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 CE8EBC433EF for ; Fri, 15 Oct 2021 00:41:44 +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 4CF0E6108E for ; Fri, 15 Oct 2021 00:41:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4CF0E6108E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.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 A2BB0837DA; Fri, 15 Oct 2021 02:41:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="VqPe2zhl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9A9B6837C7; Fri, 15 Oct 2021 02:40:54 +0200 (CEST) Received: from mail-vk1-xa2b.google.com (mail-vk1-xa2b.google.com [IPv6:2607:f8b0:4864:20::a2b]) (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 E55E4837AE for ; Fri, 15 Oct 2021 02:40:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@google.com Received: by mail-vk1-xa2b.google.com with SMTP id z202so4369196vkd.1 for ; Thu, 14 Oct 2021 17:40:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3j8rRQQYB9Tjcc2G+u4pEvCNfeQwfxxx9ZQ3FEQfnE8=; b=VqPe2zhlx1iN7hrp2EE3nJyDP9cwNh68OeqMR1zYqVggyrZ0/OauS9kdIDSisvfhAQ /yXLYtOrLY7oX12uCBEBCWUq39X3nUGYXr3PfwN9WnDOj+FUzRvJbkcvZ7ZboyYt7lEA 4AH/8AJArZYMV0mY9IilD4mqpxNkJZFSNb+6o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3j8rRQQYB9Tjcc2G+u4pEvCNfeQwfxxx9ZQ3FEQfnE8=; b=Tl2WWrKU2YLN3ws3tTwRlcV3xAB+DwvaI9Jn/4QCaY7HwmMkylaR97PCA+D3l88yS3 O4WRyBl+R10YsB9FwhQPBvzXIGEFkwozGrR9rdfeB/r2RyrOIfR32gEgs7siEi/1ow0r XQDYUc3ZUekpYjJCj01yaBYsx2l0grgddtajtpIwJRWjzxmSUz5IrUOgV44E7LkP9C7+ yUArnTPOi3QXuzLxKmRTkWO1tSbmvIPrLxcRXfUcp26Y2sEi1SdUkshe9yroohbr31Ba 33ALZat2qomTBXLHsJyI1sbhEbOThJXCuHl/59TUkOoLmqJZxMmca/o3+3QpIdkk2R0f NmiA== X-Gm-Message-State: AOAM532pthDW5CYzBucrjeymBGBJ59MvloUoAl7d7fwHbQISizC9dZ7r QiWbiEKF8dYSahb754e5i/QurJ1h1wDC4PZpVEi30w== X-Google-Smtp-Source: ABdhPJyw+8SM3ki1qbJUefJvkurEXhCSX8UUWRQ+MoJ2PjZhazNNEVnmbKYfDaXY2Lyhn63y2KkJyOV+C7ybqGb7G3Q= X-Received: by 2002:a1f:c6:: with SMTP id 189mr10405833vka.16.1634258441327; Thu, 14 Oct 2021 17:40:41 -0700 (PDT) MIME-Version: 1.0 References: <20211007062340.72207-1-takahiro.akashi@linaro.org> <20211007062340.72207-4-takahiro.akashi@linaro.org> In-Reply-To: <20211007062340.72207-4-takahiro.akashi@linaro.org> From: Simon Glass Date: Thu, 14 Oct 2021 18:40:26 -0600 Message-ID: Subject: Re: [PATCH v4 03/11] efi_loader: capsule: add back efi_get_public_key_data() To: AKASHI Takahiro Cc: Heinrich Schuchardt , Alex Graf , Ilias Apalodimas , Sughosh Ganu , Masami Hiramatsu , U-Boot Mailing List Content-Type: text/plain; charset="UTF-8" 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 Hi Takahiro, On Thu, 7 Oct 2021 at 00:25, AKASHI Takahiro wrote: > > 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) I don't think this should be weak. What other way is there of handling this and why would it be platform-specific? > +{ > + 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 > Regards, Simon