From patchwork Wed Sep 3 13:36:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 190 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756906617; bh=7PP9VKR7pDSGhLno7MgrWZaghhiUDKLJ2uoYf/mfYU4=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=HTiyHClYMFaycvEJSa/olJ/9d26AA/r6n9sIFcevAl7tET+N61mA1cStHPd7mc2oi JlfRJZeGlatQgcvjoSTYPcGGUoVVwVKSEWr1/RmGl5RlacF72jPSgofAdBXp582MrG U8NIxsVGdOHrt2YpnC7Oe+/0Q+R+SquM5Fxr94o9sasBHEPyNiaBLgz5iLfQtcr2h3 TSR/jiA+gG0osfuHS+84kykEEZp4OYljsGrbrBo62x95e9ftg1BPl4GGTFeUxqSyJs BkOps32Wm4PiDGUzPTDuLla4NozGsWlRleB+uKo997qCiSDAcD1Wlk5KHtIeSEHyBL 6pXgUsMle7yVA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BEA7767915 for ; Wed, 3 Sep 2025 07:36:57 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id kfg3HrU93Tim for ; Wed, 3 Sep 2025 07:36:57 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756906617; bh=7PP9VKR7pDSGhLno7MgrWZaghhiUDKLJ2uoYf/mfYU4=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=HTiyHClYMFaycvEJSa/olJ/9d26AA/r6n9sIFcevAl7tET+N61mA1cStHPd7mc2oi JlfRJZeGlatQgcvjoSTYPcGGUoVVwVKSEWr1/RmGl5RlacF72jPSgofAdBXp582MrG U8NIxsVGdOHrt2YpnC7Oe+/0Q+R+SquM5Fxr94o9sasBHEPyNiaBLgz5iLfQtcr2h3 TSR/jiA+gG0osfuHS+84kykEEZp4OYljsGrbrBo62x95e9ftg1BPl4GGTFeUxqSyJs BkOps32Wm4PiDGUzPTDuLla4NozGsWlRleB+uKo997qCiSDAcD1Wlk5KHtIeSEHyBL 6pXgUsMle7yVA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AB96F678B4 for ; Wed, 3 Sep 2025 07:36:57 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756906615; bh=O6F9cSCGhojm7oOdRUCu2HpnK1f7dV0Bjz1ZM3iOVRM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sar2T8p15WG2UZ3SkJdP7t1uRkboUA08INNL35EqIA92vD2g8bSsqTyNNfLvZNHzp UXIDGQoIQU3pY3HgzjxxgnUOb49TM/dIY2FAs7KC1KBHr7nwdgIzVX3hSgixEewCsR urg+DICTQnn953jD0A2Jfva8HYGujhHUT+dO9BrV8IQbs0IpJgfmgT5PMJa+QCSrxL r7BDj3dErBb1E+8Ca7gC4E8Xix3CjbTgfUHCmPqkoj7HVc6UdUzP2dEhoEOCUMA98W tHZtrXm4i8MVVkrPyMP+MD/dxYSfRtIP0k1/i4qZjKnVaAq97pV6l7igA3zt3Pz65V GTMyMpw1JhbcQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BFF2F5FE1B; Wed, 3 Sep 2025 07:36:55 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 7RIPOVgdFv_8; Wed, 3 Sep 2025 07:36:55 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756906611; bh=63Nhe+okiA3bCOT9w8hDqpJZfYNWH2YBdLw+FPxrk98=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lJnr6j9mCJmnkzvzQbyNxhUWbEIdLgDgl0YP8tcJx4pR/C+r5bwtjeEjSVwz1KhC2 zyzFltCrzmtfCAYUU4ZMyMNzWXRJtAF7HBr6w5ap/U5KbIwMF9mM1X/uQyO8gdi89W y8wso+LvwA9D8EuhRklbsL5jS/GG+yhbs3+hTKKsP5+RGRy1qpGSnTsBTqZjSQZ74E CfcFfWvulWRxGYqTprxbNR2oSt3lBg3xVXMyUEMCTj63zBwe0kisOOnvEIqAOIUe4Q n6CXyvFxGXgJq8BSyVaOXInGEmGmClfZ9RNy/uCgxJhouNTDdrvGvMoeh1VHpZi1W2 5mcGLMVkkgz/g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 827035FCF5; Wed, 3 Sep 2025 07:36:51 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 3 Sep 2025 07:36:01 -0600 Message-ID: <20250903133639.3235920-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250903133639.3235920-1-sjg@u-boot.org> References: <20250903133639.3235920-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: GCBYG4OQ3L7Q2JJQYL24ZDCKZ2PSX3PY X-Message-ID-Hash: GCBYG4OQ3L7Q2JJQYL24ZDCKZ2PSX3PY X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 01/25] lib: Rename gen_v5_guid() to indicate it is little-endian List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Normally v5 GUIDs are big-endian, so rename this function. Signed-off-by: Simon Glass --- include/u-boot/uuid.h | 4 ++-- lib/efi_loader/efi_firmware.c | 8 ++++---- lib/uuid.c | 2 +- test/lib/uuid.c | 10 ++++------ tools/mkeficapsule.c | 7 +++---- 5 files changed, 14 insertions(+), 17 deletions(-) diff --git a/include/u-boot/uuid.h b/include/u-boot/uuid.h index 7f8414dc906..124a42da297 100644 --- a/include/u-boot/uuid.h +++ b/include/u-boot/uuid.h @@ -147,14 +147,14 @@ void gen_rand_uuid_str(char *uuid_str, int str_format); struct efi_guid; /** - * gen_v5_guid() - generate little endian v5 GUID from namespace and other seed data. + * gen_v5_guid_le() - generate little-endian v5 GUID from namespace and data * * @namespace: pointer to UUID namespace salt * @guid: pointer to allocated GUID output * @...: NULL terminated list of seed data as pairs of pointers * to data and their lengths */ -void gen_v5_guid(const struct uuid *namespace, struct efi_guid *guid, ...); +void gen_v5_guid_le(const struct uuid *namespace, struct efi_guid *guid, ...); /** * uuid_str_to_le_bin() - Convert string UUID to little endian binary data. diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c index 5a754c9cd03..d47c4ee96f7 100644 --- a/lib/efi_loader/efi_firmware.c +++ b/lib/efi_loader/efi_firmware.c @@ -287,10 +287,10 @@ static efi_status_t efi_gen_capsule_guids(void) log_err("fw_name is not defined. Not generating capsule GUIDs\n"); return EFI_INVALID_PARAMETER; } - gen_v5_guid(&namespace, - &fw_array[i].image_type_id, - compatible, strlen(compatible), - fw_array[i].fw_name, u16_strlen(fw_array[i].fw_name) * sizeof(uint16_t), + gen_v5_guid_le(&namespace, &fw_array[i].image_type_id, + compatible, strlen(compatible), + fw_array[i].fw_name, + u16_strlen(fw_array[i].fw_name) * sizeof(u16), NULL); log_debug("Image %ls UUID %pUl\n", fw_array[i].fw_name, diff --git a/lib/uuid.c b/lib/uuid.c index 3f7885d0877..4ca36530710 100644 --- a/lib/uuid.c +++ b/lib/uuid.c @@ -432,7 +432,7 @@ static void configure_uuid(struct uuid *uuid, unsigned char version) uuid->clock_seq_hi_and_reserved |= (UUID_VARIANT << UUID_VARIANT_SHIFT); } -void gen_v5_guid(const struct uuid *namespace, struct efi_guid *guid, ...) +void gen_v5_guid_le(const struct uuid *namespace, struct efi_guid *guid, ...) { sha1_context ctx; va_list args; diff --git a/test/lib/uuid.c b/test/lib/uuid.c index d00e9563a47..ac51c211256 100644 --- a/test/lib/uuid.c +++ b/test/lib/uuid.c @@ -67,8 +67,7 @@ static int lib_test_uuid_bits(struct unit_test_state *uts) ut_assert((uuid[8] & UUID_VARIANT_MASK) == (UUID_VARIANT << UUID_VARIANT_SHIFT)); /* Test v5, use the v4 UUID as the namespace */ - gen_v5_guid((struct uuid *)uuid, - &guid, "test", 4, NULL); + gen_v5_guid_le((struct uuid *)uuid, &guid, "test", 4, NULL); printf("v5 GUID: %pUl\n", (efi_guid_t *)uuid); @@ -105,10 +104,9 @@ static int lib_test_dynamic_uuid_case(struct unit_test_state *uts, efi_guid_t uuid; char uuid_str[37]; - gen_v5_guid(&namespace, &uuid, - data->compatible, strlen(data->compatible), - image, u16_strlen(image) * sizeof(uint16_t), - NULL); + gen_v5_guid_le(&namespace, &uuid, data->compatible, + strlen(data->compatible), image, + u16_strlen(image) * sizeof(u16), NULL); uuid_bin_to_str((unsigned char *)&uuid, uuid_str, UUID_STR_FORMAT_GUID); ut_asserteq_str(expected_uuid, uuid_str); diff --git a/tools/mkeficapsule.c b/tools/mkeficapsule.c index fb6c57f77c1..4eb70639005 100644 --- a/tools/mkeficapsule.c +++ b/tools/mkeficapsule.c @@ -947,10 +947,9 @@ static int genguid(int argc, char **argv) for (int i = 0; i < namelen; i++) fw_image[i] = (uint16_t)argv[idx][i]; - gen_v5_guid((struct uuid *)&namespace, &image_type_id, - compatible, strlen(compatible), - fw_image, namelen * sizeof(uint16_t), - NULL); + gen_v5_guid_le((struct uuid *)&namespace, &image_type_id, + compatible, strlen(compatible), fw_image, + namelen * sizeof(uint16_t), NULL); printf("%s: ", argv[idx]); print_guid(&image_type_id);