From patchwork Sun May 1 18:12:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teddy Reed X-Patchwork-Id: 617229 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3qyc4w5KhLz9sdn for ; Mon, 2 May 2016 04:52:47 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=fgigXVqC; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0F8FFA765B; Sun, 1 May 2016 20:52:44 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PWRTuPJciLwL; Sun, 1 May 2016 20:52:43 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2D291A7624; Sun, 1 May 2016 20:52:43 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AE076A7646 for ; Sun, 1 May 2016 20:13:22 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id s7DzUwpBtdHe for ; Sun, 1 May 2016 20:13:22 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-pf0-f195.google.com (mail-pf0-f195.google.com [209.85.192.195]) by theia.denx.de (Postfix) with ESMTPS id 0CB0AA7624 for ; Sun, 1 May 2016 20:13:18 +0200 (CEST) Received: by mail-pf0-f195.google.com with SMTP id 145so16708261pfz.1 for ; Sun, 01 May 2016 11:13:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3cMbUdRMWPVkPtzqSz/uBFK3S+mxVYnJ/xyXj62FG6Q=; b=fgigXVqCAV6P57Pk8aqb1B45SUFl9tM6M+AzsNsrBKWBSzl70utrmWOBGITgziDacd NJcxjvwLnyRPZkAlYOzz5PEvSg0Rs/maADQZ574Ihob7Cay6jRo8oSG/z4pBxX/mAGlv grTBJrsX5LxzaMuatmplQ8rS6KrlbD7kiy5FufzJqNeWdqZbl6pA/+q5NtecbzXiNy5t dJJc3M9/M5+FtRzqAAhVnp3JIDecfHnynsjJleucT7X4M3E9nBrVVJk/SDbyp25D4540 w4154w/EF+JI5x2Gcg4+LfZF6axXdEZj5HSM7LV5SZuqTevF2/a1NJNKQ0bzdF3kF0t4 7T0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3cMbUdRMWPVkPtzqSz/uBFK3S+mxVYnJ/xyXj62FG6Q=; b=BtP+ngToEhklyN0B4hjFVPA/kaiT59bG+l6lGYTa9uvu5THHDoxFTIdFGA/J+dju+C XczFpynoFN21PtoIXyWlTFQCKEX6Y/SYGOtkN58YDcyiTi5vv0xgJK0qeiOT+96zj5xn eNrfDyKRNRKkh30LdpMQDIICw60eDkCWPnchpBvhXZhDtShVqLSIUg9H3GHWYi5Ra6Cr zRX9KAW+wtvbXcieBYDgw5UFSGI4fcpbL+mYhdnUgPNb1NtM2gG4RDRc1EUV6TYqQ6oR RKoMDfn26Lkr77obnHPCgJuCWti9jqH3rzoNsY+g8nCDt21lSR/UiFY+vRGyK92EWtz7 1nSw== X-Gm-Message-State: AOPr4FWbcy2Q3Zq7wU6bAF9LFc0XCgf4qnYrsLc3BXiokNuwn1Zd2dviRkbVdBLnw4JzyA== X-Received: by 10.98.85.195 with SMTP id j186mr46251263pfb.50.1462126396839; Sun, 01 May 2016 11:13:16 -0700 (PDT) Received: from maverics (c-24-6-55-56.hsd1.ca.comcast.net. [24.6.55.56]) by smtp.gmail.com with ESMTPSA id a5sm39296609pat.19.2016.05.01.11.13.15 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 01 May 2016 11:13:16 -0700 (PDT) Date: Sun, 1 May 2016 11:12:37 -0700 From: Teddy Reed To: Simon Glass Message-Id: <20160501111237.f4c430519dd178c40500ced6@gmail.com> In-Reply-To: <1462124722-21545-1-git-send-email-sjg@chromium.org> References: <1462124722-21545-1-git-send-email-sjg@chromium.org> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 X-Mailman-Approved-At: Sun, 01 May 2016 20:52:41 +0200 Cc: U-Boot Mailing List , Przemyslaw Marczak , Stefan Roese , Tom Rini , Stephen Warren , Michal Simek , huang lin , Julius Werner , Karl Apsite , York Sun Subject: Re: [U-Boot] [PATCH] RFC: Secure boot to U-Boot proper from SPL X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 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" I've been using the following patch for my configurations, please excuse the top-posting. I think the only difference is enabling the uclass mod_exp driver to initialize without needing relocation. --- This allows a board to configure verified boot within the SPL using a FIT or FIT with external data. It also allows the SPL to perform signature verification without needing relocation. The board configuration will need to add the following feature defines: CONFIG_SPL_CRYPTO_SUPPORT CONFIG_SPL_HASH_SUPPORT CONFIG_SPL_SHA256 In this example, SHA256 is the selected hashing algorithm. And the following booleans: CONFIG_SPL=y CONFIG_SPL_DM=y CONFIG_SPL_LOAD_FIT=y CONFIG_SPL_FIT=y CONFIG_SPL_OF_CONTROL=y CONFIG_SPL_OF_LIBFDT=y CONFIG_SPL_FIT_SIGNATURE=y Signed-off-by: Teddy Reed --- Kconfig | 11 +++++++++++ common/Makefile | 1 + drivers/Makefile | 1 + drivers/crypto/rsa_mod_exp/mod_exp_sw.c | 1 + lib/Makefile | 9 +++++---- lib/rsa/Kconfig | 3 +++ lib/rsa/Makefile | 2 +- 7 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Kconfig b/Kconfig index f53759a..e73ad03 100644 --- a/Kconfig +++ b/Kconfig @@ -183,6 +183,11 @@ config FIT verified boot (secure boot using RSA). This option enables that feature. +config SPL_FIT + bool "Support Flattened Image Tree within SPL" + depends on FIT + depends on SPL + config FIT_VERBOSE bool "Display verbose messages on FIT boot" depends on FIT @@ -205,6 +210,12 @@ config FIT_SIGNATURE format support in this case, enable it using CONFIG_IMAGE_FORMAT_LEGACY. +config SPL_FIT_SIGNATURE + bool "Enable signature verification of FIT firmware within SPL" + depends on SPL_FIT + depends on SPL_DM + select SPL_RSA + config FIT_BEST_MATCH bool "Select the best match for the kernel device tree" depends on FIT diff --git a/common/Makefile b/common/Makefile index b23f312..271f633 100644 --- a/common/Makefile +++ b/common/Makefile @@ -91,6 +91,7 @@ obj-$(CONFIG_USB_KEYBOARD) += usb_kbd.o endif # !CONFIG_SPL_BUILD ifdef CONFIG_SPL_BUILD +obj-$(CONFIG_SPL_HASH_SUPPORT) += hash.o obj-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o obj-$(CONFIG_SPL_YMODEM_SUPPORT) += xyzModem.o obj-$(CONFIG_SPL_NET_SUPPORT) += miiphyutil.o diff --git a/drivers/Makefile b/drivers/Makefile index 6900097..456492f 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -10,6 +10,7 @@ obj-$(CONFIG_$(SPL_)RAM) += ram/ ifdef CONFIG_SPL_BUILD +obj-$(CONFIG_SPL_CRYPTO_SUPPORT) += crypto/ obj-$(CONFIG_SPL_I2C_SUPPORT) += i2c/ obj-$(CONFIG_SPL_GPIO_SUPPORT) += gpio/ obj-$(CONFIG_SPL_MMC_SUPPORT) += mmc/ diff --git a/drivers/crypto/rsa_mod_exp/mod_exp_sw.c b/drivers/crypto/rsa_mod_exp/mod_exp_sw.c index dc6c064..56d7e89 100644 --- a/drivers/crypto/rsa_mod_exp/mod_exp_sw.c +++ b/drivers/crypto/rsa_mod_exp/mod_exp_sw.c @@ -32,6 +32,7 @@ U_BOOT_DRIVER(mod_exp_sw) = { .name = "mod_exp_sw", .id = UCLASS_MOD_EXP, .ops = &mod_exp_ops_sw, + .flags = DM_FLAG_PRE_RELOC, }; U_BOOT_DEVICE(mod_exp_sw) = { diff --git a/lib/Makefile b/lib/Makefile index 02dfa29..5c83e32 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -9,7 +9,6 @@ ifndef CONFIG_SPL_BUILD obj-$(CONFIG_EFI) += efi/ obj-$(CONFIG_EFI_LOADER) += efi_loader/ -obj-$(CONFIG_RSA) += rsa/ obj-$(CONFIG_LZMA) += lzma/ obj-$(CONFIG_LZO) += lzo/ obj-$(CONFIG_ZLIB) += zlib/ @@ -25,8 +24,6 @@ obj-y += crc8.o obj-y += crc16.o obj-$(CONFIG_ERRNO_STR) += errno_str.o obj-$(CONFIG_FIT) += fdtdec_common.o -obj-$(CONFIG_$(SPL_)OF_CONTROL) += fdtdec_common.o -obj-$(CONFIG_$(SPL_)OF_CONTROL) += fdtdec.o obj-$(CONFIG_TEST_FDTDEC) += fdtdec_test.o obj-$(CONFIG_GZIP) += gunzip.o obj-$(CONFIG_GZIP_COMPRESSED) += gzip.o @@ -41,7 +38,6 @@ obj-y += qsort.o obj-y += rc4.o obj-$(CONFIG_SHA1) += sha1.o obj-$(CONFIG_SUPPORT_EMMC_RPMB) += sha256.o -obj-$(CONFIG_SHA256) += sha256.o obj-y += strmhz.o obj-$(CONFIG_TPM) += tpm.o obj-$(CONFIG_RBTREE) += rbtree.o @@ -49,6 +45,11 @@ obj-$(CONFIG_BITREVERSE) += bitrev.o obj-y += list_sort.o endif +obj-$(CONFIG_$(SPL_)OF_CONTROL) += fdtdec_common.o +obj-$(CONFIG_$(SPL_)OF_CONTROL) += fdtdec.o +obj-$(CONFIG_$(SPL_)RSA) += rsa/ +obj-$(CONFIG_$(SPL_)SHA256) += sha256.o + obj-$(CONFIG_$(SPL_)OF_LIBFDT) += libfdt/ ifdef CONFIG_SPL_OF_CONTROL obj-$(CONFIG_OF_LIBFDT) += libfdt/ diff --git a/lib/rsa/Kconfig b/lib/rsa/Kconfig index 86df0a0..ec80e43 100644 --- a/lib/rsa/Kconfig +++ b/lib/rsa/Kconfig @@ -13,6 +13,9 @@ config RSA option. The software based modular exponentiation is built into mkimage irrespective of this option. +config SPL_RSA + bool "Use RSA Library within SPL" + if RSA config RSA_SOFTWARE_EXP bool "Enable driver for RSA Modular Exponentiation in software" diff --git a/lib/rsa/Makefile b/lib/rsa/Makefile index 6867e50..4b2c1ba 100644 --- a/lib/rsa/Makefile +++ b/lib/rsa/Makefile @@ -7,5 +7,5 @@ # SPDX-License-Identifier: GPL-2.0+ # -obj-$(CONFIG_FIT_SIGNATURE) += rsa-verify.o rsa-checksum.o +obj-$(CONFIG_$(SPL_)FIT_SIGNATURE) += rsa-verify.o rsa-checksum.o obj-$(CONFIG_RSA_SOFTWARE_EXP) += rsa-mod-exp.o