From patchwork Thu Oct 7 06:23:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 515429 Delivered-To: patch@linaro.org Received: by 2002:ac0:b5cc:0:0:0:0:0 with SMTP id x12csp1004095ime; Wed, 6 Oct 2021 23:25:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxw1ErelwqghVUZVVhZTv82/qkjRkNAZBrLm/68AVV2S2/NGHvWuleM/p9CqSn3GEzbNNH4 X-Received: by 2002:a05:6402:40f:: with SMTP id q15mr3664143edv.333.1633587927379; Wed, 06 Oct 2021 23:25:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633587927; cv=none; d=google.com; s=arc-20160816; b=sG4pDM3dOQnJsmA98a+FCHdq5SOQyIn63EgPQUp3f+bHCnzYdnTxFaIBVG3sagiaH3 M/4W6FdCh4e0w6BB4IiAPaWTAI9GtKXiKeCCcG8jQ0wc3lmMR68RcpW7PYARUBCrsV3f t70A64cjVrdVYNjqzeljLctrlwjMtFb7Qj2+F3046mnmXb/7D8UAgEqVfyFrCaeCAcJy DNYcVBRRDStv+WHmqWkjfba5BRj/fYZ9FezlRRReloEZD2cY7HC0n2/LfidGbZYdUEd/ Q6GV+1ZEBOHJPpzT5pJkl1pbOSrDrGQeCDaKvFWc2HHYxvD2uh5XOj6rY44WXwBLPKrR BALw== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2FnSOKDVLTy0sxSHbwmzOhnc/48ayRC3P9f6t3F6nFY=; b=YONOHNJeLDJBcvo90g6ylylix0F3XTbPgEPBTu5uN5bIKG1xi8NKqed0T0Dh4gKgEZ INyYxmRN2yCCJtkueFGcqKZC3J10nBS2RK6yrOvysH/Mhl7ZU2L8NLJ8+J0uyDCmBrU7 eeXuzOrTPnENvZ5P96omPu0twec26X3xNLKwIKEZlKCfEupvRcXf81Qk8g9XKDNVDqLk Z8WvnxGzWtORM242Q5m+dtX+kgM7Bdyxhmq7jsNwT2VDlOh9zO7ZTFdryMZAtgCk37O3 d62MZ7DDMoAi29r5yRJhBJf58BmJxd7tyzCq3g7YTlQsyxVxP1rzVSCbcBMo1JVfy5I1 IZXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ysXBaGfj; 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 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 i14si27039452eje.121.2021.10.06.23.25.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Oct 2021 23:25:27 -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=ysXBaGfj; 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 Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5BE0B834A0; Thu, 7 Oct 2021 08:25:20 +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="ysXBaGfj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2B50083474; Thu, 7 Oct 2021 08:25:17 +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-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) (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 A71948347F for ; Thu, 7 Oct 2021 08:25:13 +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=takahiro.akashi@linaro.org Received: by mail-pj1-x102e.google.com with SMTP id on6so4011672pjb.5 for ; Wed, 06 Oct 2021 23:25:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2FnSOKDVLTy0sxSHbwmzOhnc/48ayRC3P9f6t3F6nFY=; b=ysXBaGfjdUky2A18FLYZv8D9XSlDUe2QNecwG26E191yH5bcLU2tXvir+zsU1mymB+ BkGY62/3y47NkO3QGK+3CUyz2ieIaLxFNGMiLnrAvqwFAJYVLoV6cwTvUfpeAtADyzIq 6TQZ11UC0rvR8wOQeIQFuptxfCVbQppFQx7IUAvuQS2DZcpBC1h/XvThx5JPn/yjDWws SZ3H6JVIip5lFiFsWNNYWhlnkXyvBvMUFU1/raDtOuOEADouG7BpFrTlR9rSEKPUqySG WaaG9XYnZSkeBRv9wAVu2UJE8NgAnR6FkP+ZCpRY1VaelIHtnajvSLNQCz8o+/JfDrdb /CbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2FnSOKDVLTy0sxSHbwmzOhnc/48ayRC3P9f6t3F6nFY=; b=3/PretDUCqHpIxcTAzy+XdXfH87p+rU7qCuC2/xOlUEp2AVaOPWiuuAgrqjBF+IoDH +4AY+C8TS6PyT4qLNWCdzm6ZR5VRM5gXJpv3K05ZBIJ1yklYip+A8amzpM2IbBhBbkY2 oJQl7JmY0DpJ/YWNwRs5Fx82rL2eyReLiUeNXeH5q/RMVxHvlNlJ9b84WfUkxcbX/5at tx6DTBnJtNcvzeNVmWT5erEqdJf3NwSqnhRAMSsy/k88bsoaPPtu2WNcO9PorLbzpxPU 1n4v4Phkn1p5bC/JIoRlXh+s2B2cfF2aaHSUSNrpN80yjkdFxge5VSyuSx2LSAlOI9p8 dgVA== X-Gm-Message-State: AOAM532Nn0QKuHBaqWZ/qsOLB0Bazru6KeOuM/myRzkhd+bu9CXLmZla d17mRXisl974+aND4iGHy/VPCg== X-Received: by 2002:a17:90a:8912:: with SMTP id u18mr2730013pjn.69.1633587912011; Wed, 06 Oct 2021 23:25:12 -0700 (PDT) Received: from localhost.localdomain (122-100-26-39m5.mineo.jp. [122.100.26.39]) by smtp.gmail.com with ESMTPSA id b17sm22131859pgl.61.2021.10.06.23.25.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Oct 2021 23:25:11 -0700 (PDT) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de Cc: ilias.apalodimas@linaro.org, sughosh.ganu@linaro.org, masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v4 03/11] efi_loader: capsule: add back efi_get_public_key_data() Date: Thu, 7 Oct 2021 15:23:32 +0900 Message-Id: <20211007062340.72207-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211007062340.72207-1-takahiro.akashi@linaro.org> References: <20211007062340.72207-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 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 The commit 47a25e81d35c ("Revert "efi_capsule: Move signature from DTB to .rodata"") failed to revert the removal of efi_get_public_key_data(). Add back this function and move it under lib/efi_loader so that other platforms can utilize it. It is now declared as a weak function so that it can be replaced with a platform-specific implementation. Fixes: 47a25e81d35c ("Revert "efi_capsule: Move signature from DTB to .rodata"") Signed-off-by: AKASHI Takahiro --- lib/efi_loader/efi_capsule.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) -- 2.33.0 Reviewed-by: Ilias Apalodimas diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c index b75e4bcba1a9..44f5da61a9be 100644 --- a/lib/efi_loader/efi_capsule.c +++ b/lib/efi_loader/efi_capsule.c @@ -11,15 +11,20 @@ #include #include #include +#include +#include #include #include #include #include +#include #include #include #include +DECLARE_GLOBAL_DATA_PTR; + const efi_guid_t efi_guid_capsule_report = EFI_CAPSULE_REPORT_GUID; static const efi_guid_t efi_guid_firmware_management_capsule_id = EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID; @@ -251,6 +256,37 @@ out: } #if defined(CONFIG_EFI_CAPSULE_AUTHENTICATE) +int __weak efi_get_public_key_data(void **pkey, efi_uintn_t *pkey_len) +{ + const void *fdt_blob = gd->fdt_blob; + const void *blob; + const char *cnode_name = "capsule-key"; + const char *snode_name = "signature"; + int sig_node; + int len; + + sig_node = fdt_subnode_offset(fdt_blob, 0, snode_name); + if (sig_node < 0) { + log_err("Unable to get signature node offset\n"); + + return -FDT_ERR_NOTFOUND; + } + + blob = fdt_getprop(fdt_blob, sig_node, cnode_name, &len); + + if (!blob || len < 0) { + log_err("Unable to get capsule-key value\n"); + *pkey = NULL; + *pkey_len = 0; + + return -FDT_ERR_NOTFOUND; + } + + *pkey = (void *)blob; + *pkey_len = len; + + return 0; +} efi_status_t efi_capsule_authenticate(const void *capsule, efi_uintn_t capsule_size, void **image, efi_uintn_t *image_size)