From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7F9AC433EF for ; Thu, 7 Oct 2021 06:25:27 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F18EE61260 for ; Thu, 7 Oct 2021 06:25:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org F18EE61260 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de 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) 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-Google-Smtp-Source: ABdhPJzqpr4w8Zddf7PlOvXDYViSxtP0wLECXhHqxqlnpjyn0Z/iZNYluKr8WNpZ5405yJgdkIXeVQ== 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 Content-Transfer-Encoding: 8bit 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(+) 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) -- 2.33.0