From patchwork Thu Apr 15 13:30:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 421767 Delivered-To: patch@linaro.org Received: by 2002:a02:6a6f:0:0:0:0:0 with SMTP id m47csp469527jaf; Thu, 15 Apr 2021 06:24:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXXekT3VdLq2HVQ7grXF5hi7Y+KH4Y7nxE/iJrp7vZMA5i6jgvy0iYg/xjW+Wcc6iMwDDX X-Received: by 2002:a50:f19d:: with SMTP id x29mr4375153edl.102.1618493098758; Thu, 15 Apr 2021 06:24:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618493098; cv=none; d=google.com; s=arc-20160816; b=mfxQm2+RtxipQdNN+b6QOUJScOAhrrHRk6KomMsK7hS13FmzeZS1SN9PcfriXjnaJW 5gNeBk5xgzTMeKRkja/TTXkg8EUaHiPTMFg9JLxtIsIAzvstaUdkKDT1YK8nphRV4N9Y ymbd1Ggxanm/eNbv5IwQXkH6nh/hjVLdkZJA+5nk1UoaaFeQPNKaxa0Kw+/YkgbVhjTM PgncL/lMGSkWPW5/Z0XTT4ObNw7JDE4iIrWJTVRzKr9bLyfSyGa0tj/kfA1DJ7NRlbrd JtcFuLe9V2I3kGA/GAPpVf+Zdz4lA6spoy24FcGWRouLop57MH8Ot/UdU8850B9N2WwX KkDQ== 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:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Oakivl+hOZER5Ni1FOhqPbb0h3bVcMVthQvx8L/MypQ=; b=W3dYA/hoOfVF9QFFukoa6c11BXzWzXIsTbyRSN/j1zbZgiVbSONc0620ms0GiElrYC mQgrLGc5i+vMVRRk5SD/XzhuIWh7YxqNdIiIaazQZuITFzARXqH1a7La58dJO4oahqcJ FhUrVqg+rqkUZ+M/t3tw5ZbJgBIID7jHDVa4OQIZu8ZDEG9koOMcQhUhGs8IB71ImrDK BQS4+dST82Fk0jyGeLBG1f+iJOzjatBkTaZnvHj4mYGRt86jwMigSKSJJhXlWnExAZlY aCis7r53nAUuxsnvxEpT0Znw4pg5Wnstml5Ml5w9icSGQlmti10zgef8zS6bRaGyLvjr o83Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DBlzm81+; 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 x8si2220170edd.185.2021.04.15.06.24.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Apr 2021 06:24:58 -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=DBlzm81+; 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 938D782012; Thu, 15 Apr 2021 15:24:56 +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="DBlzm81+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AF00281FE8; Thu, 15 Apr 2021 15:24:46 +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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) (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 9E36B81FE0 for ; Thu, 15 Apr 2021 15:24:41 +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=masahisa.kojima@linaro.org Received: by mail-pj1-x1030.google.com with SMTP id x21-20020a17090a5315b029012c4a622e4aso12689299pjh.2 for ; Thu, 15 Apr 2021 06:24:41 -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; bh=Oakivl+hOZER5Ni1FOhqPbb0h3bVcMVthQvx8L/MypQ=; b=DBlzm81+vh7fsc02CKRgbnloWscGDzDWTAoKC9E7y/SovBOsnt/um/8mhY3wLp2TVa 2saWEBzXg9z4bCxAMPt2JycnVmXYHkijkLLmtASyguyekM4mptdM4d0XNuyrmDcfa45L ZfyEvs+jTxCdsSXwx3KX/fSHfMq+K1FksSxHz4Ls5+WCFvtfLCSE9IUWEeR8zRGx3UN8 p0ZiWCxDfBSbFRH6RpLGaMoiKKzps7hVaoc3raCS5i75A4uLdnhLFvp+x1wqUaqJ2FW6 akxhgvge+eXmWo8zhhcEtkaTKWvZX1o+qaklTwcCMFfB2Fyisb0vic2mTPHaPAiRHjin eN8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Oakivl+hOZER5Ni1FOhqPbb0h3bVcMVthQvx8L/MypQ=; b=Vc5SOjq+JWrP9JDCzrzKi7pK5n43ppcGk1zaConPjIMGpvuLYFZftGRwYZi6BF7Pnf qXEMwZAfsahN6GDboMxf3IEfE526z1LSDdSX9UhgMp015ikttWHFA9rK0pFazIBSQG3s TTECV+71p3s37HoBPu15UtwtklcHKRMpovKEd/pt0rjSdzcRu2YPDhD42RcqCj6g1UGX 6RF/P7+utiUwIAeDl8Jstcx3VJYarj1VQVmiESTXlohU2WkmagalmZ5Jw9l2CXhihDdT 0GCF64eF2fO+9sr4O72rjRMptS33Ola1gGOLf6VFXFE10YMIqroybd0QIXM3ToLZvLXl J1rQ== X-Gm-Message-State: AOAM531ubYKSVAWq11cvIuudz4DyXpnChpB0Sy8oB8zFLw3Mu4et5SGC rnTMiSDlNRueo4Fw21g6D1kneg== X-Received: by 2002:a17:90a:3b4c:: with SMTP id t12mr4147042pjf.142.1618493079977; Thu, 15 Apr 2021 06:24:39 -0700 (PDT) Received: from localhost.localdomain ([2400:2411:502:a100:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id m11sm2527461pjs.34.2021.04.15.06.24.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Apr 2021 06:24:39 -0700 (PDT) From: Masahisa Kojima To: Heinrich Schuchardt Cc: Alexander Graf , Simon Glass , Ilias Apalodimas , Masahisa Kojima , Dhananjay Phadke , Takahiro Akashi , u-boot@lists.denx.de Subject: [PATCH 1/2] efi_loader: expose efi_image_parse() even if UEFI Secure Boot is disabled Date: Thu, 15 Apr 2021 22:30:19 +0900 Message-Id: <20210415133020.29175-2-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210415133020.29175-1-masahisa.kojima@linaro.org> References: <20210415133020.29175-1-masahisa.kojima@linaro.org> 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.102.4 at phobos.denx.de X-Virus-Status: Clean This is preparation for PE/COFF measurement support. PE/COFF image hash calculation is same in both UEFI Secure Boot image verification and measurement in measured boot. This commit exposes the hash calculation functions even if UEFI Secure Boot is not enabled. Signed-off-by: Masahisa Kojima --- lib/efi_loader/efi_image_loader.c | 2 +- lib/efi_loader/efi_signature.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c index f53ef367ec..2c35cb5651 100644 --- a/lib/efi_loader/efi_image_loader.c +++ b/lib/efi_loader/efi_image_loader.c @@ -213,7 +213,6 @@ static void efi_set_code_and_data_type( } } -#ifdef CONFIG_EFI_SECURE_BOOT /** * cmp_pe_section() - compare virtual addresses of two PE image sections * @arg1: pointer to pointer to first section header @@ -422,6 +421,7 @@ err: return false; } +#ifdef CONFIG_EFI_SECURE_BOOT /** * efi_image_unsigned_authenticate() - authenticate unsigned image with * SHA256 hash diff --git a/lib/efi_loader/efi_signature.c b/lib/efi_loader/efi_signature.c index c7ec275414..1dd9d0e130 100644 --- a/lib/efi_loader/efi_signature.c +++ b/lib/efi_loader/efi_signature.c @@ -538,6 +538,7 @@ out: EFI_PRINT("%s: Exit, revoked: %d\n", __func__, revoked); return !revoked; } +#endif /** * efi_image_region_add() - add an entry of region @@ -601,6 +602,7 @@ efi_status_t efi_image_region_add(struct efi_image_regions *regs, return EFI_SUCCESS; } +#if defined(CONFIG_EFI_SECURE_BOOT) || defined(CONFIG_EFI_CAPSULE_AUTHENTICATE) /** * efi_sigstore_free - free signature store * @sigstore: Pointer to signature store structure