From patchwork Fri Apr 8 20:08:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1615064 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=seco.com header.i=@seco.com header.a=rsa-sha256 header.s=selector1 header.b=nj/prjoH; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KZq8P0hsMz9sFy for ; Sat, 9 Apr 2022 06:09:09 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6549583934; Fri, 8 Apr 2022 22:08:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.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=seco.com header.i=@seco.com header.b="nj/prjoH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E41DC83919; Fri, 8 Apr 2022 22:08:56 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2062a.outbound.protection.outlook.com [IPv6:2a01:111:f400:7d00::62a]) (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 1B9CC83994 for ; Fri, 8 Apr 2022 22:08:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sean.anderson@seco.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lG+h1FgwBeCR1oisIl6TfdPd6tTa+Nkc/93Jg4KLdmteqrNC19gMZOPFCi3zdqBky7ysoF1wAOMRtssTjFgpjy+5CjJQ4vImaWSF4Uz3+aA1kVlvhabeHiU/zUQoY0V6qNccfavu4tHT58akTCY5LTsg2y0ZzbwAIyCb2rFNnHRQ/NT00FELfU4afwEYUP226uQXgx5iWX04smQYvSoy7A0EzdJfWuxwHAJYmElfqwalHrDOk6LGR4QI4GuvxRMXmxRkoPN5vt7zUpZ1rcwmvFaDi3eS2PQ6XJoN9t9sn369Sf94FVxRu++XV/+gCKn/G0hcGXFqH2QRvCA9hyuaMQ== 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=eSCg/B3i1rEoe5fXxms57O/08iYcrj9yFnKooXTlka8=; b=jWqExdaTriPK7MEz1x33u7f+iqUlHnfD0XtBB8bUs4GHM/M6mWfFQJJb+f/SLE1jEW+RM8HEBH0vBfd40GPxoUODKNtzF7u8VvH0M3Zsf2i5q01HXUFIQtRlt/e7TRBDR17Mrr/6MPSWyR5kWADY6WLTB5g3oB1VljIsdPJ/ThgTUf6X5CX4K0joGmrt5HedD2KBf5c74FheRdm1pJHBM+T0/a6CRGTq5SIQX3GpLgIL6SxopvI/vLm2HOQpTHPfQ++J8OGzpUvqJa971WAf5KmKQu7uB6celtw7tpZUtPFPki26FNyyZ5GaHDaH9ZQfuXiBXfltRyQjqUQsG98pcw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seco.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eSCg/B3i1rEoe5fXxms57O/08iYcrj9yFnKooXTlka8=; b=nj/prjoHjLKkxidBgim2B5LuCwTDBSzldjGH/OkFPLBivvZfMX+eal/njdYd/O00ldrC+tLgxZVFbuc6KnuNcO+16STcugHh5FBq46SWJNqb474j07jo3Eme58Ki4z2WUKwHSC+8MRTS5HziQQAkTjuclqWESF32L6+PR6cf497cuPTBs3qF8R8zVL4NC9Rze/nobgceFmt3PzGmD5Ers5x7L9QNp1g6aiXF7QwuuhqQkJF3glBozw6/ZcMFFDhwXDtPtRUGYERRObdA3ekrM3zhMv8UIevSu3ZvhaKsIg4oRaVDWeUVj/V7x9ZXvEgt3E6iR/yuqxUpfaC2zARRMQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) by AS4PR03MB8577.eurprd03.prod.outlook.com (2603:10a6:20b:584::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.31; Fri, 8 Apr 2022 20:08:50 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::fd2d:a04b:de07:33f8]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::fd2d:a04b:de07:33f8%6]) with mapi id 15.20.5144.023; Fri, 8 Apr 2022 20:08:50 +0000 From: Sean Anderson To: Simon Glass , u-boot@lists.denx.de Cc: Heinrich Schuchardt , Sean Anderson Subject: [PATCH 1/2] mkimage: Document misc options Date: Fri, 8 Apr 2022 16:08:39 -0400 Message-Id: <20220408200841.2281918-1-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty X-ClientProxiedBy: MN2PR19CA0027.namprd19.prod.outlook.com (2603:10b6:208:178::40) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 538e0436-a77b-4ea9-bfd7-08da199b9900 X-MS-TrafficTypeDiagnostic: AS4PR03MB8577:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WvzxpgY7cF+zbHPO0ub/2IxbbzAEI/+z7WwwmFXXouTW1f54osYNYrcn3iUFCdfkQ3ZVeYuIfSxbzzfFMkMRUHXJ0K2Ip/dPqYblsWAdAPbRSZXZbDYap9+54IjH0Lbqdi71jsv5lkw6RBM4+JJxmMwU5B28iAoqo7RjVHvfp0/WJNZwJDAxSlcNCWPuh5rAVPX++AwzAYYo4fPGJa4NNOHsvOwXDLiLcZTgb/DMoXoGP6ThlA6tVGLRetTujaOc93/xETfG7zV9UAYlglXBchc2sqtXJ+D13tPeyRtGKOp4J0SJtS/ibWUzJKLgdgAfADtJZKMU1HX80R4pRnQ1YvVZTJ82aO4+77OWZwfbJbKSw/+9C0NiKeHgGFMr1Yfh1Fl9sjRaQgSvCUB+n+MWcjCNC88PBTtQDjEH3AerjTPz+7e8osQd/B3OU8kbhm3xEXCJnXqnF/+gNdYlXh47EANP72BLfY7fzdzPqufS7QHkyR/b3nl9ZpHnaSkd2K0fy5fWHW/DoFXAbKNVEqmBWuyXE1bwy7iOt5Y1KRVbqVSLekJ7dA1+r0G9hd0dJblPgkzTXAiKHbkpmFutVeY7NEeupLIWtlvu6KwRIuWCuyADK6QQhteyVPTHZTUiR8nr+FG8DtmzKvUYGfLNb7NAXMrinkGW814Uqx2QhdVAwpzAA/H/h+rFcI6JKn/j6ygp8RQdauZn4YynOSUcbTc5+g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR03MB4972.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(38350700002)(8936002)(52116002)(5660300002)(6512007)(66556008)(6486002)(2906002)(6506007)(186003)(508600001)(44832011)(83380400001)(36756003)(38100700002)(4326008)(1076003)(107886003)(66476007)(2616005)(54906003)(316002)(26005)(86362001)(8676002)(6666004)(66946007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9jSc000Xg/4K081pFFSeMgKjx+4EfN6oKzFRYqpmXMeSkqEErnXpLFgpoFNyk+ECES+ThTnQknRCKcu1nGpIRer5O7FGUnFLk/woUe4H4880dec13l0bDWUZbXKTGSK/DebcCEccKMV0KPN4SE0vmvPdcEbUsB9C5QnmNkEOiOqGOIGYP4ikKVGbcHZJXR1tt/qG4zJiZ4ckZRstJLEi0TSGOar9MIWeth+96u8yNZk1hkLzmqeRLdLjcBH9waqDPgHN03Tnq0zXDUpx8JbVZIBai5SLEaE9ZZfivt6lgZmLIF1Qse1dY96hwImYUCfOwujWDMs8v/V9WvFAoszzTa5FUd+QMsnlQsBj3wPtAjHEL67JA6hzfjGzIMNjiXib3mDPLOo5Vl84tudbv0Yx3745mdm0u+1QBxl/pD4dQ1rpFN49jv4MhX1l3LVEb3lnH4fsBlYYA7iV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2ywRtiu5AXOhq++tFf5OV2+tkyRUubAPq6s4Hb84CqVRG3FsnlcDxKtFlZNoT5GWj50GSO5RkyWvSddtMJ7T4VNVHlkGIWhMTc/cn6gMsbQLVh4evKHOi1KaMg5IIJHD4GzO4V8b+DHTh7oreODar3wJZzRUocsnkmt/ZqxugbbjLVIE6aWH7OZm9OsDpJHhAQU2HPNCSurKYKyFV6RPqBlCZZshx+w= X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 538e0436-a77b-4ea9-bfd7-08da199b9900 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2022 20:08:50.5184 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: eCwS7nUZ0+/QJ9OXfgvu4kOO4o2Edt4/+agS4pyVVr+P2v346UfJQGClsU4b1+5f/wgBwkO5pK3FlqZjJUiVyA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR03MB8577 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.5 at phobos.denx.de X-Virus-Status: Clean Over the years, several options have not made it into the help message. Document them. Do the same for the man page. Signed-off-by: Sean Anderson --- doc/mkimage.1 | 36 +++++++++++++++++++++++++++++++++++- tools/mkimage.c | 15 +++++++++++---- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/doc/mkimage.1 b/doc/mkimage.1 index 287006279f..c92e133732 100644 --- a/doc/mkimage.1 +++ b/doc/mkimage.1 @@ -53,6 +53,10 @@ Parse image file as type. Pass \-h as the image to see the list of supported image type. Without this option image type is autodetected. +.TP +.BI "\-q" +Quiet. Don't print the image header on successful verification. + .P .B Create old legacy image: @@ -91,6 +95,11 @@ List the contents of an image. .BI "\-n [" "image name" "]" Set image name to 'image name'. +.TP +.BI "\-R [" "secondary image name" "]" +Some image types support a second image for additional data. For these types, +use \-R to specify this second image. + .TP .BI "\-d [" "image data file" "]" Use image data from 'image data file'. @@ -99,6 +108,15 @@ Use image data from 'image data file'. .BI "\-x" Set XIP (execute in place) flag. +.TP +.BI "\-s" +Create an image with no data. The header will be created, but the image itself +will not contain data (such as U-Boot or any specified kernel). + +.TP +.BI "\-v" +Verbose. Print file names as they are added to the image. + .P .B Create FIT image: @@ -126,6 +144,11 @@ in each image will be replaced with 'data-offset' and 'data-size' properties. A 'data-offset' of 0 indicates that it starts in the first (4-byte aligned) byte after the FIT. +.TP +.BI "\-B [" "alignment" "]" +The alignment, in hexadecimal, that external data will be aligned to. This +option only has an effect when \-E is specified. + .TP .BI "\-f [" "image tree source file" " | " "auto" "]" Image tree source file that describes the structure and contents of the @@ -161,6 +184,11 @@ the corresponding public key is written into this file for for run-time verification. Typically the file here is the device tree binary used by CONFIG_OF_CONTROL in U-Boot. +.TP +.BI "\-G [" "key_file" "]" +Specifies the private key file to use when signing. This option may be used +instead of \-k. + .TP .BI "\-o [" "signing algorithm" "]" Specifies the algorithm to be used for signing a FIT image. The default is @@ -173,11 +201,17 @@ a 'data-offset' property defining the offset from the end of the FIT, \-p will use 'data-position' as the absolute position from the base of the FIT. .TP -.BI "\-r +.BI "\-r" Specifies that keys used to sign the FIT are required. This means that they must be verified for the image to boot. Without this option, the verification will be optional (useful for testing but not for release). +.TP +.BI "\-N [" "engine" "]" +The openssl engine to use when signing and verifying the image. For a complete list of +available engines, refer to +.BR engine (1). + .TP .BI "\-t Update the timestamp in the FIT. diff --git a/tools/mkimage.c b/tools/mkimage.c index 74bd072832..c12d5932fc 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -84,7 +84,8 @@ static void usage(const char *msg) fprintf(stderr, "Error: %s\n", msg); fprintf(stderr, "Usage: %s [-T type] -l image\n" " -l ==> list image header information\n" - " -T ==> parse image file as 'type'\n", + " -T ==> parse image file as 'type'\n" + " -q ==> quiet\n", params.cmdname); fprintf(stderr, " %s [-x] -A arch -O os -T type -C comp -a addr -e ep -n name -d data_file[:data_file...] image\n" @@ -95,8 +96,11 @@ static void usage(const char *msg) " -a ==> set load address to 'addr' (hex)\n" " -e ==> set entry point to 'ep' (hex)\n" " -n ==> set image name to 'name'\n" + " -R ==> set second image name to 'name'\n" " -d ==> use image data from 'datafile'\n" - " -x ==> set XIP (execute in place)\n", + " -x ==> set XIP (execute in place)\n" + " -s ==> create an image with no data\n" + " -v ==> verbose\n", params.cmdname); fprintf(stderr, " %s [-D dtc_options] [-f fit-image.its|-f auto|-F] [-b [-b ]] [-E] [-B size] [-i ] fit-image\n" @@ -107,7 +111,9 @@ static void usage(const char *msg) " -f => input filename for FIT source\n" " -i => input filename for ramdisk file\n" " -E => place data outside of the FIT structure\n" - " -B => align size in hex for FIT structure and header\n"); + " -B => align size in hex for FIT structure and header\n" + " -b => append the device tree binary to the FIT\n" + " -t => update the timestamp in the FIT\n"); #ifdef CONFIG_FIT_SIGNATURE fprintf(stderr, "Signing / verified boot options: [-k keydir] [-K dtb] [ -c ] [-p addr] [-r] [-N engine]\n" @@ -118,7 +124,8 @@ static void usage(const char *msg) " -F => re-sign existing FIT image\n" " -p => place external data at a static position\n" " -r => mark keys used as 'required' in dtb\n" - " -N => openssl engine to use for signing\n"); + " -N => openssl engine to use for signing\n" + " -o => algorithm to use for signing\n"); #else fprintf(stderr, "Signing / verified boot not supported (CONFIG_FIT_SIGNATURE undefined)\n"); From patchwork Fri Apr 8 20:08:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1615065 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=seco.com header.i=@seco.com header.a=rsa-sha256 header.s=selector1 header.b=cFdUnlyp; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KZq8d305Fz9sFy for ; Sat, 9 Apr 2022 06:09:21 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8873183DA5; Fri, 8 Apr 2022 22:09:12 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.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=seco.com header.i=@seco.com header.b="cFdUnlyp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DB12B83AFF; Fri, 8 Apr 2022 22:09:02 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2062a.outbound.protection.outlook.com [IPv6:2a01:111:f400:7d00::62a]) (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 591FF83B39 for ; Fri, 8 Apr 2022 22:08:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sean.anderson@seco.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NIcIusYg2n94GySr09EJKajEsIWcBZyIim1Cd8CVwJQNeKc7NV8TSQ+SC5LyOHJHJP7iWSPQUrVdkI7innRkl9Cj4PIXCgs/JPuXYl8wnH1ZlNOZCod1mo+ABhZ4+5n8FDbzQhPNHI5RbsLMcV/gxuSS2Kvg/3rgVyv/Hc6qF9RTQVYPpy/IwROA/WmAd74mwhOcjlauK/uBXklTRenBpN7/FdQBYAWNBCvAD9VATQnHRq+5S2uQL2KfSJEo83t0mQ2WIYS7XKNayIllK6wS4g1/MH8cHqe2l4y7B7CQkaEuWZhlQ01rFekzvajCFudDu9lt5nEFxWRB9b2yPTuEvg== 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=D+6q/GVCjExDT4EJG8R2yJCcI1IomvmIrG2p6BJ2CNE=; b=nZ9upJk3KYEPK5iwXRO7vf7iv8tp9wgctJop3D4D5ZCnrqZb8goh+zMLOmrJ1FnBzgpJU0ipaxEnj249UmfuBYmz4srlSDYXTEt/OQr51JKd4DEpi6onL8Alkmt/Z2kv56JZCLNYD0nWDRmBfN4R3XSEgVt9yqCdTuTXtQbKxTi488K96fw9SBkE0mGPVP9RDoyAy21N7WhYFUPsNCo93XOFWH/4H1JD60fVG3dDd1pk4VTpiaNyAMa8MYheYULTJ7qusiCXH4LU4bDTngpC3Sm3K7WIrkQIvTiI11i22YgdbqnFUoavbTJoxiEg9nEfRwsBV3kQ+us0c4r5C0FRAQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seco.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=D+6q/GVCjExDT4EJG8R2yJCcI1IomvmIrG2p6BJ2CNE=; b=cFdUnlypck5ZQBo0NU4RiQS47iDhnpNN94ebh8CDkzESMp57P2aKWLBzrH8ntnyp/4aRSGy3Hq6QNpB+88KvKTDLpKdAQClcIIUF4hl6gtuOiAN83Id7wV+e3m18qgIgNiewytm35sntI3gMj8sfTjbjTosTEnoBWdbFx3vQ4R1s5YMrZNt9xVXlBzlHZp8wkR/H3kvlBjzFDSES2OdN/Afh25ZuS2Sn/8CyGb9k/EESIbshT6ZMMAdr3UMVWUWfC/3EguFNRANfySkXF/W1B9HZzCBZEDm+cF/HkVlOsRy3ob8AJRjmYHAJ8bC1Hp2pJLBGcjHp1CswLii7TMUcKA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) by AS4PR03MB8577.eurprd03.prod.outlook.com (2603:10a6:20b:584::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.31; Fri, 8 Apr 2022 20:08:51 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::fd2d:a04b:de07:33f8]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::fd2d:a04b:de07:33f8%6]) with mapi id 15.20.5144.023; Fri, 8 Apr 2022 20:08:51 +0000 From: Sean Anderson To: Simon Glass , u-boot@lists.denx.de Cc: Heinrich Schuchardt , Sean Anderson Subject: [PATCH 2/2] mkimage: Support signing 'auto' FITs Date: Fri, 8 Apr 2022 16:08:40 -0400 Message-Id: <20220408200841.2281918-2-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220408200841.2281918-1-sean.anderson@seco.com> References: <20220408200841.2281918-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR19CA0027.namprd19.prod.outlook.com (2603:10b6:208:178::40) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 419ca705-d43b-4869-c7ff-08da199b99ae X-MS-TrafficTypeDiagnostic: AS4PR03MB8577:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 73CyFT9oPahiTj1kbVyS6fnjip6FzEfitUqQgspskrcGZpNqTMlf0mUCRjlApNoa+jeR4cuKZBvEnjTjqu4Iv6wF6TwFImv0ISJcAW/i7riMUXEw3564Lcs2rB5g3NuZnvYugFRBZQ/ivJawy6xaT0cWEG19Fh7c+ulfcOtMlK8ciioiw+sPGwAFBF8GMKSI39aFomSD4jKjY21Ks28OFEOkOVdP+ONW+W+roYIjkHUclmliBbWGIeuIdhu9PUQX9ZBXimkCJjEKCUBwhP0ys27z4qLM0zVpyMrM6qhlwILMTwjdTknm/d8jBeAEHdjXXws2IG3F5NrBh/e90NfIk3FPDqjH2K0+/pwkEhxQkHD88P92upwaexUuN0Sma0llNBh3Vx6BDPzREEJqGIPhfCrjDYKXSeYaZe34IpUP3LgQB0svjFvpbvkJx7ARLH7nyjVKEkRZh7KV7r2C2LLZDI73Te3FPxidpaDnJr6zPIny+D1UWtWcLqLUxrh85tad1gCrgJWMRPLWivWN0IuCZ1kXS1YWKa02PIFwRl7MEZ09svOc66Ntsj13ZCZBoK3iOYNzS1IrgB2y+iUiY2ZbedwZcOjvBe1aD3kLlCoqPaTBfjy4ubI0yNw8NHSVmA/Y14UkSqg2coz9/PoqN11RB2P9hqpF7/tprrhJanIuBpD5nRx+BWKFiGCEzIit/ry3U5dT1Rk0nEWv7uhD2AokS5MRXSThEsBWhKnQaSn1UrN46kd2/Q9syZWFNDr3Wi6JHA+Pb/qz0uFaK3of+GQCl4wWWgq6cRVM6xYW7oG2KZY= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR03MB4972.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(38350700002)(966005)(8936002)(52116002)(5660300002)(6512007)(66556008)(6486002)(2906002)(6506007)(186003)(508600001)(44832011)(83380400001)(36756003)(38100700002)(4326008)(1076003)(107886003)(66476007)(2616005)(54906003)(316002)(26005)(86362001)(8676002)(6666004)(66946007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ok2AP4xhfBk2ph4pkUAPkr7wc+RMccbQhJlsDZT6PCqLjYkcjxWiA387qMxbkIh7bzNXz74eh5QiX1dXulvjdzmP6qgwYEs6I2ECEUfpmwLVfQymmJZ6P/oW84hoaGGgr5CG6h2p05VaLlMW3om/w/8XkXZflGS8dKn6xRLMZ5Nk1IndVKf02JfLlkGN5JUiSSGXMR8ddgayhSDCspE/5hFyjmjZTqgE7QkJKCat9fZQTzpB1U/rciH/9mEB04dPlz4lEHoaN6JmTEZFLaCsrnzL/hpf6c20LTYNM/rDFaxhBOhPU5nfFQ1EfkBdSOiMBdvSeb4IP8CoTn43WqcTwj5Xq8LW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eMyDgN42YzZMSVtUb73DY85+7DgkiSm2ZJFJ7nQjVLrethx/x0gwPBpwp3TGRdTfelwTrH1lantetCsnnfLHXb2/n2Zn7P16u/3mp0MDqQ0VNQdhNuP2OfLQtxUDxoEapCWBKtBigC+5OYNr08pHDrclpWO8gmfgoSUmwA75CZEZcegFXvQHGrfMAKK+j8j1n9irwvxUSPMPcpcf+zqLs78ujAUP+GRtwgkM8SjMDQbe+wbLADepwhJgbCs9cbXNPGtNS0H2wblXexzef7StOuqoMDdiPpnWl63H/nX+OI53qW5H+BQxj7qYfRZjQwcjmUuiog3clOkWCbLa1Q14YbsloQ= X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 419ca705-d43b-4869-c7ff-08da199b99ae X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2022 20:08:51.6590 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UGI0Z+hmZhXbjMGir03QjKeD6sRjm72d7G4I1qtzf2lLi8m8t99G21v1TZmg3hdAOuP0Er9A9sb5nl8TDplgTg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR03MB8577 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.5 at phobos.denx.de X-Virus-Status: Clean This adds support for signing images in auto-generated FITs. To do this, we need to add a signature node. The algorithm name property already has its own option, but we need one for the key name hint. We could have gone the -G route and added an explicit name for the public key (like what is done for the private key). However, many places assume the public key can be constructed from the key dir and hint, and I don't want to do the refactoring necessary. As a consequence of this, it is now easier to add public keys to an existing image without signing something. This could be done all along, but now you don't have to create an its just to do it. Ideally, we wouldn't create a FIT at the end. This could be done by calling fit_image_setup_sig/info.crypto->add_verify_data directly. Signed-off-by: Sean Anderson --- doc/mkimage.1 | 24 ++++++++++++++++++++++++ tools/fit_image.c | 41 ++++++++++++++++++++++++++++++++++------- tools/imagetool.h | 1 + tools/mkimage.c | 5 ++++- 4 files changed, 63 insertions(+), 8 deletions(-) diff --git a/doc/mkimage.1 b/doc/mkimage.1 index c92e133732..60853ec3e6 100644 --- a/doc/mkimage.1 +++ b/doc/mkimage.1 @@ -184,6 +184,13 @@ the corresponding public key is written into this file for for run-time verification. Typically the file here is the device tree binary used by CONFIG_OF_CONTROL in U-Boot. +.TP +.BI "\-g [" "key_name_hint" "]" +Sets the key-name-hint property when used with \-f auto. This is the +part of the key. The directory part is set by \-k. This option also indicates +that the images included in the FIT should be signed. If this option is +specified, \-o must be specified as well. + .TP .BI "\-G [" "key_file" "]" Specifies the private key file to use when signing. This option may be used @@ -249,6 +256,15 @@ skipping those for which keys cannot be found. Also add a comment. .B -c """Kernel 3.8 image for production devices""" kernel.itb .fi +.P +Add public keys to u-boot.dtb without needing a FIT to sign. This will also +create a FIT containing an images node with no data named unused.itb. +.nf +.B mkimage -f auto -d /dev/null -k /public/signing-keys -g dev \\\\ +.br +.B -o sha256,rsa2048 -K u-boot.dtb unused.itb +.fi + .P Update an existing FIT image, signing it with additional keys. Add corresponding public keys into u-boot.dtb. This will resign all images @@ -277,6 +293,14 @@ automatic mode. No .its file is required. .B -c """Kernel 4.4 image for production devices""" -d vmlinuz \\\\ .B -b /path/to/rk3288-firefly.dtb -b /path/to/rk3288-jerry.dtb kernel.itb .fi +.P +Create a FIT image containing a signed kernel, using automatic mode. No .its +file is required. +.nf +.B mkimage -f auto -A arm -O linux -T kernel -C none -a 43e00000 -e 0 \\\\ +.br +.B -d vmlinuz -k /secret/signing-keys -g dev -o sha256,rsa2048 kernel.itb +.fi .SH HOMEPAGE http://www.denx.de/wiki/U-Boot/WebHome diff --git a/tools/fit_image.c b/tools/fit_image.c index 0d5a6a28f9..48fc1f5579 100644 --- a/tools/fit_image.c +++ b/tools/fit_image.c @@ -199,15 +199,36 @@ static void get_basename(char *str, int size, const char *fname) } /** - * add_crc_node() - Add a hash node to request a CRC checksum for an image + * add_hash_node() - Add a hash or signature node * + * @params: Image parameters * @fdt: Device tree to add to (in sequential-write mode) + * + * If there is a key name hint, try to sign the images. Otherwise, just add a + * CRC. + * + * Return: 0 on success, or -1 on failure */ -static void add_crc_node(void *fdt) +static int add_hash_node(struct image_tool_params *params, void *fdt) { - fdt_begin_node(fdt, "hash-1"); - fdt_property_string(fdt, FIT_ALGO_PROP, "crc32"); + if (params->keyname) { + if (!params->algo_name) { + fprintf(stderr, + "%s: Algorithm name must be specified\n", + params->cmdname); + return -1; + } + + fdt_begin_node(fdt, "signature-1"); + fdt_property_string(fdt, FIT_ALGO_PROP, params->algo_name); + fdt_property_string(fdt, FIT_KEY_HINT, params->keyname); + } else { + fdt_begin_node(fdt, "hash-1"); + fdt_property_string(fdt, FIT_ALGO_PROP, "crc32"); + } + fdt_end_node(fdt); + return 0; } /** @@ -248,7 +269,9 @@ static int fit_write_images(struct image_tool_params *params, char *fdt) ret = fdt_property_file(params, fdt, FIT_DATA_PROP, params->datafile); if (ret) return ret; - add_crc_node(fdt); + ret = add_hash_node(params, fdt); + if (ret) + return ret; fdt_end_node(fdt); /* Now the device tree files if available */ @@ -271,7 +294,9 @@ static int fit_write_images(struct image_tool_params *params, char *fdt) genimg_get_arch_short_name(params->arch)); fdt_property_string(fdt, FIT_COMP_PROP, genimg_get_comp_short_name(IH_COMP_NONE)); - add_crc_node(fdt); + ret = add_hash_node(params, fdt); + if (ret) + return ret; fdt_end_node(fdt); } @@ -289,7 +314,9 @@ static int fit_write_images(struct image_tool_params *params, char *fdt) params->fit_ramdisk); if (ret) return ret; - add_crc_node(fdt); + ret = add_hash_node(params, fdt); + if (ret) + return ret; fdt_end_node(fdt); } diff --git a/tools/imagetool.h b/tools/imagetool.h index 5169b0245d..a022e23389 100644 --- a/tools/imagetool.h +++ b/tools/imagetool.h @@ -70,6 +70,7 @@ struct image_tool_params { const char *keydir; /* Directory holding private keys */ const char *keydest; /* Destination .dtb for public key */ const char *keyfile; /* Filename of private or public key */ + const char *keyname; /* Key name "hint" */ const char *comment; /* Comment to add to signature node */ /* Algorithm name to use for hashing/signing or NULL to use the one * specified in the its */ diff --git a/tools/mkimage.c b/tools/mkimage.c index c12d5932fc..329e0cf924 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -119,6 +119,7 @@ static void usage(const char *msg) "Signing / verified boot options: [-k keydir] [-K dtb] [ -c ] [-p addr] [-r] [-N engine]\n" " -k => set directory containing private keys\n" " -K => write public keys to this .dtb file\n" + " -g => set key name hint\n" " -G => use this signing key (in lieu of -k)\n" " -c => add comment in signature node\n" " -F => re-sign existing FIT image\n" @@ -163,7 +164,7 @@ static void process_args(int argc, char **argv) int opt; while ((opt = getopt(argc, argv, - "a:A:b:B:c:C:d:D:e:Ef:FG:k:i:K:ln:N:p:o:O:rR:qstT:vVx")) != -1) { + "a:A:b:B:c:C:d:D:e:Ef:Fg:G:k:i:K:ln:N:p:o:O:rR:qstT:vVx")) != -1) { switch (opt) { case 'a': params.addr = strtoull(optarg, &ptr, 16); @@ -238,6 +239,8 @@ static void process_args(int argc, char **argv) params.type = IH_TYPE_FLATDT; params.fflag = 1; break; + case 'g': + params.keyname = optarg; case 'G': params.keyfile = optarg; break;