From patchwork Thu Aug 8 16:21:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 817721 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e11:0:b0:367:895a:4699 with SMTP id p17csp944408wrt; Thu, 8 Aug 2024 09:23:45 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXIfC+KL0ezqEoX2S6EwAi+ZtV8RIPVap3ax1ffYKDnfSc34vZy8oTVUxZf1uVspxiEttH4ilDLed8x4Etj7pcW X-Google-Smtp-Source: AGHT+IHOKqBX4H4egOit2e/Ef6yOtubhgG4FTa8H0l/lTGkrj3/Ft6Z1rV6xm9Cs7ZCeFBeG8c28 X-Received: by 2002:a05:6402:51cb:b0:59e:f6e7:5521 with SMTP id 4fb4d7f45d1cf-5bbb21e632dmr1760536a12.19.1723134225357; Thu, 08 Aug 2024 09:23:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723134225; cv=none; d=google.com; s=arc-20160816; b=OaqzUdXQXlGjRrkcmE2g/Vfs+gR27UIvIBw8MG3HpOX5u6JckZbYF730B3LmLdVm+n T3LTbi+h16A8rOlVWlK6552uaQRGVFImlA/9ZLTmigw/8LJPxhECYaKcXDK4U4p/hfc/ ffH94fqlGPb6Ss6M3nuTTpBdo6eARBauLQOINiHOcUcnvvaHsK2K3i//UMqr/o4/aqJV PKLLyu+Ym/GV/BxwWF+r/ElVf3ceeBXBYcoTwJ+zJkbGwoBY9ZL6F6cc/6rV5RCHsJDN u2pTGtZQJLjRj3ZdQ0oGZlkG0SKzR22Dy6Vdu9LkWuSaxcbH26iJO+aXSl6SLQkRgIfu fOgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=pf4OM0prvvLF0aiOGIs6XUHN+PigrIYz1lUmOKvqkEw=; fh=agjZ/guIhEAMhHGPPj2bv2oQXLz+AJM5FL9JHK/5SKA=; b=Y7VPaLW09+2W0m1lsHAEC98c9lJ8arsGekgMUq+ztjeDZBTuJIVi1QnmQSwPFz7S/b qmXZThS2DdgH/YaLlKfKQZnft4hZrZV1Rsnrkd68lRFkldwY0I1uKogiIX07IMRcIhWP tevoqWU+PQ71OQQmLcnUnjMC463ttrEK24QnMIBYDbjkwTngAU475V7kTdTUyqkJ1K2a hn1XNcstHALuaGFGfXIPHDGIPj1TekJwvVVQdQsw7ewqUK4s3aI9x+Ib+0mrK8OfAvpd 2P0N1+pLnIx5falglq8puICDoYJ37qKx2xT0Et/cqPS1e4LXIZ20zhhOI2pU5tfw0fBT V6oA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="YkELBb/v"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5bbb2bf9e4esi902670a12.18.2024.08.08.09.23.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 09:23:45 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="YkELBb/v"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0B38F88C1B; Thu, 8 Aug 2024 18:22:08 +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="YkELBb/v"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B85FE88BE0; Thu, 8 Aug 2024 18:22:05 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) (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 AFE9C874AC for ; Thu, 8 Aug 2024 18:22:03 +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=caleb.connolly@linaro.org Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-52f01b8738dso1042714e87.1 for ; Thu, 08 Aug 2024 09:22:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723134123; x=1723738923; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=pf4OM0prvvLF0aiOGIs6XUHN+PigrIYz1lUmOKvqkEw=; b=YkELBb/vsNkUQovqLMMXIgGvd5/cCxZrMNRbSLIX3Yr7KtLI4yCN0vdyXwLU+cLBtj DOINazuHGd1xGQciwohVtl2vyg+XXpKqdtYgzKc9OGE7bGG3Idze/jaCgjy7KoWQwJh1 Bfp+OlwquUi6eWhRTvOyeeaQdcF0KXEfq/GVayG4igYx16dvAWKhd7jnldXRUqI/BYlb 6goSBhi8/QUY83F6rMurN7i/u11w2/Mj52BGMOwiXO3842Dq6ld4Sy/KhIiR77bHCbl7 BsLN3U2zPW9YYOGOTSpEX8iYCb2xXPcp2vxUClfO2qAU7FMUjBnCq3eCGf3A1/y/rAae OCsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723134123; x=1723738923; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pf4OM0prvvLF0aiOGIs6XUHN+PigrIYz1lUmOKvqkEw=; b=gO5eVLFKE7WUTGpq4MtykSKQL/+Wh4d1SPZIqiFbzd8Of88N9pwDMbMcBayuWNhey0 yJJY4U757jUOMuZKIpPBHWLrvtaNMa6jxmcvFtHRuLhVVrBlYZNq1Viv5uiJf+uNvQyi NuBKtJv20/RAuX+D4UFQHAVui6oaLCJP9gdmyepEvFempapMabM+qIO7pGnpVaJtav7M n32CMMg/wVhp8IkiLHJYrwgU5eMYYuAdBpQ4ova52SACl8fekJL7Cr7w50LshyXr+YEW C0gBuPiXn7pOmccLJUjkeA4KgJWoekNuRXKwjGdScMZGuDJQwQ2Hu42S8g5hN/tCBehN JNuw== X-Forwarded-Encrypted: i=1; AJvYcCWCR5wd8cuM4NAP84L4iBTqni589knkSUpvpmqhDc7NHBt/ZY0qthiwyjcsX1uVusjm5Id8mBegMa8CgXerr2u8fQX42g== X-Gm-Message-State: AOJu0YxyojxzU2EYC/E3H2G6ohXUiMwtNSA3U4EAjq1IpGCF8ZXdsH/5 +iOM4U3AklVSgRsbXMGtoWEM1PuYzWS+tXt0pcY4Y2L6KxSBUNKkuamt28vCgYY= X-Received: by 2002:a05:6512:1149:b0:530:ac0a:15e8 with SMTP id 2adb3069b0e04-530e5817bc8mr1747030e87.11.1723134122860; Thu, 08 Aug 2024 09:22:02 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::7424]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5bbb2e5c8fbsm812351a12.79.2024.08.08.09.22.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 09:22:02 -0700 (PDT) From: Caleb Connolly Date: Thu, 08 Aug 2024 18:21:55 +0200 Subject: [PATCH v6 08/11] tools: mkeficapsule: use u-boot UUID library MIME-Version: 1.0 Message-Id: <20240808-b4-dynamic-uuid-v6-8-9332e7237119@linaro.org> References: <20240808-b4-dynamic-uuid-v6-0-9332e7237119@linaro.org> In-Reply-To: <20240808-b4-dynamic-uuid-v6-0-9332e7237119@linaro.org> To: Tom Rini , Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Mario Six , Alper Nebi Yasak , Abdellatif El Khlifi Cc: Richard Hughes , u-boot@lists.denx.de, Caleb Connolly X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3757; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=yvRcazKV9vl3+Pgpl3lDlzl/yfWSKc7gLZywA+IlSTY=; b=kA0DAAgBBYMxKxlfZLYByyZiAGa08J+i/ecmnH04m2MVRC/VbzZVtTvmdASiqEQ8p4HluILde 4kCMwQAAQgAHRYhBLZRoUY8ar7QaQxVzQWDMSsZX2S2BQJmtPCfAAoJEAWDMSsZX2S29vcQAKWd xX24s6ZgOqKmUW3S3XNk3Nz9koj65cVcQHcXsDU8r/pzvCPMzGTAZCIVJKrNgL4zXpP/zXTh94m 4VUOVC8RbiLsemfIGNkvcXPRjyQvLdb6xD0fLACiwRCo6uIvjmGbJDWMAH2NLOFMLM+yCv+0gSo U+AG4vltPUCYCOY9+hOSVSZO76WGS0H4PZrPvipoZH+NCFGEuboWA9gCMKC9GIMguMF/QDMJS1Y +jMIYtfv1NGUoREZvAkXU5kpMwY0usoV6yRLSIKwh7ZWqmME/KY+yiCkCV7foLkiSx9M98XiXmP hqhxQCJ5GbBHpgRvN6kkp+ROk3mkAq/bD/z4S5pWiL8urVSBCnP9App8oCOVRaPo/hgX4GjJL4y W2a1/8ck3mpRYsAbN7HJvmYdUjmYQpikMX04pYeTqTGFYw1Y8+Mvb1264moelEvpKXvgCEhTIeK pBFOOWc6NhgCCWGDmP6ALTciYeVQDKF6C+s2k4ec/fOXBPHGiL543xcAJRlAdR2NkP72v59t2PP FkBjncYiHMpNiDpiSZ/B8IWrt8FTMFIzmakXs42zDWmKGGDkxBI3CCSfHl5DvbGPqLrMBjVb/lt FZo21KarO8GF666M9HQZbDj6K9vHa7I9ARaihqiDtXKg7rUUKnKa/hWvQoiOy6M2/BbwSbCX00H wJE5z X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean Replace the use of libuuid with U-Boot's own UUID library. This prepares us to add support for generating v5 GUIDs. Signed-off-by: Caleb Connolly --- tools/Makefile | 8 ++++---- tools/mkeficapsule.c | 53 ++++++---------------------------------------------- 2 files changed, 10 insertions(+), 51 deletions(-) diff --git a/tools/Makefile b/tools/Makefile index 6a4280e3668f..ee08a9675df8 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -245,14 +245,14 @@ hostprogs-$(CONFIG_ASN1_COMPILER) += asn1_compiler HOSTCFLAGS_asn1_compiler.o = -idirafter $(srctree)/include HOSTCFLAGS_mkeficapsule.o += \ $(shell pkg-config --cflags gnutls 2> /dev/null || echo "") -HOSTCFLAGS_mkeficapsule.o += \ - $(shell pkg-config --cflags uuid 2> /dev/null || echo "") HOSTLDLIBS_mkeficapsule += \ $(shell pkg-config --libs gnutls 2> /dev/null || echo "-lgnutls") -HOSTLDLIBS_mkeficapsule += \ - $(shell pkg-config --libs uuid 2> /dev/null || echo "-luuid") +mkeficapsule-objs := generated/lib/uuid.o \ + generated/lib/sha1.o \ + $(LIBFDT_OBJS) \ + mkeficapsule.o hostprogs-$(CONFIG_TOOLS_MKEFICAPSULE) += mkeficapsule mkfwumdata-objs := mkfwumdata.o generated/lib/crc32.o HOSTLDLIBS_mkfwumdata += -luuid diff --git a/tools/mkeficapsule.c b/tools/mkeficapsule.c index 6a261ff549dc..54fb4dee3ee5 100644 --- a/tools/mkeficapsule.c +++ b/tools/mkeficapsule.c @@ -14,14 +14,15 @@ #include #include #include -#include #include #include #include +#include + #include "eficapsule.h" static const char *tool_name = "mkeficapsule"; @@ -573,39 +574,8 @@ err: return ret; } -/** - * convert_uuid_to_guid() - convert UUID to GUID - * @buf: UUID binary - * - * UUID and GUID have the same data structure, but their binary - * formats are different due to the endianness. See lib/uuid.c. - * Since uuid_parse() can handle only UUID, this function must - * be called to get correct data for GUID when parsing a string. - * - * The correct data will be returned in @buf. - */ -void convert_uuid_to_guid(unsigned char *buf) -{ - unsigned char c; - - c = buf[0]; - buf[0] = buf[3]; - buf[3] = c; - c = buf[1]; - buf[1] = buf[2]; - buf[2] = c; - - c = buf[4]; - buf[4] = buf[5]; - buf[5] = c; - - c = buf[6]; - buf[6] = buf[7]; - buf[7] = c; -} - static int create_empty_capsule(char *path, efi_guid_t *guid, bool fw_accept) { struct efi_capsule_header header = { 0 }; FILE *f = NULL; @@ -649,22 +619,12 @@ err: } static void print_guid(void *ptr) { - int i; - efi_guid_t *guid = ptr; - const uint8_t seq[] = { - 3, 2, 1, 0, '-', 5, 4, '-', 7, 6, - '-', 8, 9, '-', 10, 11, 12, 13, 14, 15 }; + static char buf[37] = { 0 }; - for (i = 0; i < ARRAY_SIZE(seq); i++) { - if (seq[i] == '-') - putchar(seq[i]); - else - printf("%02X", guid->b[seq[i]]); - } - - printf("\n"); + uuid_bin_to_str(ptr, buf, UUID_STR_FORMAT_GUID|UUID_STR_UPPER_CASE); + printf("%s\n", buf); } static uint32_t dump_fmp_payload_header( struct fmp_payload_header *fmp_payload_hdr) @@ -902,13 +862,12 @@ int main(int argc, char **argv) fprintf(stderr, "Image type already specified\n"); exit(EXIT_FAILURE); } - if (uuid_parse(optarg, uuid_buf)) { + if (uuid_str_to_bin(optarg, uuid_buf, UUID_STR_FORMAT_GUID)) { fprintf(stderr, "Wrong guid format\n"); exit(EXIT_FAILURE); } - convert_uuid_to_guid(uuid_buf); guid = (efi_guid_t *)uuid_buf; break; case 'i': index = strtoul(optarg, NULL, 0);