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 X-Spam-Level: X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E522C433EF for ; Sat, 11 Sep 2021 07:29:39 +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 2E4B9606A5 for ; Sat, 11 Sep 2021 07:29:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2E4B9606A5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmx.de 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 939AA83783; Sat, 11 Sep 2021 09:29:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="HTlxR0BQ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CC01383743; Sat, 11 Sep 2021 09:28:56 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8513383771 for ; Sat, 11 Sep 2021 09:28:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1631345327; bh=ByjHbMsDzH/YKg+P52Cpx8NpVP7SsmURKURA1A1VBHs=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=HTlxR0BQp7EDJ5CRAkP9yOE2K2AtE6+tl1w7hXhfBPRuh/FLvPYZT4u3ub/FBKZGD w+3OimFFVqH5FyueNV8LViK3DIE1kapgB57eIAZngDuLXIxVqOUcCS3wXWEHqD1BuN 0uzVU9fZKAF8dPXu49/WEXJnPC8c2l9pPt9BKUzo= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from LT02.fritz.box ([88.152.144.157]) by mail.gmx.net (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MTRQq-1mUQ1i43dE-00ThKq; Sat, 11 Sep 2021 09:28:47 +0200 From: Heinrich Schuchardt To: u-boot@lists.denx.de Cc: Ilias Apalodimas , AKASHI Takahiro , Sughosh Ganu , Masahisa Kojima , Alexander Graf , Heinrich Schuchardt Subject: [PATCH 4/4] efi_loader: simplify tcg2_measure_secure_boot_variable() Date: Sat, 11 Sep 2021 09:28:32 +0200 Message-Id: <20210911072832.16991-5-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210911072832.16991-1-xypron.glpk@gmx.de> References: <20210911072832.16991-1-xypron.glpk@gmx.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1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rOgUnTQL 5nMpXsylHV7PB3kSjCvuLwFulXs29bLZjipKqyjrwLReAjJjCDybx7Gbi1yHMMUGY3d6rLpff Ha8GW9LOXTYzH2RQiDtkBPkwacqEExeXtxtxMztB3vTqTW+PcV/5ZzmBAvhwP/l6oAiDjGq/R cZ4nki2QO1MMr92n9VNDTVyyTUywNYxShedi0PPrqe+vEvUio6J/1sAqVT6Om8/TL81KGEscs PWNEVyo0cZr6AgVpvOw50UjEV7K/fCYnv610G/0XlL4FcwJduTO0vZBqwgdxCGgFUEEzxTbdC Lcdg8Vtp+gykCY= 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 Don't duplicate GUIDs. Signed-off-by: Heinrich Schuchardt =2D-- 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 beb224f66a..eb2c0a413c 100644 =2D-- 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[] =3D { }, }; -struct variable_info { - u16 *name; - const efi_guid_t *guid; -}; - -static struct variable_info secure_variables[] =3D { - {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[] =3D { + u"SecureBoot", + u"PK", + u"KEK", + u"db", + u"dbx", }; #define MAX_HASH_COUNT ARRAY_SIZE(hash_algo_list) @@ -1587,19 +1583,20 @@ static efi_status_t tcg2_measure_secure_boot_varia= ble(struct udevice *dev) count =3D ARRAY_SIZE(secure_variables); for (i =3D 0; i < count; i++) { + const efi_guid_t *guid; + + guid =3D 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 =3D efi_get_var(secure_variables[i].name, - secure_variables[i].guid, - &data_size); + data =3D efi_get_var(secure_variables[i], guid, &data_size); ret =3D 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 !=3D EFI_SUCCESS) =2D- 2.30.2