From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E324BC433EF for ; Wed, 6 Oct 2021 06:26:33 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0718E611C1 for ; Wed, 6 Oct 2021 06:26:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0718E611C1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E50CA82051; Wed, 6 Oct 2021 08:26:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="NrPecGlK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A236181918; Wed, 6 Oct 2021 08:26:29 +0200 (CEST) Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4C70E82BC7 for ; Wed, 6 Oct 2021 08:26:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-wr1-x42a.google.com with SMTP id j8so5301634wro.7 for ; Tue, 05 Oct 2021 23:26:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=g7xF9Mtn/5J0Wiw4IuB0j7kMpslIcBqf8ADBVkdtRrM=; b=NrPecGlK/bUhn5oDwhHmoAqWEPbYrMEbQChajeUCC/Eks5BGptll6ISnN0znRGfxgU t+bm6S2Njgzm8KlYCLU2ElveTFI2JM5IyZ2DO8141MRG6pPLf1OJbdtMBxJQ5/eY86Qq OoFAzcMRl87l62Jcw5Qf7XhQ1PwC1CzzqIC4sG8GIpbP8CFyhXV5vR8GeQv3kjTmJRB8 Nl/bO2YAqGW+xg1YKvqu+PjFXMw9ogK4rfbeEfN8shEgVLng9/xI411zczf6OGnZcXQr 6UGFeLsPSKwmNB4KObATRQu5GBYYJwweW+AnCAElolgaJQsa9LXiJ3cdT/kqQ61JFe35 AKHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=g7xF9Mtn/5J0Wiw4IuB0j7kMpslIcBqf8ADBVkdtRrM=; b=aqrEzeMcnv2DiwUpM3/ZyNvbNWSREsJLF0OHN5rc2c5aIDA0FT3/9labkccRZ0cvX7 ELGm+k3Lwap0wj32cSSx+bPPcCIjuHkkfVAtm0GqDeGb3jyqu6txBv8bSqF8hP9Dsp0P Erc14XUq8N9VEjuw6amw5Zex2UAaG9c4lWDgofIj6TUqwdD0b2GPmZoNvaWMRVC2RFIw ZoZo5Eq/OgVO3wf0i6antACm6c2u0+1hNOgTOrJVAAnwoO1ucH2NVJIlWRtHanXllkQE yDPbh0qR8YuOR5Lr+pgNIJ+AIxSX0cTwz9kAk2cE30KmH36ZmZfFCzmn1+wPYI1ZnTve oogw== X-Gm-Message-State: AOAM531fLXWcfNF9nCPCtlrDfJdNID+Afx/iiHFbAggCijY2YIQ+1zTO JHcaBa/m+NXE9xVXxcge3gP0YQ== X-Google-Smtp-Source: ABdhPJxlTHIYFyTAdeBErcGbkZN9wEjq8Z29Cg+OZiUFBG5t0LZEwBGeLV1cYCBgJxqwXr+RWF9c4A== X-Received: by 2002:a1c:c906:: with SMTP id f6mr8139298wmb.136.1633501585868; Tue, 05 Oct 2021 23:26:25 -0700 (PDT) Received: from apalos.home (ppp-94-66-220-209.home.otenet.gr. [94.66.220.209]) by smtp.gmail.com with ESMTPSA id k22sm20166399wrd.59.2021.10.05.23.26.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 23:26:25 -0700 (PDT) Date: Wed, 6 Oct 2021 09:26:23 +0300 From: Ilias Apalodimas To: Heinrich Schuchardt Cc: u-boot@lists.denx.de, Alexander Graf , Masahisa Kojima , AKASHI Takahiro , Sughosh Ganu Subject: Re: [PATCH v3 4/4] efi_loader: simplify tcg2_measure_secure_boot_variable() Message-ID: References: <20211003092320.4671-1-heinrich.schuchardt@canonical.com> <20211003092320.4671-5-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211003092320.4671-5-heinrich.schuchardt@canonical.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On Sun, Oct 03, 2021 at 11:23:20AM +0200, Heinrich Schuchardt wrote: > Don't duplicate GUIDs. > > Signed-off-by: Heinrich Schuchardt > --- > v3: > no change > v2: > no change > --- > lib/efi_loader/efi_tcg2.c | 29 +++++++++++++---------------- > 1 file changed, 13 insertions(+), 16 deletions(-) > > diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c > index ed1506012b..52bf1b775f 100644 > --- a/lib/efi_loader/efi_tcg2.c > +++ b/lib/efi_loader/efi_tcg2.c > @@ -11,6 +11,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -79,17 +80,12 @@ static const struct digest_info hash_algo_list[] = { > }, > }; > > -struct variable_info { > - u16 *name; > - const efi_guid_t *guid; > -}; > - > -static struct variable_info secure_variables[] = { > - {L"SecureBoot", &efi_global_variable_guid}, > - {L"PK", &efi_global_variable_guid}, > - {L"KEK", &efi_global_variable_guid}, > - {L"db", &efi_guid_image_security_database}, > - {L"dbx", &efi_guid_image_security_database}, > +static const u16 *secure_variables[] = { > + u"SecureBoot", > + u"PK", > + u"KEK", > + u"db", > + u"dbx", > }; > > #define MAX_HASH_COUNT ARRAY_SIZE(hash_algo_list) > @@ -1593,19 +1589,20 @@ static efi_status_t tcg2_measure_secure_boot_variable(struct udevice *dev) > > count = ARRAY_SIZE(secure_variables); > for (i = 0; i < count; i++) { > + const efi_guid_t *guid; > + > + guid = efi_auth_var_get_guid(secure_variables[i]); > + > /* > * According to the TCG2 PC Client PFP spec, "SecureBoot", > * "PK", "KEK", "db" and "dbx" variables must be measured > * even if they are empty. > */ > - data = efi_get_var(secure_variables[i].name, > - secure_variables[i].guid, > - &data_size); > + data = efi_get_var(secure_variables[i], guid, &data_size); > > ret = tcg2_measure_variable(dev, 7, > EV_EFI_VARIABLE_DRIVER_CONFIG, > - secure_variables[i].name, > - secure_variables[i].guid, > + secure_variables[i], guid, > data_size, data); > free(data); > if (ret != EFI_SUCCESS) > -- > 2.32.0 > Reviewed-by: Ilias Apalodimas