Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D7007C001B3 for ; Fri, 23 Jun 2023 12:25:00 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B1CBB865C9; Fri, 23 Jun 2023 14:24:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="oH07rUHL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2625D8638B; Fri, 23 Jun 2023 14:23:15 +0200 (CEST) Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 017A3863C2 for ; Fri, 23 Jun 2023 14:22:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-311394406d0so566875f8f.2 for ; Fri, 23 Jun 2023 05:22:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1687522975; x=1690114975; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UE46iOV+pJSylE1P0IOrzRoO4A+L6fB7oxI5f2abZdk=; b=oH07rUHL07ZJ/SQQ6R9tdZwZE/v+muxlGPrck8NwPEw3xkHn1rYIWpw4EdL3RCZBgA FD5HfB3LtrfOGedBlFNH0EMHeB2yf/Yp4UO7Az6BLLhpS9AaLHTINqyLRmPOz4pa47J/ OWHSZQWdDPWukQ93DV1M8EbwIiuvWOFXyGNbA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687522975; x=1690114975; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UE46iOV+pJSylE1P0IOrzRoO4A+L6fB7oxI5f2abZdk=; b=Mazz5BfXMhjRJnfanzQdsctD9SA+wAOSyHGz5U0vYbvOV83KPA8MpYtHtVsyWY7vLi gFf8H8uKBfzQifIaVCHzrATuNx04O2dbEAEg/yx+Nag7KzKpqzbZw+Qfjbt29fj7ZQZT JOfQujFVmlAL36TLjvIZMQlmoQaS2NiACocmxRrFKA8M43N+dtsEc0LSW30T6ywfxDUC Jwpk2iqy1tP/UqxzF37aJ7uxBm2cNSabudhliYGUVNpGDRQMi71ha7agJfREudkIOJMh oMZb+xhUXs5I9m0QLvIFKvfIgzLvpvNyr19GeCb8ziTQYZ1OioS7JXZejum2LpHtz2nq D3fw== X-Gm-Message-State: AC+VfDwSiAdqOLZFm2MtR4VWoHxCXRjYHJZ+7t4qqQycbC9exW35tSF8 pwruEiYt2bs5DVxmPNTjTAQeqyLxbRAirQluL0UoPw== X-Google-Smtp-Source: ACHHUZ516QFMfxnC1mNW7P0mapd/FYFv3ZlCDY/dUZtTxS50ec6oytbLV/NTw7sMMP3LSYUp2CdQqA== X-Received: by 2002:a5d:44c6:0:b0:307:83a4:3d3b with SMTP id z6-20020a5d44c6000000b0030783a43d3bmr13527471wrr.54.1687522975143; Fri, 23 Jun 2023 05:22:55 -0700 (PDT) Received: from sjg1.roam.corp.google.com (ip-185-104-136-50.ptr.icomera.net. [185.104.136.50]) by smtp.gmail.com with ESMTPSA id c11-20020a056000104b00b003063a92bbf5sm9499866wrx.70.2023.06.23.05.22.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Jun 2023 05:22:54 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Tom Rini , Simon Glass Subject: [PATCH v2 12/14] doc: Add signing to the FIT spec Date: Fri, 23 Jun 2023 13:22:12 +0100 Message-ID: <20230623122222.2267003-12-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog In-Reply-To: <20230623122222.2267003-1-sjg@chromium.org> References: <20230623122222.2267003-1-sjg@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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.8 at phobos.denx.de X-Virus-Status: Clean Move this properties into the main spec. Signed-off-by: Simon Glass --- (no changes since v1) doc/usage/fit/signature.rst | 64 ------------ doc/usage/fit/source_file_format.rst | 147 ++++++++++++++++++++++++++- 2 files changed, 146 insertions(+), 65 deletions(-) diff --git a/doc/usage/fit/signature.rst b/doc/usage/fit/signature.rst index 7d8292ece867..0804bffd1edc 100644 --- a/doc/usage/fit/signature.rst +++ b/doc/usage/fit/signature.rst @@ -82,70 +82,6 @@ If you like you can look at the public key also:: $ openssl rsa -in keys/dev.key -pubout -Device Tree Bindings --------------------- -The following properties are required in the FIT's signature node(s) to -allow the signer to operate. These should be added to the .its file. -Signature nodes sit at the same level as hash nodes and are called -signature-1, signature-2, etc. - -algo - Algorithm name (e.g. "sha1,rsa2048") - -key-name-hint - Name of key to use for signing. The keys will normally be in - a single directory (parameter -k to mkimage). For a given key , its - private key is stored in .key and the certificate is stored in - .crt. - -When the image is signed, the following properties are added (mandatory): - -value - The signature data (e.g. 256 bytes for 2048-bit RSA) - -When the image is signed, the following properties are optional: - -timestamp - Time when image was signed (standard Unix time_t format) - -signer-name - Name of the signer (e.g. "mkimage") - -signer-version - Version string of the signer (e.g. "2013.01") - -comment - Additional information about the signer or image - -padding - The padding algorithm, it may be pkcs-1.5 or pss, - if no value is provided we assume pkcs-1.5 - -For config bindings (see Signed Configurations below), the following -additional properties are optional: - -sign-images - A list of images to sign, each being a property of the conf - node that contains then. The default is "kernel,fdt" which means that these - two images will be looked up in the config and signed if present. - -For config bindings, these properties are added by the signer: - -hashed-nodes - A list of nodes which were hashed by the signer. Each is - a string - the full path to node. A typical value might be:: - - hashed-nodes = "/", "/configurations/conf-1", "/images/kernel", - "/images/kernel/hash-1", "/images/fdt-1", - "/images/fdt-1/hash-1"; - -hashed-strings - The start and size of the string region of the FIT that was hashed - -Example: See :doc:`sign-images` for an example image tree source file and -sign-configs.its for config signing. - - Public Key Storage ------------------ In order to verify an image that has been signed with a public key we need to diff --git a/doc/usage/fit/source_file_format.rst b/doc/usage/fit/source_file_format.rst index f1cc1bc4931c..1f6c33834b6a 100644 --- a/doc/usage/fit/source_file_format.rst +++ b/doc/usage/fit/source_file_format.rst @@ -385,6 +385,10 @@ hash-1 Each hash sub-node represents separate hash or checksum calculated for node's data according to specified algorithm. +signature-1 + Each signature sub-node represents separate signature + calculated for node's data according to specified algorithm. + Hash nodes ---------- @@ -418,6 +422,91 @@ algo value Actual checksum or hash value. +Image-signature nodes +--------------------- + +:: + + o signature-1 + |- algo = "algorithm name" + |- key-name-hint = "key name" + |- value = [hash or checksum value] + + +Mandatory properties +~~~~~~~~~~~~~~~~~~~~ + +_`FIT Algorithm`: + +algo + Algorithm name. Supported algoriths and their value sizes are shown below. + Note that the hash is specified separately from the signing algorithm, so + it is possible to mix and match any SHA algorithm with any signing + algorithm. The size of the signature relates to the signing algorithm, not + the hash, since it is the hash that is signed. + + ==================== ============ ========================================= + Sub-image type Size (bytes) Meaning + ==================== ============ ========================================= + sha1,rsa2048 256 SHA1 hash signed with 2048-bit + Rivest–Shamir–Adleman algorithm + sha1,rsa3072 384 SHA1 hash signed with 2048-bit RSA + sha1,rsa4096 512 SHA1 hash signed with 2048-bit RSA + sha1,ecdsa256 32 SHA1 hash signed with 256-bit Elliptic + Curve Digital Signature Algorithm + sha256,... + sha384,... + sha512,... + ==================== ============ ========================================= + +key-name-hint + Name of key to use for signing. The keys will normally be in + a single directory (parameter -k to mkimage). For a given key , its + private key is stored in .key and the certificate is stored in + .crt. + +sign-images + A list of images to sign, each being a property of the conf + node that contains then. The default is "kernel,fdt" which means that these + two images will be looked up in the config and signed if present. This is + used by mkimage to determine which images to sign. + +The following properies are added as part of signing, and are mandatory: + +value + Actual signature value. This is added by mkimage. + +hashed-nodes + A list of nodes which were hashed by the signer. Each is + a string - the full path to node. A typical value might be:: + + hashed-nodes = "/", "/configurations/conf-1", "/images/kernel", + "/images/kernel/hash-1", "/images/fdt-1", + "/images/fdt-1/hash-1"; + +hashed-strings + The start and size of the string region of the FIT that was hashed. The + start is normally 0, indicating the first byte of the string table. The size + indicates the number of bytes hashed as part of signing. + +The following properies are added as part of signing, and are optional: + +timestamp + Time when image was signed (standard Unix time_t format) + +signer-name + Name of the signer (e.g. "mkimage") + +signer-version + Version string of the signer (e.g. "2013.01") + +comment + Additional information about the signer or image + +padding + The padding algorithm, it may be pkcs-1.5 or pss, + if no value is provided we assume pkcs-1.5 + '/configurations' node ---------------------- @@ -447,6 +536,13 @@ Mandatory nodes configuration-sub-node-unit-name At least one of the configuration sub-nodes is required. +Optional nodes +~~~~~~~~~~~~~~ + +signature-1 + Each signature sub-node represents separate signature + calculated for the configuration according to specified algorithm. + Configuration nodes ------------------- @@ -460,7 +556,7 @@ Each configuration has the following structure:: |- loadables = "loadables sub-node unit-name" |- script = " |- compatible = "vendor,board-style device tree compatible string" - + o signature-1 {...} Mandatory properties ~~~~~~~~~~~~~~~~~~~~ @@ -512,6 +608,55 @@ Older, 2.4 kernel and 2.6 non-FDT kernel do not use FDT blob, in such cases 'struct bd_info' must be passed instead of FDT blob, thus fdt property *must not* be specified in a configuration node. +Configuration-signature nodes +----------------------------- + +:: + + o signature-1 + |- algo = "algorithm name" + |- key-name-hint = "key name" + |- sign-images = "path1", "path2"; + |- value = [hash or checksum value] + |- hashed-strings = <0 len> + + +Mandatory properties +~~~~~~~~~~~~~~~~~~~~ + +algo + See `FIT Algorithm`_. + +key-name-hint + Name of key to use for signing. The keys will normally be in + a single directory (parameter -k to mkimage). For a given key , its + private key is stored in .key and the certificate is stored in + .crt. + +The following properies are added as part of signing, and are mandatory: + +value + Actual signature value. This is added by mkimage. + +The following properies are added as part of signing, and are optional: + +timestamp + Time when image was signed (standard Unix time_t format) + +signer-name + Name of the signer (e.g. "mkimage") + +signer-version + Version string of the signer (e.g. "2013.01") + +comment + Additional information about the signer or image + +padding + The padding algorithm, it may be pkcs-1.5 or pss, + if no value is provided we assume pkcs-1.5 + + Examples -------- -- 2.41.0.162.gfafddb0af9-goog