From patchwork Wed Jan 23 19:29:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Matheus Lima X-Patchwork-Id: 1030123 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="FChfQWNM"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43lFkC0GSRz9s3l for ; Thu, 24 Jan 2019 06:30:26 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id B439DC21DB3; Wed, 23 Jan 2019 19:29:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 7BB6BC21E26; Wed, 23 Jan 2019 19:29:57 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E6785C21DCA; Wed, 23 Jan 2019 19:29:51 +0000 (UTC) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00048.outbound.protection.outlook.com [40.107.0.48]) by lists.denx.de (Postfix) with ESMTPS id CC9DCC21DFF for ; Wed, 23 Jan 2019 19:29:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oXhKXqrnE8q7V2M5dW7T2FiIXBR8mxjVj7VxCB8WTGQ=; b=FChfQWNMFL+ySj9kHfCrcajiIbwaTbePeXK9An+czZbMOIF2QSROyGFyE89KdF6rXCJXAmV1pssQLpzvAh/RFIrfwohsq4qebS0Z3N56gYceiJAYdl5jEggs4ifuTlkcQ6yRfzLZ2WOFOkHDea2Fa7MFLC9Dtmp0kSbTmbRkbJo= Received: from DB7PR04MB4636.eurprd04.prod.outlook.com (52.135.138.158) by DB7PR04MB5307.eurprd04.prod.outlook.com (20.176.236.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1558.17; Wed, 23 Jan 2019 19:29:46 +0000 Received: from DB7PR04MB4636.eurprd04.prod.outlook.com ([fe80::ad79:c2:afcd:9b85]) by DB7PR04MB4636.eurprd04.prod.outlook.com ([fe80::ad79:c2:afcd:9b85%3]) with mapi id 15.20.1537.031; Wed, 23 Jan 2019 19:29:46 +0000 From: Breno Matheus Lima To: "fabio.estevam@gmail.com" , "sbabic@denx.de" Thread-Topic: [PATCH 1/6] doc: imx: habv4: Remove extra hab directory for a cleaner documentation structure Thread-Index: AQHUs1H/UA9/J0GatUG5dv/43j9t/A== Date: Wed, 23 Jan 2019 19:29:46 +0000 Message-ID: <1548271740-177-2-git-send-email-breno.lima@nxp.com> References: <1548271740-177-1-git-send-email-breno.lima@nxp.com> In-Reply-To: <1548271740-177-1-git-send-email-breno.lima@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [64.157.242.222] x-clientproxiedby: SN6PR04CA0037.namprd04.prod.outlook.com (2603:10b6:805:2a::14) To DB7PR04MB4636.eurprd04.prod.outlook.com (2603:10a6:5:36::30) authentication-results: spf=none (sender IP is ) smtp.mailfrom=breno.lima@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.7.4 x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB7PR04MB5307; 6:Ovcx3F4QQMhaE4NvKGGS6e3R81NARo1ZOjJftK55MYGTLn8Off++/F3hccfJecqAQdbzwOmK674Rt2/vqv/GPhIZq57PRkK9pH7lNIq7TIFJ20nIndmwGaHCRND3nmTlEtOSXS9K9W6Mep+4aAR5vPa3//M7YGtI9Nxi4hF+87/L3YdhASGcuhaloBbmTEoGukHz9Gn8soffJ3BMIvADdTjQUpDqTgLO1mCsjBgbQmntOn1WpVGlRqXHs+gHeQRqQ0wCcuIh/ZewoD6v5PipP1tFYfdWcl2ucq2Ant4zmof8ras3ZALSDp7wmk/ngQaXSWxDHIBZiPWx3rC/opPL8josUNAVnZcNc/BCwXnlN0/W+lfW0+zdqGpCXIB8ROQKn+uN1bd1gv/292EG9D27rcwx4avEhCKqTli80HyXyicbFVsfpDTyAiTdK2U8YqrpksR/J81MiK4pH63dSxCjGQ==; 5:P3lqJXNEcJupAdQIHMLKdtdPUbxtxcI/TLP7aAiQNiwaQdjE8mfAFKeqafVruEnqCtjmJOR3rtG5ErMuIkuUiPeiFuIPZ5TKmSsbEBGdko5mM69OoeACDAHoTQNW3ULdptJ5PLsOiqJ17NmKKtUq0hYV+EjELCsTjawM7l1QFYs3kmgxDy1AnrQt0aLJhXNI70RZkBdWGqv4v/R4B9P5YA==; 7:Ih2lFtWxVqZ1t0GRtB3qrXHOIL/Vf6LqPmgW4r9xDbgHLAwQ1/qTZ25Aw6HNqfKmxOTti4k/X9iXbkZOuC2QJ3waml7RXlI9VT9XqhuPrHmj0h0JR3bjZk949KvhK+Nxtza3MFE3DIMzFSIRQR90lA== x-ms-office365-filtering-correlation-id: 744c9ec6-c562-4319-51ed-08d6816921ec x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600110)(711020)(4605077)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:DB7PR04MB5307; x-ms-traffictypediagnostic: DB7PR04MB5307: x-microsoft-antispam-prvs: x-forefront-prvs: 0926B0E013 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(39860400002)(346002)(396003)(376002)(136003)(189003)(199004)(6486002)(81166006)(6436002)(39060400002)(71190400001)(8936002)(71200400001)(2906002)(4326008)(446003)(81156014)(8676002)(53936002)(478600001)(476003)(2616005)(11346002)(256004)(4744005)(66066001)(486006)(6512007)(36756003)(186003)(7736002)(76176011)(316002)(97736004)(54906003)(110136005)(102836004)(105586002)(86362001)(2501003)(305945005)(3846002)(6116002)(52116002)(26005)(68736007)(99286004)(50226002)(6506007)(14454004)(386003)(25786009)(106356001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR04MB5307; H:DB7PR04MB4636.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: H10tGmXJ0ZVsCRhe3KuJVFANqH13nK/yyC2gmZ8UTNA/czYjsGvo9RM8CitmOQGRDia6STEHaGW4HkKl/++Hf9YrUyn22AM0p8XWCMOeGqUE7xeaQ0Mf+YEhjyA7Puf9ksx5lIVfrNNBgxfpjdWxssmKD+lQLlD0buxQqshXXi4H/p7r21q2fVO+rzWnU0CQmWRqVA1T/eYFDUl3i7f4UHyerk+EAQ0RbPIYAC+YxkaFeIzqOdVZK6m1w6JPQXxbSxbKkZHilMY9F9fspW1S0Ghculs+4jLvHV1TY3vp2MccNviIuHS5A3dANbHY5qbW43Pk3jn+pdnqZQb49vQEHmIxPFfKiYEdLQJKAH4UtQ9JdvrQvKSpvs3M0Jq7sCyB/ybR2Tw0GBetYm8I9lHPDIgTCbhLGXEe72s0oolsiYM= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 744c9ec6-c562-4319-51ed-08d6816921ec X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Jan 2019 19:29:40.5399 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB5307 Cc: Breno Matheus Lima , "u-boot@lists.denx.de" Subject: [U-Boot] [PATCH 1/6] doc: imx: habv4: Remove extra hab directory for a cleaner documentation structure X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" There is no need to have an extra hab directory under doc/imx/. Habv4 and AHAB documentation can be added directly in doc/imx/ for a cleaner documentation structure. Signed-off-by: Breno Lima --- doc/imx/{hab => }/habv4/encrypted_boot.txt | 0 doc/imx/{hab => }/habv4/secure_boot.txt | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename doc/imx/{hab => }/habv4/encrypted_boot.txt (100%) rename doc/imx/{hab => }/habv4/secure_boot.txt (100%) diff --git a/doc/imx/hab/habv4/encrypted_boot.txt b/doc/imx/habv4/encrypted_boot.txt similarity index 100% rename from doc/imx/hab/habv4/encrypted_boot.txt rename to doc/imx/habv4/encrypted_boot.txt diff --git a/doc/imx/hab/habv4/secure_boot.txt b/doc/imx/habv4/secure_boot.txt similarity index 100% rename from doc/imx/hab/habv4/secure_boot.txt rename to doc/imx/habv4/secure_boot.txt From patchwork Wed Jan 23 19:29:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Matheus Lima X-Patchwork-Id: 1030128 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="ZankHBmQ"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43lFlC5rYgz9s3l for ; Thu, 24 Jan 2019 06:31:19 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 58AF0C21DFF; Wed, 23 Jan 2019 19:30:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 9828CC21E15; Wed, 23 Jan 2019 19:30:14 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C06C0C21DF9; Wed, 23 Jan 2019 19:29:58 +0000 (UTC) Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10062.outbound.protection.outlook.com [40.107.1.62]) by lists.denx.de (Postfix) with ESMTPS id F3167C21DAF for ; Wed, 23 Jan 2019 19:29:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ewa5Dng0rDpqwXzThJjvUT0Pb12Eje/dA1kD+oT9Cr8=; b=ZankHBmQMjMAE9OVR2vQa73RzazXoWrZVyNuI8KjWYAS10dGpbcrtllAzzWtIMyEcRr4bLA+BKOrU6rh8b1nLotITlxcbGekg9KzRiYKMtvm7doP4aVM+lIRZZSRaF0c7GUHo/FILv1XWlWY6pEO+Wz2gQNLxNDgh9vlnr1aieU= Received: from DB7PR04MB4636.eurprd04.prod.outlook.com (52.135.138.158) by DB7PR04MB5307.eurprd04.prod.outlook.com (20.176.236.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1558.17; Wed, 23 Jan 2019 19:29:53 +0000 Received: from DB7PR04MB4636.eurprd04.prod.outlook.com ([fe80::ad79:c2:afcd:9b85]) by DB7PR04MB4636.eurprd04.prod.outlook.com ([fe80::ad79:c2:afcd:9b85%3]) with mapi id 15.20.1537.031; Wed, 23 Jan 2019 19:29:53 +0000 From: Breno Matheus Lima To: "fabio.estevam@gmail.com" , "sbabic@denx.de" Thread-Topic: [PATCH 2/6] doc: imx: habv4: Add HABv4 introduction Thread-Index: AQHUs1IDiFrpptVYQk6ZWiyJFi3w6w== Date: Wed, 23 Jan 2019 19:29:53 +0000 Message-ID: <1548271740-177-3-git-send-email-breno.lima@nxp.com> References: <1548271740-177-1-git-send-email-breno.lima@nxp.com> In-Reply-To: <1548271740-177-1-git-send-email-breno.lima@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [64.157.242.222] x-clientproxiedby: SN6PR04CA0037.namprd04.prod.outlook.com (2603:10b6:805:2a::14) To DB7PR04MB4636.eurprd04.prod.outlook.com (2603:10a6:5:36::30) authentication-results: spf=none (sender IP is ) smtp.mailfrom=breno.lima@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.7.4 x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB7PR04MB5307; 6:6CMmlVHCLABeIL5AstWQJtqrEPiO09v1qyvMYU8LqvYLjtVlXSHd8e6QNtp8hTXGmzDCXuzbIh+H2eOQ6T19o1BeKRpAIpjmfDYRP66bdUcTR8Rsz3xJl2xSnEjDpPa/zwPpQYRy6OnZTqHw15tQ/rHdy5wfV7cQDuptl495IMC4fdLAgOeEkP2YovKtBnBlphfzb2JSEejo5QbHrzkyQkLIXtSZrWo5zPRE5/FJiKEn3YN5F43RBWqaXMbTQfCvcGkeJ8bdfRhMoEABp7Gau4Wjm3UfPsTxo4sC/L7H4fvijSYl7z0SP6wOZQ67yMPpJOLgGFIJh3YNhexbKtKZxHKMlBEz0uYe6DUw2DzbmdEP4sGfoxANYHKcVaGI3c9APlacoHlPbpF/zeY06lzMX2DDSITY3l61YkLHP3S3jQcK7fzGUZ0yxYdAZuKSC5RxAArmelsuXrZ8KyT5nCGtDA==; 5:yN9lYU5rHMKN/GGmsZ5dh2bSzS6+tC5GqTLtFAh4AojShHS5UoMh0oO4Ivgu2A5fKvLKtDyFJYgW8klWyF21g2UrnSH2MDjXpme4zomSS35/fMp/glp6WtQ6mpFlo3rDyCjcVR4sm3kXiQlvIqezudW7CmwjXP/2xy+M0gd7fc6kbAvCEnW6z5VTFNgyZtPm6CnVWJsxNP36nKAlNlJf1g==; 7:d4AZpC7GMWltZmbAVCiL3GILrAusMzVS7qnfUytNouIBcu6p6qcDjIR5Qlv7YmAPjmx/S5KHhpk7qDInN0zy/97AYkUnp/EQ19XmQujhlOCC7ORwRDhgHDLjObG620mmpE6rhxKL+5XgIKJLX/iM6g== x-ms-office365-filtering-correlation-id: 86b93660-b947-46f5-0742-08d681692610 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600110)(711020)(4605077)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:DB7PR04MB5307; x-ms-traffictypediagnostic: DB7PR04MB5307: x-microsoft-antispam-prvs: x-forefront-prvs: 0926B0E013 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(39860400002)(346002)(396003)(376002)(136003)(189003)(199004)(6486002)(81166006)(6436002)(39060400002)(71190400001)(8936002)(71200400001)(2906002)(4326008)(446003)(30864003)(81156014)(8676002)(53936002)(478600001)(476003)(2616005)(11346002)(14444005)(256004)(66066001)(486006)(6512007)(36756003)(186003)(7736002)(66574012)(76176011)(316002)(97736004)(54906003)(110136005)(102836004)(105586002)(86362001)(2501003)(305945005)(3846002)(6116002)(52116002)(26005)(68736007)(99286004)(50226002)(6506007)(14454004)(386003)(25786009)(106356001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR04MB5307; H:DB7PR04MB4636.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: CJLMZ/PUgWZARUunX8f9Gf9EylLn9SHgwrteltdAwIhLWkuEVzi/MezQYn7AiVeyHnIhTxJ5WWbobneq29a7Lo+UD5KvsmBNHV/Hk8gjZKlYAJIlXaI7W6bqbmbcbmwqeEGBHlDdjw/L93qhHmmK+ueu0hUlnX9tj/dmz7npqFYV8B4zGquUn7Gs4xQBnRT0oyXUwGEcNDAy1Mle90QUeKHGfjALOhytZ/URMZdAo/zF0rR/P/Quoo9wITwpQNeV1QTTuBjfCzd/4M6hDJIX6xlkyqS9cSilLG1hlkx1dvbfXDK2R3s4JemNd0DnSQran2io0wFZgMDHu7ZigezAMOwEvGGNGAJaujYBokRDzQrw3F25Kgu1zs6IRz+VLAevaphxSME8mwhc1Gg0+nzdHezHjjW0P9NYk/hTRaSlhzc= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 86b93660-b947-46f5-0742-08d681692610 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Jan 2019 19:29:47.6970 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB5307 Cc: Breno Matheus Lima , "u-boot@lists.denx.de" Subject: [U-Boot] [PATCH 2/6] doc: imx: habv4: Add HABv4 introduction X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" The HABv4 is supported in i.MX50, i.MX53, i.MX6, i.MX7, series and i.MX 8M, i.MX8MM devices. Add an introductory document containing the following topics: - HABv4 Introduction - HABv4 Secure Boot - HABv4 Encrypted Boot - HAB PKI tree generation - HAB Fast Authentication PKI tree generation - SRK Table and SRK Hash generation Reviewed-by: Ye Li Reviewed-by: Utkarsh Gupta Signed-off-by: Breno Lima --- doc/imx/habv4/introduction_habv4.txt | 262 +++++++++++++++++++++++++++ 1 file changed, 262 insertions(+) create mode 100644 doc/imx/habv4/introduction_habv4.txt diff --git a/doc/imx/habv4/introduction_habv4.txt b/doc/imx/habv4/introduction_habv4.txt new file mode 100644 index 0000000000..25711bbe95 --- /dev/null +++ b/doc/imx/habv4/introduction_habv4.txt @@ -0,0 +1,262 @@ + +=======================================================+ + + i.MX Secure and Encrypted Boot using HABv4 + + +=======================================================+ + +1. Introduction +---------------- + +The i.MX family of applications processors provides the High Assurance Boot +(HAB) feature in the on-chip ROM. The ROM is responsible for loading the +initial program image (U-Boot) from the boot media and HAB enables the ROM +to authenticate and/or decrypt the program image by using cryptography +operations. + +This feature is supported in i.MX 50, i.MX 53, i.MX 6, i.MX 7 series and + i.MX 8M, i.MX 8MM devices. + +Step-by-step guides are available under doc/imx/habv4/guides/ directory, +users familiar with HAB and CST PKI tree generation should refer to these +documents instead. + +1.1 The HABv4 Secure Boot Architecture +--------------------------------------- + +The HABv4 secure boot feature uses digital signatures to prevent unauthorized +software execution during the device boot sequence. In case a malware takes +control of the boot sequence, sensitive data, services and network can be +impacted. + +The HAB authentication is based on public key cryptography using the RSA +algorithm in which image data is signed offline using a series of private +keys. The resulting signed image data is then verified on the i.MX processor +using the corresponding public keys. The public keys are included in the CSF +binary and the SRK Hash is programmed in the SoC fuses for establishing the +root of trust. + +The diagram below illustrate the secure boot process overview: + + Host PC + CST i.MX + HAB + +----------+ +----------+ + ---> | U-Boot | | Compare | + | +----------+ +----------+ + | | ^ ^ + | v Reference / \ Generated + | +----------+ Hash / \ Hash + | | Hash | Private / \ + | +----------+ Key / \ + | | | +----------+ +----------+ + | v | | Verify | | Hash | + | +----------+ | +----------+ +----------+ + | | Sign | <--- SRK ^ ^ + | +----------+ HASH \ / + | | | CSF \ / U-Boot + | v v \ / + | +----------+ +----------+ +----------+ + | | U-Boot | | | | U-Boot | + ---> | + | -----> | i.MX | -----> | + | + | CSF | | | | CSF | + +----------+ +----------+ +----------+ + +The U-Boot image to be programmed into the boot media needs to be properly +constructed i.e. it must contain a proper Command Sequence File (CSF). + +The CSF is a binary data structure interpreted by the HAB to guide +authentication process, this is generated by the Code Signing Tool[1]. +The CSF structure contains the commands, SRK table, signatures and +certificates. + +Details about the Secure Boot and Code Signing Tool (CST) can be found in +the application note AN4581[2] and in the secure boot guides. + +1.2 The HABv4 Encrypted Boot Architecture +------------------------------------------ + +The HAB Encrypted Boot feature available in CAAM supported devices adds an +extra security operation to the bootloading sequence. It uses cryptographic +techniques (AES-CCM) to obscure the U-Boot data, so it cannot be seen or used +by unauthorized users. This mechanism protects the U-Boot code residing on +flash or external memory and also ensures that the final image is unique +per device. + +The process can be divided into two protection mechanisms. The first mechanism +is the bootloader code encryption which provides data confidentiality and the +second mechanism is the digital signature, which authenticates the encrypted +image. + +Keep in mind that the encrypted boot makes use of both mechanisms whatever the +order is (sign and then encrypt, or encrypt and then sign), both operations +can be applied on the same region with exception of the U-Boot Header (IVT, +boot data and DCD) which can only be signed, not encrypted. + +The diagram below illustrate the encrypted boot process overview: + + Host PC + CST i.MX + HAB + +------------+ +--------------+ + | U-Boot | | U-Boot | + +------------+ +--------------+ + | ^ + | | + v DEK +--------------+ + +------------+ | ----> | Decrypt | + | Encrypt | <--- | +--------------+ + +------------+ DEK | ^ + | | | + | Private | | + v Key +------+ +--------------+ + +------------+ | | CAAM | | Authenticate | + | Sign | <--- +------+ +--------------+ + +------------+ DEK ^ ^ + | + OTPMK DEK \ / U-Boot + | | Blob \ / + CSF + v v \ / + +------------+ +----------+ +------------+ + | Enc U-Boot | | | | Enc U-Boot | + | + CSF | ----> | i.MX | -------> | + CSF | + | + DEK Blob | | | | + DEK Blob | + +------------+ +----------+ +------------+ + ^ | + | | + --------------------- + DEK Blob + (CAAM) + +The Code Signing Tool automatically generates a random AES Data Encryption Key +(DEK) when encrypting an image. This key is used in both encrypt and decrypt +operations and should be present in the final image structure encapsulated +by a CAAM blob. + +The OTP Master Key (OTPMK) is used to encrypt and wrap the DEK in a blob +structure. The OTPMK is unique per device and can be accessed by CAAM only. +To further add to the security of the DEK, the blob is decapsulated and +decrypted inside a secure memory partition that can only be accessed by CAAM. + +During the design of encrypted boot using DEK blob, it is necessary to inhibit +any modification or replacement of DEK blob with a counterfeit one allowing +execution of malicious code. The PRIBLOB setting in CAAM allows secure boot +software to have its own private blobs that cannot be decapsulated or +encapsulated by any other user code, including any software running in trusted +mode. + +Details about DEK Blob generation and PRIBLOB setting can be found in the +encrypted boot guide and application note AN12056[3] . + +2. Generating a PKI tree +------------------------- + +The first step is to generate the private keys and public keys certificates. +The HAB architecture is based in a Public Key Infrastructure (PKI) tree. + +The Code Signing Tools package contains an OpenSSL based key generation script +under keys/ directory. The hab4_pki_tree.sh script is able to generate a PKI +tree containing up to 4 Super Root Keys (SRK) as well as their subordinated +IMG and CSF keys. + +A new PKI tree can be generated by following the example below: + +- Generating 2048-bit PKI tree on CST v3.1.0: + + $ ./hab4_pki_tree.sh + ... + Do you want to use an existing CA key (y/n)?: n + Do you want to use Elliptic Curve Cryptography (y/n)?: n + Enter key length in bits for PKI tree: 2048 + Enter PKI tree duration (years): 5 + How many Super Root Keys should be generated? 4 + Do you want the SRK certificates to have the CA flag set? (y/n)?: y + +The diagram below illustrate the PKI tree: + + +---------+ + | CA | + +---------+ + | + | + --------------------------------------------------- + | | | | + | | | | + v v v v + +--------+ +--------+ +--------+ +--------+ + | SRK1 | | SRK2 | | SRK3 | | SRK4 | + +--------+ +--------+ +--------+ +--------+ + / \ / \ / \ / \ + v v v v v v v v + +----+ +----+ +----+ +----+ +----+ +----+ +----+ +----+ + |CSF1| |IMG1| |CSF2| |IMG2| |CSF3| |IMG3| |CSF4| |IMG4| + +----+ +----+ +----+ +----+ +----+ +----+ +----+ +----+ + +After running the script users can check the private keys under keys/ directory +and their respective X.509v3 public key certificates under crts/ directory. +Those files will be used during the signing and authentication process. + +2.1 Generating a fast authentication PKI tree +---------------------------------------------- + +Starting in HAB v4.1.2 users can use a single SRK key to authenticate the both +CSF and IMG contents. This reduces the number of key pair authentications that +must occur during the ROM/HAB boot stage, thus providing a faster boot process. + +The script hab4_pki_tree.sh is also able to generate a Public Key Infrastructure +(PKI) tree which only contains SRK Keys, users should not set the CA flag when +generating the SRK certificates. + +- Generating 2048-bit fast authentication PKI tree on CST v3.1.0: + + $ ./hab4_pki_tree.sh + ... + Do you want to use an existing CA key (y/n)?: n + Do you want to use Elliptic Curve Cryptography (y/n)?: n + Enter key length in bits for PKI tree: 2048 + Enter PKI tree duration (years): 5 + How many Super Root Keys should be generated? 4 + Do you want the SRK certificates to have the CA flag set? (y/n)?: n + +The diagram below illustrate the PKI tree generated: + + +---------+ + | CA | + +---------+ + | + | + --------------------------------------------------- + | | | | + | | | | + v v v v + +--------+ +--------+ +--------+ +--------+ + | SRK1 | | SRK2 | | SRK3 | | SRK4 | + +--------+ +--------+ +--------+ +--------+ + +2.2 Generating a SRK Table and SRK Hash +---------------------------------------- + +The next step is to generated the SRK Table and its respective SRK Table Hash +from the SRK public key certificates created in one of the steps above. + +In the HAB architecture, the SRK Table is included in the CSF binary and the +SRK Hash is programmed in the SoC SRK_HASH[255:0] fuses. + +On the target device during the authentication process the HAB code verify the +SRK Table against the SoC SRK_HASH fuses, in case the verification success the +root of trust is established and the HAB code can progress with the image +authentication. + +The srktool can be used for generating the SRK Table and its respective SRK +Table Hash. + +- Generating SRK Table and SRK Hash in Linux 64-bit machines: + + $ ../linux64/bin/srktool -h 4 -t SRK_1_2_3_4_table.bin -e \ + SRK_1_2_3_4_fuse.bin -d sha256 -c \ + SRK1_sha256_2048_65537_v3_ca_crt.pem,\ + SRK2_sha256_2048_65537_v3_ca_crt.pem,\ + SRK3_sha256_2048_65537_v3_ca_crt.pem,\ + SRK4_sha256_2048_65537_v3_ca_crt.pem + +The SRK_1_2_3_4_table.bin and SRK_1_2_3_4_fuse.bin files can be used in further +steps as explained in HAB guides available under doc/imx/habv4/guides/ +directory. + +References: +[1] CST: i.MX High Assurance Boot Reference Code Signing Tool. +[2] AN4581: "Secure Boot on i.MX 50, i.MX 53, i.MX 6 and i.MX 7 Series using + HABv4" - Rev 2. +[3] AN12056: "Encrypted Boot on HABv4 and CAAM Enabled Devices" - Rev. 1 From patchwork Wed Jan 23 19:29:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Matheus Lima X-Patchwork-Id: 1030125 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="koEEmTUW"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43lFkY5PcNz9sCh for ; Thu, 24 Jan 2019 06:30:45 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 7EE26C21C3F; Wed, 23 Jan 2019 19:30:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 3369FC21DDC; Wed, 23 Jan 2019 19:30:14 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 450D4C21DFF; Wed, 23 Jan 2019 19:30:04 +0000 (UTC) Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40087.outbound.protection.outlook.com [40.107.4.87]) by lists.denx.de (Postfix) with ESMTPS id BA5D3C21E0B for ; Wed, 23 Jan 2019 19:30:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TaBrjWIlHos6y7NBughUb9YLVAN7/aKfY6gGkz78rEY=; b=koEEmTUWE434sNCthKImt1v6JXLGdwZ9ZZTkwti2UapHz92JEcDRO99VVSkP7lPTLrvV/N8tfZJl+1Km7jC/j6LdLPuxoNAEafBgqDgx55KS7s0NDowan321HTgMVFUFgrepvl3xjrqJT2ec+E2s1tNWCT0vEooWBh16AAk/KYQ= Received: from DB7PR04MB4636.eurprd04.prod.outlook.com (52.135.138.158) by DB7PR04MB5225.eurprd04.prod.outlook.com (20.176.236.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1558.17; Wed, 23 Jan 2019 19:29:59 +0000 Received: from DB7PR04MB4636.eurprd04.prod.outlook.com ([fe80::ad79:c2:afcd:9b85]) by DB7PR04MB4636.eurprd04.prod.outlook.com ([fe80::ad79:c2:afcd:9b85%3]) with mapi id 15.20.1537.031; Wed, 23 Jan 2019 19:29:59 +0000 From: Breno Matheus Lima To: "fabio.estevam@gmail.com" , "sbabic@denx.de" Thread-Topic: [PATCH 3/6] doc: imx: habv4: Add Secure Boot guide for i.MX6 and i.MX7 non-SPL targets Thread-Index: AQHUs1IHpmYUo+sdhU2a5VTjeWl90A== Date: Wed, 23 Jan 2019 19:29:59 +0000 Message-ID: <1548271740-177-4-git-send-email-breno.lima@nxp.com> References: <1548271740-177-1-git-send-email-breno.lima@nxp.com> In-Reply-To: <1548271740-177-1-git-send-email-breno.lima@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [64.157.242.222] x-clientproxiedby: SN6PR04CA0037.namprd04.prod.outlook.com (2603:10b6:805:2a::14) To DB7PR04MB4636.eurprd04.prod.outlook.com (2603:10a6:5:36::30) authentication-results: spf=none (sender IP is ) smtp.mailfrom=breno.lima@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.7.4 x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB7PR04MB5225; 6:TMGND8iRraERg984+s6RUrQqLwNqY0Zg8ILYseYbC0go0imqL/E05Nzt83UYE8czitV+td2X58y2RGQd+2ET/xpmzgIBbdHk0fQGjKc2S5Y3g9BsNQYvL5SB0jBWKrQqIi5/qOHd0XXZ7hoTQykQbX90dg0zcjyV3qUiWeB7S0BeYDsiURenYwsRo7HsheKJQyvKRpd2mEOn1EF1bEFzHDMHOxsVNR6aG8eqXLub+6kswAWKhZ117/mdSCbfRN2AQ88/vvSWV/Bc6qFlyP1L+ckVNTG24gHHthfS38cxwkSAoGm7TWTMJQ5NOmWXlnMJHVs/FxJTilo4FYMS7JwP1Bx5WlEQjJZi5zmKh2YJ2ydfjFZc1UItGoFoNI+O9WCzEpuNipCsUFQIfzdLlb73m2khEMjicuktGDqSbh/WvKRlbY1JloFgnOw5sVYU32Zf2itfHfraC3Iub9Gz5JdZ4w==; 5:a/dWqDGEI1nUsuYwUZGSLJbJ73FbgXGviqeCjtRnkiaMgAZ8kR+Li+oOT0jJ6QoL5rN9yeD+jbVrWwSTIZA128I4oBGLg4w1nibTg+FbHFW9H8OaEX8SgmQR65t7UQ4l/sJDRWDgXPH8d2aWCxdkXzFIgsNfQ8U4QfgN2nzjR+Z2Hm4oDtrvvfnauh4ogyRtCOdJhMGrGiqHxtV8fuGVew==; 7:RGu0qQBRTQaj/W7FFb+miMDdfC2UpT5DBr7phZ4rvXsc2rJ3T7Np5s5QrLkedZUP2+xNtyxSXXg+3yipAekPWmbgABInZjpssVWxwBPoz7SwSlRejPNv9nlSmOppMfuY4/p3B5/WrJpGSAXDso0NYw== x-ms-office365-filtering-correlation-id: d0d4c2f8-ed8b-4dbd-c721-08d681692980 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600110)(711020)(4605077)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:DB7PR04MB5225; x-ms-traffictypediagnostic: DB7PR04MB5225: x-microsoft-antispam-prvs: x-forefront-prvs: 0926B0E013 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(39860400002)(376002)(136003)(346002)(366004)(199004)(189003)(50226002)(66066001)(7736002)(6486002)(6512007)(305945005)(14454004)(81166006)(81156014)(8936002)(478600001)(8676002)(68736007)(2906002)(53946003)(6436002)(106356001)(2501003)(105586002)(36756003)(3846002)(6116002)(76176011)(102836004)(54906003)(97736004)(52116002)(6506007)(386003)(53936002)(186003)(26005)(86362001)(316002)(110136005)(99286004)(11346002)(446003)(30864003)(5024004)(71200400001)(256004)(14444005)(71190400001)(39060400002)(476003)(2616005)(4326008)(486006)(25786009)(579004); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR04MB5225; H:DB7PR04MB4636.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: mnJF1N8uhhU2/Qs2FgViP+g2ahIJS1ONJmkztKAg35DZyOlI4pkjoh+niX49am4ry0Tvx9CWzPHuxF0tiL/0A+RQSJp83KLKh3eQiUEJiElDK+osTD23H5PqFYaVgRXAnRFoKfN7jD9pYPavgNffa4YzpsmJ4MaZn75qs+ykFUIG/jTMNcwYhIdknLmcF8Hgf5aBDXCNIQEMGFscE2ZK8FnZPROQYjK86nTL3//ByyvG0Gr42myOgfoFSomjbnsvrcgGpEX81WGcoA43sTKFVN95oXstWilKwwO6YI5GIHV/a1CmqSX4pOX932GOoCsh6GGhGOShRxqZdPaMYDIcKGjnaNboQKPEqRCM5xOLvEJ3T3MzJEW+krjb/5vDLRsH0Vl2L+b5IQAkdiSNJlO8j6rJPR/U37p6k0wiS3SMlJM= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d0d4c2f8-ed8b-4dbd-c721-08d681692980 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Jan 2019 19:29:53.9644 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB5225 Cc: Breno Matheus Lima , "u-boot@lists.denx.de" Subject: [U-Boot] [PATCH 3/6] doc: imx: habv4: Add Secure Boot guide for i.MX6 and i.MX7 non-SPL targets X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" Add HABv4 documentation for non-SPL targets covering the following topics: - How to sign an securely boot an u-boot-dtb.imx image. - How to extend the root of trust for additional boot images. - Add 3 CSF examples. - Add IVT generation script example. Reviewed-by: Ye Li Reviewed-by: Utkarsh Gupta Signed-off-by: Breno Lima --- .../csf_additional_images.txt | 34 ++ .../habv4/csf_examples/mx6_mx7/csf_uboot.txt | 32 ++ .../mx6_mx7/csf_uboot_fast_authentication.txt | 23 + doc/imx/habv4/guides/mx6_mx7_secure_boot.txt | 402 ++++++++++++++++++ doc/imx/habv4/script_examples/genIVT.pl | 12 + 5 files changed, 503 insertions(+) create mode 100644 doc/imx/habv4/csf_examples/additional_images/csf_additional_images.txt create mode 100644 doc/imx/habv4/csf_examples/mx6_mx7/csf_uboot.txt create mode 100644 doc/imx/habv4/csf_examples/mx6_mx7/csf_uboot_fast_authentication.txt create mode 100644 doc/imx/habv4/guides/mx6_mx7_secure_boot.txt create mode 100644 doc/imx/habv4/script_examples/genIVT.pl diff --git a/doc/imx/habv4/csf_examples/additional_images/csf_additional_images.txt b/doc/imx/habv4/csf_examples/additional_images/csf_additional_images.txt new file mode 100644 index 0000000000..bbe489714b --- /dev/null +++ b/doc/imx/habv4/csf_examples/additional_images/csf_additional_images.txt @@ -0,0 +1,34 @@ +[Header] + Version = 4.2 + Hash Algorithm = sha256 + Engine Configuration = 0 + Certificate Format = X509 + Signature Format = CMS + Engine = CAAM + +[Install SRK] + # Index of the key location in the SRK table to be installed + File = "../crts/SRK_1_2_3_4_table.bin" + Source index = 0 + +[Install CSFK] + # Key used to authenticate the CSF data + File = "../crts/CSF1_1_sha256_2048_65537_v3_usr_crt.pem" + +[Authenticate CSF] + +[Install Key] + # Key slot index used to authenticate the key to be installed + Verification index = 0 + # Target key slot in HAB key store where key will be installed + Target Index = 2 + # Key to install + File= "../crts/IMG1_1_sha256_2048_65537_v3_usr_crt.pem" + +[Authenticate Data] + # Key slot index used to authenticate the image data + Verification index = 2 + # Authenticate Start Address, Offset, Length and file + Blocks = 0x80800000 0x00000000 0x80EEA020 "zImage", \ + 0x83800000 0x00000000 0x8380B927 "imx7d-sdb.dtb", \ + 0x84000000 0x00000000 0x840425B8 "uTee-7dsdb" diff --git a/doc/imx/habv4/csf_examples/mx6_mx7/csf_uboot.txt b/doc/imx/habv4/csf_examples/mx6_mx7/csf_uboot.txt new file mode 100644 index 0000000000..39986243e4 --- /dev/null +++ b/doc/imx/habv4/csf_examples/mx6_mx7/csf_uboot.txt @@ -0,0 +1,32 @@ +[Header] + Version = 4.2 + Hash Algorithm = sha256 + Engine Configuration = 0 + Certificate Format = X509 + Signature Format = CMS + Engine = CAAM + +[Install SRK] + # Index of the key location in the SRK table to be installed + File = "../crts/SRK_1_2_3_4_table.bin" + Source index = 0 + +[Install CSFK] + # Key used to authenticate the CSF data + File = "../crts/CSF1_1_sha256_2048_65537_v3_usr_crt.pem" + +[Authenticate CSF] + +[Install Key] + # Key slot index used to authenticate the key to be installed + Verification index = 0 + # Target key slot in HAB key store where key will be installed + Target Index = 2 + # Key to install + File= "../crts/IMG1_1_sha256_2048_65537_v3_usr_crt.pem" + +[Authenticate Data] + # Key slot index used to authenticate the image data + Verification index = 2 + # Authenticate Start Address, Offset, Length and file + Blocks = 0x877ff400 0x00000000 0x0009ec00 "u-boot-dtb.imx" diff --git a/doc/imx/habv4/csf_examples/mx6_mx7/csf_uboot_fast_authentication.txt b/doc/imx/habv4/csf_examples/mx6_mx7/csf_uboot_fast_authentication.txt new file mode 100644 index 0000000000..cdb34bcf74 --- /dev/null +++ b/doc/imx/habv4/csf_examples/mx6_mx7/csf_uboot_fast_authentication.txt @@ -0,0 +1,23 @@ +[Header] + Version = 4.2 + Hash Algorithm = sha256 + Engine Configuration = 0 + Certificate Format = X509 + Signature Format = CMS + Engine = CAAM + +[Install SRK] + # Index of the key location in the SRK table to be installed + File = "../crts/SRK_1_2_3_4_table.bin" + Source index = 0 + +[Install NOCAK] + File = "../crts/SRK1_sha256_2048_65537_v3_usr_crt.pem" + +[Authenticate CSF] + +[Authenticate Data] + # Key slot index 0 used to authenticate the image data + Verification index = 0 + # Authenticate Start Address, Offset, Length and file + Blocks = 0x877ff400 0x00000000 0x0009ec00 "u-boot-dtb.imx" diff --git a/doc/imx/habv4/guides/mx6_mx7_secure_boot.txt b/doc/imx/habv4/guides/mx6_mx7_secure_boot.txt new file mode 100644 index 0000000000..98e18beecd --- /dev/null +++ b/doc/imx/habv4/guides/mx6_mx7_secure_boot.txt @@ -0,0 +1,402 @@ + +=======================================================+ + + i.MX6, i.MX7 U-Boot Secure Boot guide using HABv4 + + +=======================================================+ + +1. HABv4 secure boot process +----------------------------- + +This document describes a step-by-step procedure on how to sign and securely +boot an U-Boot image for non-SPL targets. It is assumed that the reader is +familiar with basic HAB concepts and with the PKI tree generation. + +Details about HAB can be found in the application note AN4581[1] and in the +introduction_habv4.txt document. + +1.1 Building a u-boot-dtb.imx image supporting secure boot +----------------------------------------------------------- + +The U-Boot provides support to secure boot configuration and also provide +access to the HAB APIs exposed by the ROM vector table, the support is +enabled by selecting the CONFIG_SECURE_BOOT option. + +When built with this configuration, the U-Boot provides extra functions for +HAB, such as the HAB status logs retrievement through the hab_status command +and support for extending the root of trust. + +The U-Boot also correctly pads the final image by aligning to the next 0xC00 +address, so the CSF signature data generated by CST can be concatenated to +image. + +The diagram below illustrate a signed u-boot-dtb.imx image layout: + + ------- +-----------------------------+ <-- *start + ^ | Image Vector Table | + | +-----------------------------+ <-- *boot_data + | | Boot Data | + | +-----------------------------+ <-- *dcd + | | DCD Table | + | +-----------------------------+ + Signed | | Padding | + Data | +-----------------------------+ <-- *entry + | | | + | | | + | | u-boot-dtb.bin | + | | | + | | | + | +-----------------------------+ + v | Padding | + ------- +-----------------------------+ <-- *csf + | | + | Command Sequence File (CSF) | + | | + +-----------------------------+ + | Padding (optional) | + +-----------------------------+ + +1.2 Enabling the secure boot support +------------------------------------- + +The first step is to generate an U-Boot image supporting the HAB features +mentioned above, this can be achieved by adding CONFIG_SECURE_BOOT to the +build configuration: + +- Defconfig: + + CONFIG_SECURE_BOOT=y + +- Kconfig: + + ARM architecture -> Support i.MX HAB features + +1.3 Creating the CSF description file +-------------------------------------- + +The CSF contains all the commands that the HAB executes during the secure +boot. These commands instruct the HAB on which memory areas of the image +to authenticate, which keys to install, use and etc. + +CSF examples are available under doc/imx/habv4/csf_examples/ directory. + +A build log containing the "Authenticate Data" parameters is available after +the U-Boot build, the example below is a log for mx7dsabresd_defconfig target: + +- mkimage build log: + + $ cat u-boot-dtb.imx.log + + Image Type: Freescale IMX Boot Image + Image Ver: 2 (i.MX53/6/7 compatible) + Mode: DCD + Data Size: 667648 Bytes = 652.00 KiB = 0.64 MiB + Load Address: 877ff420 + Entry Point: 87800000 + HAB Blocks: 0x877ff400 0x00000000 0x0009ec00 + ^^^^^^^^^^ ^^^^^^^^^^ ^^^^^^^^^^ + | | | + | | ------- (1) + | | + | ------------------ (2) + | + ----------------------------- (3) + + (1) Size of area in file u-boot-dtb.imx to sign. + This area should include the IVT, the Boot Data the DCD + and the U-Boot itself. + (2) Start of area in u-boot-dtb.imx to sign. + (3) Start of area in RAM to authenticate. + +- In "Authenticate Data" CSF command users can copy and past the output + addresses: + + Block = 0x877ff400 0x00000000 0x0009ec00 "u-boot-dtb.imx" + +1.4 Signing the U-Boot binary +------------------------------ + +The CST tool is used for singing the U-Boot binary and generating a CSF binary, +users should input the CSF description file created in the step above and +should receive a CSF binary, which contains the CSF commands, SRK table, +signatures and certificates. + +- Create CSF binary file: + + $ ./cst -i csf_uboot.txt -o csf_uboot.bin + +- Append CSF signature to the end of U-Boot image: + + $ cat u-boot-dtb.imx csf_uboot.bin > u-boot-signed.imx + +The u-boot-signed.imx is the signed binary and should be flashed into the boot +media. + +- Flash signed U-Boot binary: + + $ sudo dd if=u-boot-signed.imx of=/dev/sd bs=1K seek=1 && sync + +1.5 Programming SRK Hash +------------------------- + +As explained in AN4581[1] and in introduction_habv4.txt document the SRK Hash +fuse values are generated by the srktool and should be programmed in the +SoC SRK_HASH[255:0] fuses. + +Be careful when programming these values, as this data is the basis for the +root of trust. An error in SRK Hash results in a part that does not boot. + +The U-Boot fuse tool can be used for programming eFuses on i.MX SoCs. + +- Dump SRK Hash fuses values in host machine: + + $ hexdump -e '/4 "0x"' -e '/4 "%X""\n"' SRK_1_2_3_4_fuse.bin + 0x20593752 + 0x6ACE6962 + 0x26E0D06C + 0xFC600661 + 0x1240E88F + 0x1209F144 + 0x831C8117 + 0x1190FD4D + +- Program SRK_HASH[255:0] fuses, using i.MX6 series as example: + + => fuse prog 3 0 0x20593752 + => fuse prog 3 1 0x6ACE6962 + => fuse prog 3 2 0x26E0D06C + => fuse prog 3 3 0xFC600661 + => fuse prog 3 4 0x1240E88F + => fuse prog 3 5 0x1209F144 + => fuse prog 3 6 0x831C8117 + => fuse prog 3 7 0x1190FD4D + +The table below lists the SRK_HASH bank and word according to the i.MX device: + + +-------------------+---------------+---------------+---------------+ + | | i.MX6 Series | i.MX7D/S | i.MX7ULP | + +-------------------+---------------+---------------+---------------+ + | SRK_HASH[31:00] | bank 3 word 0 | bank 6 word 0 | bank 5 word 0 | + +-------------------+---------------+---------------+---------------+ + | SRK_HASH[63:32] | bank 3 word 1 | bank 6 word 1 | bank 5 word 1 | + +-------------------+---------------+---------------+---------------+ + | SRK_HASH[95:64] | bank 3 word 2 | bank 6 word 2 | bank 5 word 2 | + +-------------------+---------------+---------------+---------------+ + | SRK_HASH[127:96] | bank 3 word 3 | bank 6 word 3 | bank 5 word 3 | + +-------------------+---------------+---------------+---------------+ + | SRK_HASH[159:128] | bank 3 word 4 | bank 7 word 0 | bank 5 word 4 | + +-------------------+---------------+---------------+---------------+ + | SRK_HASH[191:160] | bank 3 word 5 | bank 7 word 1 | bank 5 word 5 | + +-------------------+---------------+---------------+---------------+ + | SRK_HASH[223:192] | bank 3 word 6 | bank 7 word 2 | bank 5 word 6 | + +-------------------+---------------+---------------+---------------+ + | SRK_HASH[255:224] | bank 3 word 7 | bank 7 word 3 | bank 5 word 7 | + +-------------------+---------------+---------------+---------------+ + +1.6 Verifying HAB events +------------------------- + +The next step is to verify that the signature attached to U-Boot is +successfully processed without errors. HAB generates events when processing +the commands if it encounters issues. + +The hab_status U-Boot command call the hab_report_event() and hab_status() +HAB API functions to verify the processor security configuration and status. +This command displays any events that were generated during the process. + +Prior to closing the device users should ensure no HAB events were found, as +the example below: + +- Verify HAB events: + + => hab_status + + Secure boot disabled + + HAB Configuration: 0xf0, HAB State: 0x66 + No HAB Events Found! + +1.7 Closing the device +----------------------- + +After the device successfully boots a signed image without generating any HAB +events, it is safe to close the device. This is the last step in the HAB +process, and is achieved by programming the SEC_CONFIG[1] fuse bit. + +Once the fuse is programmed, the chip does not load an image that has not been +signed using the correct PKI tree. + +- Program SEC_CONFIG[1] fuse, using i.MX6 series as example: + + => fuse prog 0 6 0x00000002 + +The table below list the SEC_CONFIG[1] bank and word according to the i.MX +device: + + +--------------+-----------------+------------+ + | Device | Bank and Word | Value | + +--------------+-----------------+------------+ + | i.MX6 Series | bank 0 word 6 | 0x00000002 | + +--------------+-----------------+------------+ + | i.MX7D/S | bank 1 word 3 | 0x02000000 | + +--------------+-----------------+------------+ + | i.MX7ULP | bank 29 word 6 | 0x80000000 | + +--------------+-----------------+------------+ + +1.8 Completely secure the device +--------------------------------- + +Additional fuses can be programmed for completely secure the device, more +details about these fuses and their possible impact can be found at AN4581[1]. + +- Program SRK_LOCK, using i.MX6 series as example: + + => fuse prog 0 0 0x4000 + +- Program DIR_BT_DIS, using i.MX6 series as example: + + => fuse prog 0 6 0x8 + +- Program SJC_DISABLE, using i.MX6 series as example: + + => fuse prog 0 6 0x100000 + +- JTAG_SMODE, using i.MX6 series as example: + + => fuse prog 0 6 0xC00000 + +The table below list the SRK_LOCK, DIR_BT_DIS, SJC_DISABLE, and JTAG_SMODE bank +and word according to the i.MX device: + + +--------------+---------------+------------+ + | Device | Bank and Word | Value | + +--------------+---------------+------------+ + | SRK_LOCK | + +-------------------------------------------+ + | i.MX6 Series | bank 0 word 0 | 0x00004000 | + +--------------+---------------+------------+ + | i.MX7D/S | bank 0 word 0 | 0x00000200 | + +--------------+---------------+------------+ + | i.MX7ULP | bank 1 word 1 | 0x00000080 | + +--------------+---------------+------------+ + | DIR_BT_DIS | + +-------------------------------------------+ + | i.MX6 Series | bank 0 word 6 | 0x00000008 | + +--------------+---------------+------------+ + | i.MX7D/S | bank 1 word 3 | 0x08000000 | + +--------------+---------------+------------+ + | i.MX7ULP | bank 1 word 1 | 0x00002000 | + +--------------+---------------+------------+ + | SJC_DISABLE | + +-------------------------------------------+ + | i.MX6 Series | bank 0 word 6 | 0x00100000 | + +--------------+---------------+------------+ + | i.MX7D/S | bank 1 word 3 | 0x00200000 | + +--------------+---------------+------------+ + | i.MX7ULP | bank 1 word 1 | 0x00000020 | + +--------------+---------------+------------+ + | JTAG_SMODE | + +-------------------------------------------+ + | i.MX6 Series | bank 0 word 6 | 0x00C00000 | + +--------------+---------------+------------+ + | i.MX7D/S | bank 1 word 3 | 0x00C00000 | + +--------------+---------------+------------+ + | i.MX7ULP | bank 1 word 1 | 0x000000C0 | + +--------------+---------------+------------+ + +2. Extending the root of trust +------------------------------- + +The High Assurance Boot (HAB) code located in the on-chip ROM provides an +Application Programming Interface (API) making it possible to call back +into the HAB code for authenticating additional boot images. + +The U-Boot supports this feature and can be used to authenticate the Linux +Kernel Image. + +The process of signing an additional image is similar to the U-Boot. +The diagram below illustrate the zImage layout: + + ------- +-----------------------------+ <-- *load_address + ^ | | + | | | + | | | + | | | + | | zImage | + Signed | | | + Data | | | + | | | + | +-----------------------------+ + | | Padding Next Boundary | + | +-----------------------------+ <-- *ivt + v | Image Vector Table | + ------- +-----------------------------+ <-- *csf + | | + | Command Sequence File (CSF) | + | | + +-----------------------------+ + | Padding (optional) | + +-----------------------------+ + +2.1 Padding the image +---------------------- + +The zImage must be padded to the next boundary address (0x1000), for instance +if the image size is 0x649920 it must be padded to 0x64A000. + +The tool objcopy can be used for padding the image. + +- Pad the zImage: + + $ objcopy -I binary -O binary --pad-to 0x64A000 --gap-fill=0x00 \ + zImage zImage_pad.bin + +2.2 Generating Image Vector Table +---------------------------------- + +The HAB code requires an Image Vector Table (IVT) for determining the image +length and the CSF location. Since zImage does not include an IVT this has +to be manually created and appended to the end of the padded zImage, the +script genIVT.pl in script_examples directory can be used as reference. + +- Generate IVT: + + $ genIVT.pl + +Note: The load Address may change depending on the device. + +- Append the ivt.bin at the end of the padded zImage: + + $ cat zImage_pad.bin ivt.bin > zImage_pad_ivt.bin + +2.3 Signing the image +---------------------- + +A CSF file has to be created to sign the image. HAB does not allow to change +the SRK once the first image is authenticated, so the same SRK key used in +U-Boot must be used when extending the root of trust. + +CSF examples are available in ../csf_examples/additional_images/ +directory. + +- Create CSF binary file: + + $ ./cst --i csf_additional_images.txt --o csf_zImage.bin + +- Attach the CSF binary to the end of the image: + + $ cat zImage_pad_ivt.bin csf_zImage.bin > zImage_signed.bin + +2.4 Verifying HAB events +------------------------- + +The U-Boot includes the hab_auth_img command which can be used for +authenticating and troubleshooting the signed image, zImage must be +loaded at the load address specified in the IVT. + +- Authenticate additional image: + + => hab_auth_img + +If no HAB events were found the zImage is successfully signed. + +References: +[1] AN4581: "Secure Boot on i.MX 50, i.MX 53, i.MX 6 and i.MX 7 Series using + HABv4" - Rev 2. diff --git a/doc/imx/habv4/script_examples/genIVT.pl b/doc/imx/habv4/script_examples/genIVT.pl new file mode 100644 index 0000000000..84a4fcb16f --- /dev/null +++ b/doc/imx/habv4/script_examples/genIVT.pl @@ -0,0 +1,12 @@ +#! /usr/bin/perl -w +use strict; +open(my $out, '>:raw', 'ivt.bin') or die "Unable to open: $!"; +print $out pack("V", 0x412000D1); # Signature +print $out pack("V", 0x80800000); # Load Address (*load_address) +print $out pack("V", 0x0); # Reserved +print $out pack("V", 0x0); # DCD pointer +print $out pack("V", 0x0); # Boot Data +print $out pack("V", 0x80EEA000); # Self Pointer (*ivt) +print $out pack("V", 0x80EEA020); # CSF Pointer (*csf) +print $out pack("V", 0x0); # Reserved +close($out); From patchwork Wed Jan 23 19:30:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Matheus Lima X-Patchwork-Id: 1030133 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="iTCFzreh"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43lFmg6jVtz9s3l for ; Thu, 24 Jan 2019 06:32:35 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 9D368C21E0F; Wed, 23 Jan 2019 19:31:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id C177BC21E12; Wed, 23 Jan 2019 19:30:58 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 510F4C21E12; Wed, 23 Jan 2019 19:30:11 +0000 (UTC) Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40057.outbound.protection.outlook.com [40.107.4.57]) by lists.denx.de (Postfix) with ESMTPS id 67FC0C21D65 for ; Wed, 23 Jan 2019 19:30:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TiIvRJWly5DrYuFjg2AvQYV+JUFHWHBP4PDumf0z8O0=; b=iTCFzrehwVJgcnXxOxyk0T2dEahLP59GwyMUcZNBWxd7CsfFvv0IK96u1DCXKNv524kSRtLgS1GijnYkJ3A8VtQJVzr8lM69rTyYASCWbSipAunu5JWJQGs07BkkU+znN72FmgL0X0aeEXxDfCT7+ok4Z2PA1AAqx5fhxNJBotM= Received: from DB7PR04MB4636.eurprd04.prod.outlook.com (52.135.138.158) by DB7PR04MB5225.eurprd04.prod.outlook.com (20.176.236.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1558.17; Wed, 23 Jan 2019 19:30:06 +0000 Received: from DB7PR04MB4636.eurprd04.prod.outlook.com ([fe80::ad79:c2:afcd:9b85]) by DB7PR04MB4636.eurprd04.prod.outlook.com ([fe80::ad79:c2:afcd:9b85%3]) with mapi id 15.20.1537.031; Wed, 23 Jan 2019 19:30:06 +0000 From: Breno Matheus Lima To: "fabio.estevam@gmail.com" , "sbabic@denx.de" Thread-Topic: [PATCH 4/6] doc: imx: habv4: Add Secure Boot guide for i.MX6 and i.MX7 SPL targets Thread-Index: AQHUs1ILyF8QX7EMSkqPkKco31Kdgw== Date: Wed, 23 Jan 2019 19:30:06 +0000 Message-ID: <1548271740-177-5-git-send-email-breno.lima@nxp.com> References: <1548271740-177-1-git-send-email-breno.lima@nxp.com> In-Reply-To: <1548271740-177-1-git-send-email-breno.lima@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [64.157.242.222] x-clientproxiedby: SN6PR04CA0037.namprd04.prod.outlook.com (2603:10b6:805:2a::14) To DB7PR04MB4636.eurprd04.prod.outlook.com (2603:10a6:5:36::30) authentication-results: spf=none (sender IP is ) smtp.mailfrom=breno.lima@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.7.4 x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB7PR04MB5225; 6:27lgLULiPOykB5wkGx10EZ8EpxOh5dao8QoICmvQfsQJhwtN+KGSFCYLqVT3FzJKH+V9aFgMww1Af+XcBXeJj6mQzkkfA9/kZd4LVXqjrGRRKe/PzCAyM8dxx6gd4kInP41/6JeZ54AK28tGuQmDMv3h+Nn1iA1OCrjpVnBBNgZDgIGca5KxvaU9Zp91rBzRWAiW93ZDCTl+RomIyDtoiTxZ89i8u3grhevaoZRJyR4utbJNMlHCU/eE5XHLDAs8xdDnZk5voCEGaSRbnI39Vh/MenwFf1Hob6HH6YFUcNvuAh8wr9ARljcUTrvTxFCtmsX30ocFjFjVsaeqtZrqp41CsaHB8X8g09IS6tnJjs/Ttvp/s1yQhGyPlj15bSJbB/hPDk3cQjb0SE1fnm9FkEtDs3VpKDLmPkHfvB5yXt45mkCeUq7tHS/9Z3+iHjy5MWnrnh2TjBPrgUqOvPOUeA==; 5:5nVJG3sTGEwhma2YHLTi6BMrxt2ueAKUrgLUQmCFlwaSqW44BOz3wcD3L3/1NY4W3Gr9co1TTszIF8paCuMtsWF55Zzyw2zE8u4JB9QOneoUScgMhJ2KqEEowXTllPOUtJlOGmdpXbnNbH5xFKwHaIISAS3wwkbBHiYsUkpX3ILrmo+fJZhbmgKu5+GG70SXT7jobu4+GZytrrCLOCFioQ==; 7:Pz3YajyJFiQAnPVsJXMS3kCgjJbFXy/bV64xBq3MR2NyBHNolR91l0mwnbdyNFcMLqpWuG+44XfLhHSN4MaK4E/gi8oP9sHyHj2y+VMav4v4YSGcmAYKcjH0gN1g0oDwItjhhT0AHeCYs0uEmTUJwA== x-ms-office365-filtering-correlation-id: 778e4778-0869-40ce-6744-08d681692dd8 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600110)(711020)(4605077)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:DB7PR04MB5225; x-ms-traffictypediagnostic: DB7PR04MB5225: x-microsoft-antispam-prvs: x-forefront-prvs: 0926B0E013 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(39860400002)(376002)(136003)(346002)(366004)(199004)(189003)(50226002)(66066001)(7736002)(6486002)(6512007)(305945005)(14454004)(81166006)(81156014)(8936002)(478600001)(8676002)(68736007)(2906002)(6436002)(106356001)(2501003)(105586002)(36756003)(3846002)(6116002)(76176011)(102836004)(54906003)(97736004)(52116002)(6506007)(386003)(53936002)(186003)(26005)(86362001)(316002)(110136005)(99286004)(11346002)(446003)(71200400001)(256004)(14444005)(71190400001)(39060400002)(476003)(2616005)(4326008)(486006)(25786009); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR04MB5225; H:DB7PR04MB4636.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: LegUjr8qbyxSNRGVDo5yI0FPaqI1N9Bu8iBK2l2wqisu51kCijDfQwqa2JOhl8zg5Io5wui1tE+DBOiWmbaI3mIoM96OyQyX2vOkOvvD9l3i9fWu7PM/6Zxj+cV/0TLPCTyyxyCaCq1alDPpxM2ZLiDI//G8UvyKwLOwoIBE4aOHrNyQJgjfjQb+bnczxGEbJo6zVBYGvTG25ZUfbxL/uw95hlwWviF0oirZkOsymtqILwPm0H9wj9norQK5yv1+Y3zkd9O/VtWqDBSLCkvnZHy8XkkJuVIMPBkWLd21aDUlzUI/QBb/uy9seCxXvxBwNO5SJSSobfmlT7LFxbSMG1GfOeLek9+zj9dh1Si2GBuSYBp9H0wczzy1xt8v1iEYlB0oDGOy6hea/3ZNshVZxTFA9qZjZOxShOft5zYDP6A= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 778e4778-0869-40ce-6744-08d681692dd8 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Jan 2019 19:30:00.1628 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB5225 Cc: Breno Matheus Lima , "u-boot@lists.denx.de" Subject: [U-Boot] [PATCH 4/6] doc: imx: habv4: Add Secure Boot guide for i.MX6 and i.MX7 SPL targets X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" The current U-Boot implementation includes SPL targets for some NXP development boards: - mx6sabreauto_defconfig - mx6sabresd_defconfig - mx6ul_14x14_evk_defconfig - mx6ul_9x9_evk_defconfig Add additional steps needed to completly secure the bootloader image. Signed-off-by: Breno Lima --- .../habv4/guides/mx6_mx7_spl_secure_boot.txt | 181 ++++++++++++++++++ 1 file changed, 181 insertions(+) create mode 100644 doc/imx/habv4/guides/mx6_mx7_spl_secure_boot.txt diff --git a/doc/imx/habv4/guides/mx6_mx7_spl_secure_boot.txt b/doc/imx/habv4/guides/mx6_mx7_spl_secure_boot.txt new file mode 100644 index 0000000000..0d7931aac0 --- /dev/null +++ b/doc/imx/habv4/guides/mx6_mx7_spl_secure_boot.txt @@ -0,0 +1,181 @@ + +===============================================================+ + + i.MX6, i.MX7 U-Boot HABv4 Secure Boot guide for SPL targets + + +===============================================================+ + +1. HABv4 secure boot process +----------------------------- + +This document is an addendum of mx6_mx7_secure_boot.txt guide describing a +step-by-step procedure on how to sign and securely boot an U-Boot image for +SPL targets. + +Details about HAB can be found in the application note AN4581[1] and in the +introduction_habv4.txt document. + +1.1 Building a SPL target supporting secure boot +------------------------------------------------- + +The U-Boot provides Second Program Loader (SPL) support which generates two +final images, SPL and U-Boot proper. The HABv4 can be used to authenticate +both binaries. + +Out of reset the ROM code authenticates the SPL which is responsible for +initializing essential features such as DDR, UART, PMIC and clock +enablement. Once the DDR is available, the SPL code loads the U-Boot proper +image to its specific execution address and call the HAB APIs to extend the +root of trust. + +The U-Boot provides support to secure boot configuration and also provide +access to the HAB APIs exposed by the ROM vector table, the support is +enabled by selecting the CONFIG_SECURE_BOOT option. + +When built with this configuration the U-Boot correctly pads the final SPL +image by aligning to the next 0xC00 address, so the CSF signature data +generated by CST can be concatenated to the image. + +The U-Boot also append an Image Vector Table (IVT) in the final U-Boot proper +binary (u-boot-ivt.img) so it can be used by HAB API in a post ROM stage. + +The diagram below illustrate a signed SPL image layout: + + ------- +-----------------------------+ <-- *start + ^ | Image Vector Table | + | +-----------------------------+ <-- *boot_data + | | Boot Data | + | +-----------------------------+ + Signed | | Padding | + Data | +-----------------------------+ <-- *entry + | | | + | | SPL | + | | | + | +-----------------------------+ + v | Padding | + ------- +-----------------------------+ <-- *csf + | | + | Command Sequence File (CSF) | + | | + +-----------------------------+ + | Padding (optional) | + +-----------------------------+ + +The diagram below illustrate a signed u-boot-ivt.img image layout: + + ------- +-----------------------------+ <-- *load_address + ^ | | + | | | + | | u-boot.img | + Signed | | | + Data | | | + | +-----------------------------+ + | | Padding Next Boundary | + | +-----------------------------+ <-- *ivt + v | Image Vector Table | + ------- +-----------------------------+ <-- *csf + | | + | Command Sequence File (CSF) | + | | + +-----------------------------+ + | Padding (optional) | + +-----------------------------+ + +1.2 Enabling the secure boot support +------------------------------------- + +The first step is to generate an U-Boot image supporting the HAB features +mentioned above, this can be achieved by adding CONFIG_SECURE_BOOT to the +build configuration: + +- Defconfig: + + CONFIG_SECURE_BOOT=y + +- Kconfig: + + ARM architecture -> Support i.MX HAB features + +1.3 Creating the CSF description file +-------------------------------------- + +The CSF contains all the commands that the HAB executes during the secure +boot. These commands instruct the HAB code on which memory areas of the image +to authenticate, which keys to install, use and etc. + +CSF examples are available under doc/imx/habv4/csf_examples/ directory. + +Build logs containing the "Authenticate Data" parameters are available after +the U-Boot build, the example below is a log for mx6sabresd_defconfig target: + +- SPL build log: + + $ cat SPL.log + Image Type: Freescale IMX Boot Image + Image Ver: 2 (i.MX53/6/7 compatible) + Mode: DCD + Data Size: 69632 Bytes = 68.00 KiB = 0.07 MiB + Load Address: 00907420 + Entry Point: 00908000 + HAB Blocks: 0x00907400 0x00000000 0x0000ec00 + +- u-boot-ivt.img build log: + + $ cat u-boot-ivt.img.log + Image Name: U-Boot 2019.01-00003-g78ee492eb3 + Created: Mon Jan 14 17:58:10 2019 + Image Type: ARM U-Boot Firmware with HABv4 IVT (uncompressed) + Data Size: 458688 Bytes = 447.94 KiB = 0.44 MiB + Load Address: 17800000 + Entry Point: 00000000 + HAB Blocks: 0x177fffc0 0x0000 0x0006e020 + +As explained in section above the SPL is first authenticated by the ROM code +and the root of trust is extended to the U-Boot image, hence two CSF files are +necessary to completely sign a bootloader image. + +In "Authenticate Data" CSF command users can copy and past the output +addresses, the csf_uboot.txt can be used as example: + +- In csf_SPL.txt: + + Block = 0x00907400 0x00000000 0x0000ec00 "SPL" + +- In csf_uboot-ivt.txt: + + Block = 0x177fffc0 0x0000 0x0006e020 "u-boot-ivt.img" + +1.4 Signing the images +----------------------- + +The CST tool is used for singing the U-Boot binary and generating a CSF binary, +users should input the CSF description file created in the step above and +receive a CSF binary, which contains the CSF commands, SRK table, signatures +and certificates. + +- Create SPL CSF binary file: + + $ ./cst -i csf_SPL.txt -o csf_SPL.bin + +- Append CSF signature to the end of SPL image: + + $ cat SPL csf_SPL.bin > SPL-signed + +- Create U-Boot proper CSF binary file: + + $ ./cst -i csf_uboot-ivt.txt -o csf_uboot-ivt.bin + +- Append CSF signature to the end of U-Boot proper image: + + $ cat u-boot-ivt.img csf_uboot-ivt.bin > u-boot-signed.img + +The bootloader is signed and can be flashed into the boot media. + +1.5 Closing the device +----------------------- + +The procedure for closing the device is similar as in Non-SPL targets, for a +complete procedure please refer to section "1.5 Programming SRK Hash" in +mx6_mx7_secure_boot.txt document available under doc/imx/habv4/guides/ +directory. + +References: +[1] AN4581: "Secure Boot on i.MX 50, i.MX 53, i.MX 6 and i.MX 7 Series using + HABv4" - Rev 2. From patchwork Wed Jan 23 19:30:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Matheus Lima X-Patchwork-Id: 1030132 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="is7WlSBq"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43lFm93fdgz9s3l for ; Thu, 24 Jan 2019 06:32:04 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 9CCB2C21DA6; Wed, 23 Jan 2019 19:31:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 4C743C21E13; Wed, 23 Jan 2019 19:30:35 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 29192C21DB5; Wed, 23 Jan 2019 19:30:12 +0000 (UTC) Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40063.outbound.protection.outlook.com [40.107.4.63]) by lists.denx.de (Postfix) with ESMTPS id 2D76BC21DF9 for ; Wed, 23 Jan 2019 19:30:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1I0+zR1oATQjtAsXo5/zh7qu+pdnVZD7zk0Zwi3ue64=; b=is7WlSBqwTgyoGWSAzbngBvFjOW0bdi+zGso8GKRaHiLnsjUV4VJQHsymv+wOJNo0pu48P3DLIVRajaRbAjfWg98BY4PMOtxWgDGVXGIjiWaXhFjfBVtn4oIawNSefUAs6yb2ZZq8RkDrrDF6yCjr0HB9QBRriAhh5fi0Ib8xFY= Received: from DB7PR04MB4636.eurprd04.prod.outlook.com (52.135.138.158) by DB7PR04MB5225.eurprd04.prod.outlook.com (20.176.236.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1558.17; Wed, 23 Jan 2019 19:30:11 +0000 Received: from DB7PR04MB4636.eurprd04.prod.outlook.com ([fe80::ad79:c2:afcd:9b85]) by DB7PR04MB4636.eurprd04.prod.outlook.com ([fe80::ad79:c2:afcd:9b85%3]) with mapi id 15.20.1537.031; Wed, 23 Jan 2019 19:30:11 +0000 From: Breno Matheus Lima To: "fabio.estevam@gmail.com" , "sbabic@denx.de" Thread-Topic: [PATCH 5/6] doc: imx: habv4: Move encrypted boot guide Thread-Index: AQHUs1IOqO17Chg6GkCTMjT8S5Dl3Q== Date: Wed, 23 Jan 2019 19:30:11 +0000 Message-ID: <1548271740-177-6-git-send-email-breno.lima@nxp.com> References: <1548271740-177-1-git-send-email-breno.lima@nxp.com> In-Reply-To: <1548271740-177-1-git-send-email-breno.lima@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [64.157.242.222] x-clientproxiedby: SN6PR04CA0037.namprd04.prod.outlook.com (2603:10b6:805:2a::14) To DB7PR04MB4636.eurprd04.prod.outlook.com (2603:10a6:5:36::30) authentication-results: spf=none (sender IP is ) smtp.mailfrom=breno.lima@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.7.4 x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB7PR04MB5225; 6:4T16PaW6DRqMwswxnxYalx0Z3F9a9hIhZ3iuJD5xrGJN9dczw4fARleHD3OJ4wl8swF1cgeqvbb0LDBAzvIMj6mmCsVhXbyakLfECLMqcH+bLRkkX0OwraG7jkwtjCkx+IqtATiuHSNpR8ZcRAodZgqpFjuBJTK7tkTrKIrfvxoqcRmQIKZm/Y3LIy5dLYfBk4ktyZmCgoqztE47ECbJGye/y6PS/OqELQbLa/8Obo4O35bbtOnaRDazlbUl9CJ7iSu4gknMnh7735C1L+BWmdYDxvI2ViVNTPiNmH/oZVUv6FfFf82+DUd0soyu5b2X3rvvmwuuAKgDa/tvDpbQj5lP3tLXYP8yvhXyBdpgwei8CZq7KJiXMQvpNpk7UQjJ3uAhHEZrWHltsxEa0XVDrvC1Jn/GlwAWrNlrngAmuLz2G7y1opwROx+f0UFYeQhYCPTxQXPVrBivMQLWj/zRbw==; 5:jZSy5WDIZ5aItRmnZlJbQOM1srfyysUThArKSqiQNVp3X0apxt/49wCC7mOd1Atd4bZbUn7P3QQSs7GLyGlU41/kDa8u9VZI4KAwubZSLPneyv4ItuNRALxE2NZ0CHUWOmcq6lyg5uE4XeFq3HiuaXE2LMg034INHNOizpwp/4SLtQ6Z42o+oaTmrL1cHjxaaNOzzYWYbFmKmr6M8oN3tw==; 7:LCbkjrKzWr9WAZW1LtpkFVOtW9ChKPEg4tHEI6nHxfMER9FpeFPEcXk9YAie9TpJlzz8MnLoJw1hl8Jj/xTs8CdNQfYnFbFODZRdjl3IMHYrL3HehysMGqvul/Cq4XbtpbLhpCXfxDqJAdrywD5QPQ== x-ms-office365-filtering-correlation-id: a84fdb73-fc00-42ab-67e2-08d6816930c1 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600110)(711020)(4605077)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:DB7PR04MB5225; x-ms-traffictypediagnostic: DB7PR04MB5225: x-microsoft-antispam-prvs: x-forefront-prvs: 0926B0E013 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(39860400002)(376002)(136003)(346002)(366004)(199004)(189003)(50226002)(66066001)(7736002)(6486002)(6512007)(305945005)(14454004)(81166006)(81156014)(8936002)(478600001)(8676002)(68736007)(2906002)(6436002)(106356001)(2501003)(105586002)(36756003)(3846002)(6116002)(76176011)(102836004)(54906003)(97736004)(52116002)(6506007)(386003)(53936002)(186003)(26005)(86362001)(316002)(110136005)(99286004)(11346002)(446003)(71200400001)(256004)(71190400001)(4744005)(39060400002)(476003)(2616005)(4326008)(486006)(25786009); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR04MB5225; H:DB7PR04MB4636.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: C5zgf/GnIdurFexXfuMfKubx+vdzw2kM8AQRZMJSz/AQsTLILCPNpT3coCjqT7JhlX7o17tbLlyGhvKm5msbXgIoWp77I6/nVyPffYpHI0bfIShRticlwbkKyixxlAM5fwkvb2zgXTJJ6BBJzAx8LlB3MmWxvhMohwUnrBDs/GvQyN6LADjcFz1lRyYXaQOUCP4ILozu1GkLfc1pkUn2mPxdoFaUBr6b+zspRLkJCUsJYEQnobv3okYIBHQ6ivqep55v8g8ExhX5ItLejyGIR4vjMzG0IyK5CkMzAKdUdJvJchvIAeV3UEiB1pFlGk7b7cGqIf0PTqymLtqHLxZd+oL4ZJyBodfhoZSfXa5fTJ3yMEgnLV34ie5hsVlEMXbAnN4gAINjm6GpGGZaeF/N/KDFGGSKdsLkmK1GWjJgTb4= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a84fdb73-fc00-42ab-67e2-08d6816930c1 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Jan 2019 19:30:07.0036 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB5225 Cc: Breno Matheus Lima , "u-boot@lists.denx.de" Subject: [U-Boot] [PATCH 5/6] doc: imx: habv4: Move encrypted boot guide X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" All guides are currently located at doc/imx/habv4/guides/ directory. Move encrypted_boot.txt document to guides directory. Signed-off-by: Breno Lima --- doc/imx/habv4/{ => guides}/encrypted_boot.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename doc/imx/habv4/{ => guides}/encrypted_boot.txt (100%) diff --git a/doc/imx/habv4/encrypted_boot.txt b/doc/imx/habv4/guides/encrypted_boot.txt similarity index 100% rename from doc/imx/habv4/encrypted_boot.txt rename to doc/imx/habv4/guides/encrypted_boot.txt