From patchwork Sat Sep 11 07:28:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1526685 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.a=rsa-sha256 header.s=badeba3b8450 header.b=fwddDUX3; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4H64BJ6cQ6z9sRN for ; Sat, 11 Sep 2021 17:29:28 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4C75783768; Sat, 11 Sep 2021 09:28:59 +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="fwddDUX3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 57B938371F; Sat, 11 Sep 2021 09:28:53 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 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 F087B8372B for ; Sat, 11 Sep 2021 09:28:47 +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=1631345326; bh=mhhoiB0uj61geB3r2Ge13UwrLjYgRF1hk0l8S/oqYOg=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=fwddDUX3Ztf3fR/QsczAGxqK9VeWEAfGiEl64sk/30w0XcuJyVWmsbtIXp7JcNADp roDV5z0Kn3QNN53dh9VuvZiQ6RCRimpd/qD7yquU3MsTHGUSjBB31WCNPSk9uiwMui CN3n1RwDchOzt3rGcG+xMUR2R6MxC7sAmw9LLAmk= 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 1MGyxX-1mCbEb0TBL-00E7rD; Sat, 11 Sep 2021 09:28:46 +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 1/4] efi_loader: treat UEFI variable name as const Date: Sat, 11 Sep 2021 09:28:29 +0200 Message-Id: <20210911072832.16991-2-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 X-Provags-ID: V03:K1:zkIwG1EmOC2YvDZqZNBDH2RwLG4zzb3x34Gfls07tkbw34a3IlK 1D/VxEGD5XQQGziLBXQth2yAhUsJfriEdqVwhCEIhd9Z/sS2ffO7Qr4oHbV4hoVPgj9VdGe LpAD3DDNtq7pZVxLRyoaf8+ncBiYNBwQjXYap5igEAoM6XTArLcs1JOSrpKvODh3MWgt80a gLqnYZsN30OnNTh7Oc7Kg== X-UI-Out-Filterresults: notjunk:1;V03:K0:XvZ0Z8NLAM0=:cUSYDZ0R1jDqc2897JLG1S hfsFsDgP8vZXtXxqriDpjbJPK8lcUoPFqyxwBoAZjSOmz5nSHZ6J46Q96+lS6IaSOEtXJQ3Hj ym51XUjB+kUr5ymKxQfqH6ASkBUWKXHJY9cbdNUECKj1PKMhgquT6bgkNWgvqdBGIfpWSpJlK nQ13oy2CHsqlAQMbHczc4AuDAvt199CgL3DKSZvWroLGwuWIBoTGl1+g1Qikkw/WOSrXjD3JQ 2Y/GN2QRQaTu7U+jbK0T7pr/pObj8uRXS0BXJkZXLHycxuCuI7GJidYhETJoAU9tqDEA3cZPq KLndpBqw+zaWuRQdawfk0N4ZcvC4IYQNA9YnxsiD/jr4LLqSTeqmmfnorHs+Vu7JJyHJg+1jN x4Y7KoQPekQEGn7RsW+G0K1vhnN5QIFRHxzjSyuGniwIqqd88FIalh6LiicE8qNs7JIcCS1Dj SCqKATccvuUKWC6+5tzpQhrI3sPe7Bni/gcHNMycl4laR+X3FF0wYgLS8npDy5v1zaoRSCopI kURpPAS4ULfrwgV7B4kbsCWrWge2JMsPbZ0dFmQ82czWu5yf2BK2JzJnCE9GdcueaNdnugLPg MJ/uguQjEK+PjnWv3pyY7E+vccy6fes32b9hd1Q7ArfYhCxYsTJ/X18dtzAlvlhZ1CisuAq8I dvlNLEFTRALehiUtd1MHUFcmMbZGjh3KnMtuTNb7hgRvDEdClC3b4w85vdWLr1z9DH1KLSucv rRt0IIwicKqZJq9q2GFfbVrTW+5dURXhOV6e9KEklr//2ZgondNF9vcOKcBdFLIE75Nk3LR7L EchtvOAWjTN9gyUnKKuP0KtyxmFwMYmPbZeCfowDz2fXPXSTWqzz3tovH83Ecz2QIKD9h4WFX YeoQOTWv8LYiZZ9AsXUWJ0HZyYvOsGwFJ7I0WlGDBj7WqL/vDKhf2VjlgHQfXoDglbnmOudeD u8iGyv8M7c20Wn5dFP28uEli5FsquG+8/7Isejpq9epWtdrOHeDiJ0BfvVqOupM5qLu2fR2MY pq4igIKFbcCl2gAY3FrT9+crkN4xGDJX3L3YZg3Vc0DDE2ASxgctZE0+OuOmVc+KOOtK+S8sG ly+qlwMxrnGXvk= 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 Adjust several internal functions to treat UEFI variable names as const. Signed-off-by: Heinrich Schuchardt --- include/efi_loader.h | 2 +- include/efi_variable.h | 16 ++++++++++------ lib/efi_loader/efi_tcg2.c | 2 +- lib/efi_loader/efi_var_common.c | 5 +++-- lib/efi_loader/efi_var_mem.c | 7 ++++--- lib/efi_loader/efi_variable.c | 9 +++++---- lib/efi_loader/efi_variable_tee.c | 16 ++++++++++------ 7 files changed, 34 insertions(+), 23 deletions(-) -- 2.30.2 diff --git a/include/efi_loader.h b/include/efi_loader.h index c440962fe5..125052d002 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -816,7 +816,7 @@ efi_status_t EFIAPI efi_query_variable_info( u64 *remaining_variable_storage_size, u64 *maximum_variable_size); -void *efi_get_var(u16 *name, const efi_guid_t *vendor, efi_uintn_t *size); +void *efi_get_var(const u16 *name, const efi_guid_t *vendor, efi_uintn_t *size); /* * See section 3.1.3 in the v2.7 UEFI spec for more details on diff --git a/include/efi_variable.h b/include/efi_variable.h index 0440d356bc..8f666b2309 100644 --- a/include/efi_variable.h +++ b/include/efi_variable.h @@ -32,7 +32,8 @@ enum efi_auth_var_type { * @timep: authentication time (seconds since start of epoch) * Return: status code */ -efi_status_t efi_get_variable_int(u16 *variable_name, const efi_guid_t *vendor, +efi_status_t efi_get_variable_int(const u16 *variable_name, + const efi_guid_t *vendor, u32 *attributes, efi_uintn_t *data_size, void *data, u64 *timep); @@ -47,7 +48,8 @@ efi_status_t efi_get_variable_int(u16 *variable_name, const efi_guid_t *vendor, * @ro_check: check the read only read only bit in attributes * Return: status code */ -efi_status_t efi_set_variable_int(u16 *variable_name, const efi_guid_t *vendor, +efi_status_t efi_set_variable_int(const u16 *variable_name, + const efi_guid_t *vendor, u32 attributes, efi_uintn_t data_size, const void *data, bool ro_check); @@ -224,7 +226,7 @@ void efi_var_mem_del(struct efi_var_entry *var); * @time: time of authentication (as seconds since start of epoch) * Result: status code */ -efi_status_t efi_var_mem_ins(u16 *variable_name, +efi_status_t efi_var_mem_ins(const u16 *variable_name, const efi_guid_t *vendor, u32 attributes, const efi_uintn_t size1, const void *data1, const efi_uintn_t size2, const void *data2, @@ -251,7 +253,8 @@ efi_status_t efi_init_secure_state(void); * @guid: guid of UEFI variable * Return: identifier for authentication related variables */ -enum efi_auth_var_type efi_auth_var_get_type(u16 *name, const efi_guid_t *guid); +enum efi_auth_var_type efi_auth_var_get_type(const u16 *name, + const efi_guid_t *guid); /** * efi_get_next_variable_name_mem() - Runtime common code across efi variable @@ -280,8 +283,9 @@ efi_get_next_variable_name_mem(efi_uintn_t *variable_name_size, u16 *variable_na * Return: status code */ efi_status_t __efi_runtime -efi_get_variable_mem(u16 *variable_name, const efi_guid_t *vendor, u32 *attributes, - efi_uintn_t *data_size, void *data, u64 *timep); +efi_get_variable_mem(const u16 *variable_name, const efi_guid_t *vendor, + u32 *attributes, efi_uintn_t *data_size, void *data, + u64 *timep); /** * efi_get_variable_runtime() - runtime implementation of GetVariable() diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c index 401acf3d4f..beb224f66a 100644 --- a/lib/efi_loader/efi_tcg2.c +++ b/lib/efi_loader/efi_tcg2.c @@ -1359,7 +1359,7 @@ static efi_status_t efi_append_scrtm_version(struct udevice *dev) * Return: status code */ static efi_status_t tcg2_measure_variable(struct udevice *dev, u32 pcr_index, - u32 event_type, u16 *var_name, + u32 event_type, const u16 *var_name, const efi_guid_t *guid, efi_uintn_t data_size, u8 *data) { diff --git a/lib/efi_loader/efi_var_common.c b/lib/efi_loader/efi_var_common.c index a00bbf1620..e179932124 100644 --- a/lib/efi_loader/efi_var_common.c +++ b/lib/efi_loader/efi_var_common.c @@ -374,7 +374,8 @@ bool efi_secure_boot_enabled(void) return efi_secure_boot; } -enum efi_auth_var_type efi_auth_var_get_type(u16 *name, const efi_guid_t *guid) +enum efi_auth_var_type efi_auth_var_get_type(const u16 *name, + const efi_guid_t *guid) { for (size_t i = 0; i < ARRAY_SIZE(name_type); ++i) { if (!u16_strcmp(name, name_type[i].name) && @@ -393,7 +394,7 @@ enum efi_auth_var_type efi_auth_var_get_type(u16 *name, const efi_guid_t *guid) * * Return: buffer with variable data or NULL */ -void *efi_get_var(u16 *name, const efi_guid_t *vendor, efi_uintn_t *size) +void *efi_get_var(const u16 *name, const efi_guid_t *vendor, efi_uintn_t *size) { efi_status_t ret; void *buf = NULL; diff --git a/lib/efi_loader/efi_var_mem.c b/lib/efi_loader/efi_var_mem.c index 3d335a8274..13909b1d26 100644 --- a/lib/efi_loader/efi_var_mem.c +++ b/lib/efi_loader/efi_var_mem.c @@ -134,7 +134,7 @@ void __efi_runtime efi_var_mem_del(struct efi_var_entry *var) } efi_status_t __efi_runtime efi_var_mem_ins( - u16 *variable_name, + const u16 *variable_name, const efi_guid_t *vendor, u32 attributes, const efi_uintn_t size1, const void *data1, const efi_uintn_t size2, const void *data2, @@ -274,8 +274,9 @@ efi_status_t efi_var_mem_init(void) } efi_status_t __efi_runtime -efi_get_variable_mem(u16 *variable_name, const efi_guid_t *vendor, u32 *attributes, - efi_uintn_t *data_size, void *data, u64 *timep) +efi_get_variable_mem(const u16 *variable_name, const efi_guid_t *vendor, + u32 *attributes, efi_uintn_t *data_size, void *data, + u64 *timep) { efi_uintn_t old_size; struct efi_var_entry *var; diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c index fa2b6bc7a8..5adc7f821a 100644 --- a/lib/efi_loader/efi_variable.c +++ b/lib/efi_loader/efi_variable.c @@ -45,7 +45,7 @@ * * Return: status code */ -static efi_status_t efi_variable_authenticate(u16 *variable, +static efi_status_t efi_variable_authenticate(const u16 *variable, const efi_guid_t *vendor, efi_uintn_t *data_size, const void **data, u32 given_attr, @@ -194,7 +194,7 @@ err: return ret; } #else -static efi_status_t efi_variable_authenticate(u16 *variable, +static efi_status_t efi_variable_authenticate(const u16 *variable, const efi_guid_t *vendor, efi_uintn_t *data_size, const void **data, u32 given_attr, @@ -205,7 +205,7 @@ static efi_status_t efi_variable_authenticate(u16 *variable, #endif /* CONFIG_EFI_SECURE_BOOT */ efi_status_t __efi_runtime -efi_get_variable_int(u16 *variable_name, const efi_guid_t *vendor, +efi_get_variable_int(const u16 *variable_name, const efi_guid_t *vendor, u32 *attributes, efi_uintn_t *data_size, void *data, u64 *timep) { @@ -219,7 +219,8 @@ efi_get_next_variable_name_int(efi_uintn_t *variable_name_size, return efi_get_next_variable_name_mem(variable_name_size, variable_name, vendor); } -efi_status_t efi_set_variable_int(u16 *variable_name, const efi_guid_t *vendor, +efi_status_t efi_set_variable_int(const u16 *variable_name, + const efi_guid_t *vendor, u32 attributes, efi_uintn_t data_size, const void *data, bool ro_check) { diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c index 51920bcb51..281f886124 100644 --- a/lib/efi_loader/efi_variable_tee.c +++ b/lib/efi_loader/efi_variable_tee.c @@ -284,7 +284,8 @@ out: * StMM can store internal attributes and properties for variables, i.e enabling * R/O variables */ -static efi_status_t set_property_int(u16 *variable_name, efi_uintn_t name_size, +static efi_status_t set_property_int(const u16 *variable_name, + efi_uintn_t name_size, const efi_guid_t *vendor, struct var_check_property *var_property) { @@ -317,7 +318,8 @@ out: return ret; } -static efi_status_t get_property_int(u16 *variable_name, efi_uintn_t name_size, +static efi_status_t get_property_int(const u16 *variable_name, + efi_uintn_t name_size, const efi_guid_t *vendor, struct var_check_property *var_property) { @@ -361,7 +363,8 @@ out: return ret; } -efi_status_t efi_get_variable_int(u16 *variable_name, const efi_guid_t *vendor, +efi_status_t efi_get_variable_int(const u16 *variable_name, + const efi_guid_t *vendor, u32 *attributes, efi_uintn_t *data_size, void *data, u64 *timep) { @@ -502,9 +505,10 @@ out: return ret; } -efi_status_t efi_set_variable_int(u16 *variable_name, const efi_guid_t *vendor, - u32 attributes, efi_uintn_t data_size, - const void *data, bool ro_check) +efi_status_t efi_set_variable_int(const u16 *variable_name, + const efi_guid_t *vendor, u32 attributes, + efi_uintn_t data_size, const void *data, + bool ro_check) { efi_status_t ret, alt_ret = EFI_SUCCESS; struct var_check_property var_property; From patchwork Sat Sep 11 07:28:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1526688 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.a=rsa-sha256 header.s=badeba3b8450 header.b=i+FEjOMB; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4H64Bk5qDgz9sRN for ; Sat, 11 Sep 2021 17:29:50 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EC24F83788; Sat, 11 Sep 2021 09:29:15 +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="i+FEjOMB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5D08C83772; Sat, 11 Sep 2021 09:28:57 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) (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 4874983768 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=1631345326; bh=ibqOlPsidCPZGqCNG7zWjmbyYzppZ8FP/BMSsrCQUMA=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=i+FEjOMB6zo0c2SZBoa7/TxeZpeQnr6tDnVR+Ekg5/93sqlPVKt7gveUnJm2xUpqD nUri4JaZddNxMi5kAbatZIO5B9dUnG7dCJQQql9KV9+UUxRbtbhlWwhl5CjVHQr8Wa nWgHcCvxN/Tvxjy7SNf5TFnNdnIDDDpQ3UoaeQZQ= 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 1M4b1y-1mOPTU1fQU-001lOs; Sat, 11 Sep 2021 09:28:46 +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 2/4] efi_loader: function to get GUID for variable name Date: Sat, 11 Sep 2021 09:28:30 +0200 Message-Id: <20210911072832.16991-3-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 X-Provags-ID: V03:K1:2tsXnFzyfREjlP4AuqZIGzpZ7gU8gbocUhv1tgRFUir4PjPVN4a 4a7jrTuG1Jjn+9ANkKrELgFwBSysVyBUc2E7moT2UVEEk36vKRwuqIiiW+rjWA0JGBJmtEh 8jygskke+DTNMJdBqmTVdK3pP99Fek3p7snER0+7HFdRwcI+GsSh9Akou6bT8bKfJFEx/I2 Z/3LQ/CUB5CIwpjmgdsGg== X-UI-Out-Filterresults: notjunk:1;V03:K0:a7DOz3fRSeo=://B77/BNxZNaP0Quk03kC1 tJ5Bd+ZmRa+QEfXHWN8pWIh0Wcs4x6XP0hWKbTO/rvkC5pEN3s2uX5bfDyyGcvh0hgMEaw9BG i/J7STfcC5rPxv5UYghVyCwrOdj6pF9mwILJa5Kn9o1DBBDAu83eGDHgQWv7AjUzoO0aDXZ0m fwwsPPjoZdQsI/+ktBgi30ttuSQJDJCCU4XQ6gC4oDGpcrzdFUwD14TQZEEBG331hPA+9bBtJ mBJSeQS2EbJ5bqT+fRUPt9d16zj0rNqfpHpvs5JjZzyH1olspoag56sXEycQufozk2rYUKOEa kJg/P625hTJe1rhjZfe+hi9zVUdze+l09+a7n+8ef8tWzcV0eZi6KWQMvGx9eSu05A7hqiTOU fhNrWJAidIo+dJN+qGuKm+oWPszsBhwF7B+na0DB0aRuYP5K6+nAdwEiMxSLMYMHDdBkrr/Ed mbkDpamS/y7ePME3IqhVb9/e4UTRkzduVAoGXd7b43wvNMY6IMR1kmrp710fU6bBFUQwPmoms JEG4UDWIwZQ/udRHumKjEuvACOxMiVxH/6FlHUwyIjqajyBz2+MIwrgbiFnPpYHGfI3H0+pGg pUTGdpFjmixR2fK7I8n2SnqcF90bvb3nBbi1Uu2vzE+Vtoso0Qmao3TW2qPlTYw6NmIWk3z7h hQxd/QctLg231yae4318vV7s4jGrT9dnvHTe6ESET+DfOG9M/J7CGOO6bzUNlUBqNKf98PLSd wWj4j0yQUQctgJhHSRt9MeeYK+ur18cKYycoeMxShgN5DbgP4pa3sRz/ZGs02JGsoVbgsAqZi dB/aUnTVKIXLYIwr6yLynafcG6ljjA+HCmlG6Ji0+QohQ04yYk85i7uZ6KDt8d/dF+F0gtUPU RxKQ1ODNCJ/OWpV7aRAwGnMU+tbYpXpboHuWD+dM1JE3F7U35/c3n7CeL6J/ocanRWWiXukxr 5TH56VStbTnEcrflQrtzL+Z9zqWXAwSAjyFmQ6qT2qPT3ultrT4IT1QisbOBfhaZufptaiABo ebjUY8S4Kqh9sGzLTlNHYalJciydC9o2VfQpag3RLx+gr1nLQJuQCNbrXCccSqFK96rx8GIle NftgKMK56kysNQ= 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 In multiple places we need the default GUID used for variables like 'PK', 'KEK', 'db'. Provide a function for it. Signed-off-by: Heinrich Schuchardt Reviewed-by: Ilias Apalodimas --- include/efi_variable.h | 8 ++++++++ lib/efi_loader/efi_var_common.c | 9 +++++++++ 2 files changed, 17 insertions(+) -- 2.30.2 diff --git a/include/efi_variable.h b/include/efi_variable.h index 8f666b2309..03a3ecb235 100644 --- a/include/efi_variable.h +++ b/include/efi_variable.h @@ -256,6 +256,14 @@ efi_status_t efi_init_secure_state(void); enum efi_auth_var_type efi_auth_var_get_type(const u16 *name, const efi_guid_t *guid); +/** + * efi_auth_var_get_guid() - get the predefined GUID for a variable name + * + * @name: name of UEFI variable + * Return: guid of UEFI variable + */ +const efi_guid_t *efi_auth_var_get_guid(const u16 *name); + /** * efi_get_next_variable_name_mem() - Runtime common code across efi variable * implementations for GetNextVariable() diff --git a/lib/efi_loader/efi_var_common.c b/lib/efi_loader/efi_var_common.c index e179932124..3cbb7c96c2 100644 --- a/lib/efi_loader/efi_var_common.c +++ b/lib/efi_loader/efi_var_common.c @@ -385,6 +385,15 @@ enum efi_auth_var_type efi_auth_var_get_type(const u16 *name, return EFI_AUTH_VAR_NONE; } +const efi_guid_t *efi_auth_var_get_guid(const u16 *name) +{ + for (size_t i = 0; i < ARRAY_SIZE(name_type); ++i) { + if (!u16_strcmp(name, name_type[i].name)) + return name_type[i].guid; + } + return &efi_global_variable_guid; +} + /** * efi_get_var() - read value of an EFI variable * From patchwork Sat Sep 11 07:28:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1526686 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.a=rsa-sha256 header.s=badeba3b8450 header.b=PfXhDyDK; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4H64BL0jxVz9sf8 for ; Sat, 11 Sep 2021 17:29:30 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4A5F383777; Sat, 11 Sep 2021 09:29:04 +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="PfXhDyDK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 43B4F83773; Sat, 11 Sep 2021 09:28:56 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 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 5368783743 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=1631345326; bh=uuDUrL9GhF7Qn5Ijarpz9M0AgMtxBdoAg36TO51HtWI=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=PfXhDyDKXJTwO4uP6JRta22xo6vXAvzaPyTBulKOQtVgDaumreE8Y9UiBWKeIgwRb 7Stao02K1EP93TRdTyhpv0JMmMgyjCPRDPK/cOCKTGL6gCvUYwRpD9hyG6mm49Z1dF fJe4fyjWN9s7hFzQ6exsoV6RaY6lJqve5pmb8C4Q= 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 1Mv31c-1nFp4o2rzs-00qysO; Sat, 11 Sep 2021 09:28:46 +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 3/4] efi_loader: simplify efi_sigstore_parse_sigdb() Date: Sat, 11 Sep 2021 09:28:31 +0200 Message-Id: <20210911072832.16991-4-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 X-Provags-ID: V03:K1:kPiWdznNzB2E4FN3Th5M+DJ6BiQkejSyLyC/XJC3r/jDpqkWFOj 5wWyG0NJbO6gunqsaRKaDVntlz1ylVHBEKJ94LNI/GWRdjTM00dpDtlnTUXvx0+6QLsISmZ +ojQHv31eRh/qCYohjZHMEN6A5n3I+MtoFPKfMsIg/0Xc5ZGNOg3rBkyDLKO3V/QmuQFCiM DVBWJrmAvSLooe4D9r4CA== X-UI-Out-Filterresults: notjunk:1;V03:K0:xo48tohki9A=:477HpqP3ttfU9yoFTPp5qO Ba8WWkIpKJFRzhlEu16wEaQKWGB2aQjrc7z7U/2k0zoiC59zfHq8oZH/Yq/aakKKkRuWAXkAd OvC7snIC6G1AXObjfC9VuG5J0S8FR0/TkpYnIKcxL7L1XYu1z9O1iE4ROgIuxTpzHN63yPKQJ S1WB0s5/m74nmMkrP2BZJTCROIoZG0OAIiHV7lo4q7YU5i+J+ci+nAasM5P2S7HlxI4CMO6ET SK3/RqGAy/SjkTdLXNNZWsAZ/4TkYmnmO9f+GVNWpRZGmNunZ4aGrS31uc1zdAK0Coo0vjGZc Zvt+YYd/VV9PtsB4Gx4uwcy0MQ6zjLAdC+EogATbhPjkazlb4meAVu8l1hYAKDgJQoghvkrcD HnDbUDjtZOpuqLLcX3TDyPwUJIF8J1ATIM1Wa716ibXlfWrFpjXJTAjt5UEin30nw8miOvtT0 FU9db9N2gKtmPatgV+Lww1FtkPdWMtmhgY+Ckumc4d90exQuU1ddGTyOHvLeLqlbi+PxkM7LM wm0uZDunY60wQTTXuRHLVT+pZ1PR9uSkbH1icQiP11nGbIS7SODzdGOnQI3eVyJ/vbfQ3wMw1 kubHx/w7HVT3UA626ud3fn5Y/v9pQns7lkgbtGat+BFP9M4t1Hh3LeNRWXu2/lHEAH16ACHlx RyoUVBPBSvOiRJj+aEy60cqB3I+L+2Eb0m1HMKv4qQi8jts/QvisErpAiJTqtoD0AWTPdWShl XbeeD1qoBXN03Kwoq/gKQk3BM8ZhG7qFoqzSN1CLWbuwSET5UGYPVylYlCioAMkQKOo7ptntS a/TPWizQqsthkMm5aQ9dP+fOkkwX0s0ciRNh4/GBgBeUq7JQQlbhjuPjpTapnR476R/SSFDB/ s4TLemYM+Dxyd5H24KeGqzQuJME8hLHTPnFWu4BX/tL7wPW8aRC+thvhL+gnvGfc9xjJIyZwJ T6wX+/FkO2w7ZhynRVdR+Q8gg3M+JxPnLmXzI2iMEMPgekwXmUoKimIAf4l+xgCOUOC86sCkD VwbkYigwteyeeCzkoPd52q+NvcdhOt6Z11blawtJFYDymVWWP8qrnSc4NmSbh3IQIfOLlxxRv dGGvOSATVEezx0= 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 Simplify efi_sigstore_parse_sigdb() by using existing functions. Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/efi_signature.c | 35 ++++++---------------------------- 1 file changed, 6 insertions(+), 29 deletions(-) -- 2.30.2 diff --git a/lib/efi_loader/efi_signature.c b/lib/efi_loader/efi_signature.c index bdd09881fc..b741905a99 100644 --- a/lib/efi_loader/efi_signature.c +++ b/lib/efi_loader/efi_signature.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -740,44 +741,20 @@ err: */ struct efi_signature_store *efi_sigstore_parse_sigdb(u16 *name) { - struct efi_signature_store *sigstore = NULL; const efi_guid_t *vendor; void *db; efi_uintn_t db_size; - efi_status_t ret; - if (!u16_strcmp(name, L"PK") || !u16_strcmp(name, L"KEK")) { - vendor = &efi_global_variable_guid; - } else if (!u16_strcmp(name, L"db") || !u16_strcmp(name, L"dbx")) { - vendor = &efi_guid_image_security_database; - } else { + vendor = efi_auth_var_get_guid(name); + if (!vendor) { EFI_PRINT("unknown signature database, %ls\n", name); return NULL; } - /* retrieve variable data */ - db_size = 0; - ret = EFI_CALL(efi_get_variable(name, vendor, NULL, &db_size, NULL)); - if (ret == EFI_NOT_FOUND) { - EFI_PRINT("variable, %ls, not found\n", name); - sigstore = calloc(sizeof(*sigstore), 1); - return sigstore; - } else if (ret != EFI_BUFFER_TOO_SMALL) { - EFI_PRINT("Getting variable, %ls, failed\n", name); - return NULL; - } - - db = malloc(db_size); + db = efi_get_var(name, vendor, &db_size); if (!db) { - EFI_PRINT("Out of memory\n"); - return NULL; - } - - ret = EFI_CALL(efi_get_variable(name, vendor, NULL, &db_size, db)); - if (ret != EFI_SUCCESS) { - EFI_PRINT("Getting variable, %ls, failed\n", name); - free(db); - return NULL; + EFI_PRINT("variable, %ls, not found\n", name); + return calloc(sizeof(struct efi_signature_store), 1); } return efi_build_signature_store(db, db_size); From patchwork Sat Sep 11 07:28:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1526687 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.a=rsa-sha256 header.s=badeba3b8450 header.b=HTlxR0BQ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4H64BX6rstz9sRN for ; Sat, 11 Sep 2021 17:29:40 +1000 (AEST) 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) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 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 X-Provags-ID: V03:K1:6h5wBNTMtQVX2y+euJUodJB6VCQvl80d8yisEIw48omtlsbzzYP F4v5BDgL2KoNjtxW9DOL/ozEWSbIYQpAx7D4rmeaHX67AcY5T19SSSWy3HwnDJg+fQBMAGW rPQXyjcqyGHamqpA15+KsdyPr6i+W/6ArR5+iCaK016b9CD2n1zWyyn9JfCuUeycdaRYWY3 V3Jpu2SAjqkSzR9NOmmog== X-UI-Out-Filterresults: notjunk:1;V03:K0:/7U61Tb0jq0=:N2SZ6hKljEfzp8Tosjcrkv ta9jnUcUERjIXdaO1m7lOYJLIg/rCLumCuHnFabpaPXrSkUOF8X2Mmpi9/ExLg8e+Zq71+KHP WN6SPnAZqN0Gdih7dO6aqws3Dvsftu3LYl0tV9hc5GiCL6CcBkIJ2iM/TW5B2c59RAkW9e91M hl1UdJx32GqgrDwfLhQ2rcb7XwioLjjdSXd2ZWAdxux7FXLD/8TaKoZWhup6W6XSSwf3hc2ML ejDBxukYoYs1ulGx4no3ezE2bKIpsPng7BxQtxe26kFirSZOWtMtGOFpG0IBLLZURSl4f29S/ YLU/EGwz8J8U9W7qtyQyvcnVkhgbBC1EvuSV2Q2+TLhFXRiYkVc+ahaG+FVzv2EERMAU+REnD mgM9C+ArC1OgH1d5ABYGGwTSlNfprMYCmSl5gTCcCGjn2SI/KpFni1ck/7v+9FqwU+QpjFMNG YMEFsUlpPJey9V151hdlBAHZYTS5Ao4ah72RudB8pYYSr/P1K5io+XVOo91IuTMxJpdgogV3C oU2+j1SpOiSUlQU4AUW+yVe6pYe23cxN/KUGOvmFX9/4v37/WIr2TY+3U1fvmzF7gnrQuK6+w seMGNmy08/dFnYu2RAbo4L/ybZe1hh68cMIncZEE7xmWSSOY7Oa1lmR64E7YluHKn8M47yCrX b45XvnK+0ujISNW/ComxJJe5fxmMeBijdrEHkTIdbTl+jkYSucGdP0bZ4QcOQOYhjbtTMzIU3 gU88YrMFtU6qmoyfYnPqzB+iP6HE650NfI6HQ9nBUrfiKAObyfYjFDxUK79fBb6U1rOgUnTQL 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 --- lib/efi_loader/efi_tcg2.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) -- 2.30.2 diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c index beb224f66a..eb2c0a413c 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) @@ -1587,19 +1583,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)