From patchwork Fri Aug 9 00:56:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 818105 Delivered-To: patch@linaro.org Received: by 2002:a5d:5711:0:b0:367:895a:4699 with SMTP id a17csp89562wrv; Thu, 8 Aug 2024 17:58:04 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV8v8m0oz+603YFAd4K5CXyqxeqiVEVS1Ecjs7JFhcoWYcZgD5Gy4Z8p3bqXNA2G/NIEYBWWI6A4ZIvTQ22R+j9 X-Google-Smtp-Source: AGHT+IE78fskWr/eseCLwmT5IV5aqBptmc+jin8SVxI6FZYdxYP3JbYC3VKURTQGrVPBqUSmz0Tp X-Received: by 2002:a05:6512:4020:b0:52f:cdb0:11da with SMTP id 2adb3069b0e04-530ee995d7amr6259e87.33.1723165084178; Thu, 08 Aug 2024 17:58:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723165084; cv=none; d=google.com; s=arc-20160816; b=Dey4N7mZo4mc7bcT9RGbXGEanK3bfh3mQQx5aC5itTuRdpb6Sqq0SmoR18iigRJ836 tt83b9qbqGFzRbrCVnPpB2c/LX94EX0KWdUVbYdTE+3/M6450EAUIaE5wuDX8wlpGm1r scxX0NVMTkIaJvX9jmZAssS8FjSEt6tiBIxSpE62+cwWui3zoHVWt1pJgq7suQoKn1Bb IgE9r7COeX0D0VcY8TW/BIZW5D3ZzAcaVlw6KjQ9KGDhvVPacbs2ERtXY8o57W0sgl88 b6VlGRkQRZVJiru7M0+juTsAOGh7AZcszXLTzYsMj2KACbd8Ke1WvWdWUyMmiEcphMYy L5Sg== 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=wxoUmHtmvjgCaZOdGgs2Djd7/yb9seAZ6tkmYw6gA24=; b=HZK/VwkhsaZo9Qnw2sY8lrRt6B5CuVsJeHXQAxL7drn+s62HoF9qjp4uJb8dFhslwi 13o7h2Ee9VsvLwpGdD7yTwXEfIpDT7O0ROOrimWUkQ5/TvNRcCy0UTH7MV0CBnUQBZ7M cQD8EKOwwW9kM3ldKX4jd5ux6cv+Vc8Nc3Up3vc8AalNFIUnqpQhIPpVgDcV+hi/BR8q Fd6Dvg1IW/2s4w9e5x3vKogB4D9PX0zTXMAHg+JZqKdtKrVklNkEBMEitf22ymp5FROm sRHUxTxI1adMlHlsyNTZ395hfKhod8lE9oIWvkztJsM+3bxHrNMQor840Sggy8WTWmgb sRoA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H3WHusfD; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id a640c23a62f3a-a7dc9f2b210si890524066b.796.2024.08.08.17.58.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 17:58:04 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H3WHusfD; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 5668688C08; Fri, 9 Aug 2024 02:56:44 +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="H3WHusfD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1B75888B63; Fri, 9 Aug 2024 02:56:42 +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-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) (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 0C7C288C18 for ; Fri, 9 Aug 2024 02:56:40 +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-ej1-x630.google.com with SMTP id a640c23a62f3a-a7aa4bf4d1eso190646566b.0 for ; Thu, 08 Aug 2024 17:56:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723164999; x=1723769799; 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=H3WHusfDX15028GGsgZnuxoQM7xYuu+bEuHQ2+0Zo66ZQWWu9a+pg9nImJ7z2mAxNT nfWGd/Rl9avXgU2mp85DC78OoNaTyLuzSTzS4yJf17BBhd3mOXAQUHJ8lA93upiam+mY 30l2191NU8vCUG3UkVHzVzwQJUeLfyHQaHZLUSqTszF6x5Foq1ThqvgrRHtK9ivup3x1 HM0WohWp7e5Tuq/0chpXrTsHRU0CkYvKuWkaUlciHkzWWpjd5Ig62watcLsp1yUFw1hv 3kkTrtE+FQD3XG8Eu1jkNJ1GY1iuziqf6VxcqeL8dAfdEZQsi6rmxLEV2cn81xE/3SYo 2bmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723164999; x=1723769799; 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=KHXQ0d+k4ubvAMhJySywF1tzHyUdAul/ET6XASV3SUHh4+8eJc/2VXL3KUa/fKJLv/ QF+jUOs8dT5lF0f30ioPJsYYvO6Zvd67Ps6uTqJM0s7rNqubFcaoxPPqXDRkl+ABqUYk TEBFDCIqK+NdvtmKrVaPOaNaM70fy523+MyEtpE75Mtjk4vPCrVydev0+6CHizyLBUoe t1+//9gqdmRT70V4azAcmYLZY6B1durQyugV0a16W/nNf7becwBMEXz8iiRtYo64Zos+ AuwsopvMbLVcsY3PrIR3tfn8qUxiYR1bCqYX4DLTSVxdOBBCY5aFWoNPzNm6MJ6i9XKs pAjg== X-Forwarded-Encrypted: i=1; AJvYcCXbKjGRwiSU6r7w+9ou2roEWEPeB6/hyk8tsDr1vHpp/R0CM+oOyNpg2TTT2JyQvRulE5b+ZTEIl3GhusahkSsInvtVMw== X-Gm-Message-State: AOJu0YzJvkWurh1oY2jGActrfGKNAXQY/gonOrH7HLddpj4hmij4/d9d NIxL/hB2boMMxFdysV6LeuPMqbr7OMIBR1t0O5vPjr2da+17X0qZeaPSWk0jN7U= X-Received: by 2002:a17:906:bc0e:b0:a7d:9f92:9107 with SMTP id a640c23a62f3a-a80aa6d36abmr3166b.58.1723164999470; Thu, 08 Aug 2024 17:56:39 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::7424]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7dc9e80e54sm790680266b.167.2024.08.08.17.56.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 17:56:39 -0700 (PDT) From: Caleb Connolly Date: Fri, 09 Aug 2024 02:56:27 +0200 Subject: [PATCH v7 08/11] tools: mkeficapsule: use u-boot UUID library MIME-Version: 1.0 Message-Id: <20240809-b4-dynamic-uuid-v7-8-8c44ab1f06a5@linaro.org> References: <20240809-b4-dynamic-uuid-v7-0-8c44ab1f06a5@linaro.org> In-Reply-To: <20240809-b4-dynamic-uuid-v7-0-8c44ab1f06a5@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=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmtWk96o035BaXaW0jJNSImoU7k3Nc5SkndyUkW kB+0mdLfAOJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZrVpPQAKCRAFgzErGV9k tuGSD/9QcSgife5SaVe1WiMfRdKbPrfKRMWrVbFIMoiKL0giTZ93Xl6H+PmefK3UpMhLhhjAHD8 ikEjn2kotEGo4cNfsPLe0kE9K95FXVPM16ff1wM1DggNNZFr/BqhHKB7cs4E2gc4Yq1PGT0mye/ Uuhp8mqTLnnHvpldrAZCn8wXIW9a9e5CpMh0RIuQGNiW15VnEcp7wJ+Pv6A82JsQweFPPRPZdqu +Qwhg0imZSHJysW0/7dDG1t2FYtuoA4GEG5ZL+zJYOXHPdZLbHoaL4xmXPv6LFF2JJyIcVFz2Gm HcLtPdk+LJMf0WX39muH/9tcliyxUZBINSPhks7qIAtiLMh2k7ofjGuLMw7Id6ebEwACdHsKy2O IfM34NPJVlvKr/lK9EvsG6q/1tIVN5v73kq/nKs1JAZlCyXEnUZ6qEkQynRv+oxNeIjRQbgGO8Y LPt7xYTRfjhie6Nn1q+IU+K72JnxA3yQDsnnCAvK1M7uUwZTMLxPpf+VjNGNW/7kuL9VOU61GPW e7t4i/HyMVJt9Sh7wP6fZ+hjnR+mQW95cwaOO2lfc/QZPGMgceqEdCiaULGJg2lsaZKfJFMwf3S ygw+KJaOKw6XhpOlwTExKa08eKItE368Az7GtxL/vcnIqzWO7P/XHj+WrKQ6zJzAP4wlxvsyj7P qYBJaWE5X+vq0WA== 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);