From patchwork Wed Sep 14 18:57:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Lawrance X-Patchwork-Id: 1678058 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=softathome1.onmicrosoft.com header.i=@softathome1.onmicrosoft.com header.a=rsa-sha256 header.s=selector1-softathome1-onmicrosoft-com header.b=vkEkc1k2; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MSV2w45wGz1ypW for ; Thu, 15 Sep 2022 04:58:00 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F040F84B90; Wed, 14 Sep 2022 20:57:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=softathome.com 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=softathome1.onmicrosoft.com header.i=@softathome1.onmicrosoft.com header.b="vkEkc1k2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4DB44845B3; Wed, 14 Sep 2022 20:57:43 +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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from FRA01-PR2-obe.outbound.protection.outlook.com (mail-eopbgr120085.outbound.protection.outlook.com [40.107.12.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 17EAA84B8E for ; Wed, 14 Sep 2022 20:57:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=softathome.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=steven.lawrance@softathome.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XyPP4GyAEJh5cnFUuZXicWH7UWs01VJbSlxYIviD3ZSthJiMJSG5FXQ2pJIu75++L7nC7/LF0Y4liorA4CVgLEKQWj8b5g3zL1aL0x3ZxIGgRRf5VPScvZ8qQvpkBmK+G19ESQDYzXMsvpOQcBKMPwqnRN70a4KJuPfz6tBppMfmiSZEcekdao2lciJSnyMVrF4yP4KoL5rhAsCtv9yX19/wKX/VO48jdHYN0uS5qJIJz2dOdlZU5m3QKhOXafdpUVggfMgrS5qRv9TUp2YZGkKUG40icQ42RkDZyCG9n27e0SpDx/5jXYqfe4lh2HPlZVxA/PKwt8Tuqayp/r1ZLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=oQk4Y/VyBkf09icqVQOWPThGEYSL4HPyd4ktNWGVwo8=; b=VfVcIkSVBtr0phTh5xFOz1LdLm0pyDOJ43PvWzV3KW+sZyqOXX/P3o3sCxv3MeuPHoLAgKw7v3UZurFJC+6dqdURvQDhVLP0Pzi0rQ5moKlcwPFNJxxHOTw75wArjkFbQ6Z5KSiI5o0tM2gLYZ8eCtR/cMjiujbBVQGfhYPeY+gsrbyahvK4CEVow22apyb2o4+vAXKvCpHjqwq10unosjToo+MZDALlfMsDhe4PSTT8uSWK6I5gEA0OuKUVCxF72h4PSdFWhVF4/bAsiFJEzDni0SJx9tp9RPM5QhaGPA74ADuzrhe3LVTC9M3soOT/OY/WGvD0kIQlwXvyhmnNHQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.6.166.170) smtp.rcpttodomain=lists.denx.de smtp.mailfrom=softathome.com; dmarc=bestguesspass action=none header.from=softathome.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=softathome1.onmicrosoft.com; s=selector1-softathome1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oQk4Y/VyBkf09icqVQOWPThGEYSL4HPyd4ktNWGVwo8=; b=vkEkc1k2OBGbVlFRHCneri/x7MDYSPzJ2n5QUExsdJF0/czz/cqHZ4HfKzmWHt5IqjNGAuXCfGWU6ZukMx15LAeZmv7+M1NsOA434zck3bGu2/vKSizk1N8dN086aYo3xGoN5ZZZnL25wLzxCBBjvIofRU9gW8+el+v7maDwF9Wb8s96Sj/l4IFG3vCQMl+v3uq2iEsmy1zRFuken6URKRRk6BPHwERPJc0g+3w4YgmPR9n4qhV/lkob0riTth1r3caR3GkLahwAY4KfXSKit4/ShP3FVHd/6I9agJb01AnEjGh2J9Y6VO/FEtjtlrrn64jpnI7r7dC6b0KNOXVmHQ== Received: from MR1P264CA0005.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:2e::10) by MR1P264MB2323.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:34::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.12; Wed, 14 Sep 2022 18:57:35 +0000 Received: from MR2FRA01FT004.eop-fra01.prod.protection.outlook.com (2603:10a6:501:2e:cafe::27) by MR1P264CA0005.outlook.office365.com (2603:10a6:501:2e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.12 via Frontend Transport; Wed, 14 Sep 2022 18:57:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.6.166.170) smtp.mailfrom=softathome.com; dkim=none (message not signed) header.d=none;dmarc=bestguesspass action=none header.from=softathome.com; Received-SPF: Pass (protection.outlook.com: domain of softathome.com designates 149.6.166.170 as permitted sender) receiver=protection.outlook.com; client-ip=149.6.166.170; helo=proxy.softathome.com; pr=C Received: from proxy.softathome.com (149.6.166.170) by MR2FRA01FT004.mail.protection.outlook.com (10.152.50.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.12 via Frontend Transport; Wed, 14 Sep 2022 18:57:35 +0000 Received: from sahwlpt0127.be.softathome.com. (unknown [192.168.18.25]) by proxy.softathome.com (Postfix) with ESMTPSA id 06E051FE66; Wed, 14 Sep 2022 20:57:35 +0200 (CEST) From: Steven Lawrance To: u-boot@lists.denx.de Cc: Philippe Reynes Subject: [PATCH 1/2] image-pre-load: Move macros/definitions to image.h Date: Wed, 14 Sep 2022 20:57:27 +0200 Message-Id: <20220914185728.393277-1-steven.lawrance@softathome.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MR2FRA01FT004:EE_|MR1P264MB2323:EE_ X-MS-Office365-Filtering-Correlation-Id: 4542ceb6-5ab9-44b1-1c6d-08da9682fc8d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WQu7ldNg42iGwoBY2GkB77eBKmRFc3cZ630g9/J7Le/YJYBF+x2JvU3MX9OgyaK+ex24/qaHRLnVT6VtUomL1KCDp6N0kU5NCXUuuRJII00ptqcizEd6IJUtxq4fMzrzs0r5Qz3d6GvixfWUHzq7qg8vaAvIEIFx9nnqn/FbqLJE31Acz0nseJK2FXUAoO3l/3AjPbEdsPGxqC1Ritz2qAoY7RlP6pD5x94dMJtjqGgG+bBhlZUgzor8c2WjyzxVIzM1AC+Uwx9E43aSZj7doCKkrnEofHH6CWWRtAihNdRMmuUfraSKDbX0tI8Of+BD1V4rpT68GVbzKvtxs1JOHvhAaggjhRUiha9rH8r100q8MTm1H1GvMLO2irC6AQuT1ahDM4ZbUbh+ETUr5MSA1yUREH1My9hXYmhpzP9nV8r20iDJR+KDRQOyo+BK+OFA9cZiBgkRvvHjBsqgI++AoNeMnoDtHW6AGDWEOe97z7F4BqwRXpSKlisk4A6sXld57aQTgrLgB+6R6xjajdSSQYwFtJeeZQQLUqVCu/csqpZ9zGR4u6LnW12xt26hdYfk31lHL3YcyHSpp8fGf1+UwahiW8nkJHd8PXKGD4WsdmDMFxn/OGl2cObiZ5X7gujlM/BesA4ttNIUGii+ZWPACQz5Q/+qGX805Tz7qvHfJFWWVTyTZnexYNBYrfMVgtZfrnrg9qOYb8XeM1k2Tf21L2gsjH42I4SvrrcgZvzW0KiK+wINh7SlTnPnouUNsFDxT+erTFkNRajObRCQ4uWcxKtN7ahpiUulNKSsNacGmbCVRgEfcB9/a+p7EPSAFfo7 X-Forefront-Antispam-Report: CIP:149.6.166.170; CTRY:FR; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:proxy.softathome.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230022)(4636009)(136003)(376002)(396003)(39850400004)(346002)(451199015)(46966006)(40470700004)(36840700001)(70206006)(70586007)(426003)(4326008)(8676002)(40480700001)(47076005)(86362001)(26005)(5660300002)(36756003)(6266002)(8936002)(6916009)(2616005)(44832011)(2906002)(316002)(82740400003)(186003)(336012)(7696005)(82960400001)(82310400005)(81166007)(356005)(6966003)(478600001)(1076003)(41300700001)(107886003)(6666004)(40460700003)(83380400001)(36860700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: softathome.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2022 18:57:35.2742 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4542ceb6-5ab9-44b1-1c6d-08da9682fc8d X-MS-Exchange-CrossTenant-Id: aa10e044-e405-4c10-8353-36b4d0cce511 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=aa10e044-e405-4c10-8353-36b4d0cce511; Ip=[149.6.166.170]; Helo=[proxy.softathome.com] X-MS-Exchange-CrossTenant-AuthSource: MR2FRA01FT004.eop-fra01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MR1P264MB2323 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean Putting these definitions in a header will allow signatures to be validated independently of bootm. Signed-off-by: Steven Lawrance Reviewed-by: Simon Glass --- boot/image-pre-load.c | 43 ------------------------------------------- include/image.h | 43 +++++++++++++++++++++++++++++++++++++++++++ tools/image-host.c | 2 -- 3 files changed, 43 insertions(+), 45 deletions(-) diff --git a/boot/image-pre-load.c b/boot/image-pre-load.c index 5ab9ae1874..01b60030fc 100644 --- a/boot/image-pre-load.c +++ b/boot/image-pre-load.c @@ -11,49 +11,6 @@ DECLARE_GLOBAL_DATA_PTR; #include -#define IMAGE_PRE_LOAD_SIG_MAGIC 0x55425348 -#define IMAGE_PRE_LOAD_SIG_OFFSET_MAGIC 0 -#define IMAGE_PRE_LOAD_SIG_OFFSET_IMG_LEN 4 -#define IMAGE_PRE_LOAD_SIG_OFFSET_SIG 8 - -#define IMAGE_PRE_LOAD_PATH "/image/pre-load/sig" -#define IMAGE_PRE_LOAD_PROP_ALGO_NAME "algo-name" -#define IMAGE_PRE_LOAD_PROP_PADDING_NAME "padding-name" -#define IMAGE_PRE_LOAD_PROP_SIG_SIZE "signature-size" -#define IMAGE_PRE_LOAD_PROP_PUBLIC_KEY "public-key" -#define IMAGE_PRE_LOAD_PROP_MANDATORY "mandatory" - -/* - * Information in the device-tree about the signature in the header - */ -struct image_sig_info { - char *algo_name; /* Name of the algo (eg: sha256,rsa2048) */ - char *padding_name; /* Name of the padding */ - u8 *key; /* Public signature key */ - int key_len; /* Length of the public key */ - u32 sig_size; /* size of the signature (in the header) */ - int mandatory; /* Set if the signature is mandatory */ - - struct image_sign_info sig_info; /* Signature info */ -}; - -/* - * Header of the signature header - */ -struct sig_header_s { - u32 magic; - u32 version; - u32 header_size; - u32 image_size; - u32 offset_img_sig; - u32 flags; - u32 reserved0; - u32 reserved1; - u8 sha256_img_sig[SHA256_SUM_LEN]; -}; - -#define SIG_HEADER_LEN (sizeof(struct sig_header_s)) - /* * Offset of the image * diff --git a/include/image.h b/include/image.h index d7d756c645..10fe5115e7 100644 --- a/include/image.h +++ b/include/image.h @@ -1411,6 +1411,49 @@ struct crypto_algo *image_get_crypto_algo(const char *full_name); */ struct padding_algo *image_get_padding_algo(const char *name); +#define IMAGE_PRE_LOAD_SIG_MAGIC 0x55425348 +#define IMAGE_PRE_LOAD_SIG_OFFSET_MAGIC 0 +#define IMAGE_PRE_LOAD_SIG_OFFSET_IMG_LEN 4 +#define IMAGE_PRE_LOAD_SIG_OFFSET_SIG 8 + +#define IMAGE_PRE_LOAD_PATH "/image/pre-load/sig" +#define IMAGE_PRE_LOAD_PROP_ALGO_NAME "algo-name" +#define IMAGE_PRE_LOAD_PROP_PADDING_NAME "padding-name" +#define IMAGE_PRE_LOAD_PROP_SIG_SIZE "signature-size" +#define IMAGE_PRE_LOAD_PROP_PUBLIC_KEY "public-key" +#define IMAGE_PRE_LOAD_PROP_MANDATORY "mandatory" + +/* + * Information in the device-tree about the signature in the header + */ +struct image_sig_info { + char *algo_name; /* Name of the algo (eg: sha256,rsa2048) */ + char *padding_name; /* Name of the padding */ + uint8_t *key; /* Public signature key */ + int key_len; /* Length of the public key */ + uint32_t sig_size; /* size of the signature (in the header) */ + int mandatory; /* Set if the signature is mandatory */ + + struct image_sign_info sig_info; /* Signature info */ +}; + +/* + * Header of the signature header + */ +struct sig_header_s { + uint32_t magic; + uint32_t version; + uint32_t header_size; + uint32_t image_size; + uint32_t offset_img_sig; + uint32_t flags; + uint32_t reserved0; + uint32_t reserved1; + uint8_t sha256_img_sig[SHA256_SUM_LEN]; +}; + +#define SIG_HEADER_LEN (sizeof(struct sig_header_s)) + /** * image_pre_load() - Manage pre load header * diff --git a/tools/image-host.c b/tools/image-host.c index 698adfb3e1..0bf18df50e 100644 --- a/tools/image-host.c +++ b/tools/image-host.c @@ -17,8 +17,6 @@ #include #include -#define IMAGE_PRE_LOAD_PATH "/image/pre-load/sig" - /** * fit_set_hash_value - set hash value in requested has node * @fit: pointer to the FIT format image header