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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3883C433F5 for ; Fri, 12 Nov 2021 19:31:48 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6D4C360F41 for ; Fri, 12 Nov 2021 19:31:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6D4C360F41 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DE169830AE; Fri, 12 Nov 2021 20:30:28 +0100 (CET) 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="ZntpLIUy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 405F483070; Fri, 12 Nov 2021 20:29:29 +0100 (CET) Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) (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 7BC5183081 for ; Fri, 12 Nov 2021 20:29:07 +0100 (CET) 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-oi1-x22e.google.com with SMTP id 7so9613244oip.12 for ; Fri, 12 Nov 2021 11:29:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AGBUFDa1rY5dDLR3kQEtyXsrexdZhzfctPb5OcEWxAk=; b=ZntpLIUy0yXLubPfFbZeYhF0c9+NV2n5Z4HCOdBqdYn158p6+LDwT5iL4bxTDmmnb6 EgZ+GqW8GwvdpfUDz0xS6Sev1lfa1D6Dg4zBa+fdLz+XKnoDobI7YSS6m5V2fE8AfatA ey37tYXm4fousD90MXrjzJsZW2ZG5RCTqsrrs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AGBUFDa1rY5dDLR3kQEtyXsrexdZhzfctPb5OcEWxAk=; b=kr42n74BbuEWhw62L8gAEGLMJIaP2xFE0+/5bF8e7DehibpkU/9mpMezFSaX60eCTb Cmmak0B6f9FI+M/DGu0tHTJ3HCuJBHaBc9h14bPbinYLUvwRkRCDfTYZQuru4hIdcmNU aVm+eeHCAZSKS0xLLKBpdAu/4TnvkBR9Savh3V/sosbK1BazikRC/+srsRB6HaUoFuAB mGmHWscPGRxtUMd79ZOsKJVbs42x9ooU7PKTP9x91IxsGHJBr7UzTldYqEUP6fNoP+F+ 1xiA4ltDswZE9WIwxRc06whrEFA8FlCbWU0exHCRcIEWge56Aw1WJXTb2tLuB/n2l+qP +Oaw== X-Gm-Message-State: AOAM531Dt2sf94F/c61OXqybKxmGf84FpR7hp8OFOvl/sdTo36tWrA/g lwbtijCt6+n1LdDTOcPEwP7Jb63UnK0E5w== X-Google-Smtp-Source: ABdhPJwZnpdjhFBdsh89okbdpfmFFFI6scn6tnlCOj+AsFZmyGAKC5kDrKaKDGXRzgANSgnWm2WObg== X-Received: by 2002:a05:6808:23c3:: with SMTP id bq3mr14922646oib.124.1636745345845; Fri, 12 Nov 2021 11:29:05 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id n20sm1283527ooe.7.2021.11.12.11.29.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Nov 2021 11:29:05 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Rob Herring , Tom Rini , Bill Mills , Simon Glass Subject: [PATCH 16/16] tools: Add man pages for fdt_sign and fdt_check_sign Date: Fri, 12 Nov 2021 12:28:17 -0700 Message-Id: <20211112192817.199075-17-sjg@chromium.org> X-Mailer: git-send-email 2.34.0.rc1.387.gb447b232ab-goog In-Reply-To: <20211112192817.199075-1-sjg@chromium.org> References: <20211112192817.199075-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.35 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.2 at phobos.denx.de X-Virus-Status: Clean Add some documentation for these tools, along with a MAINTAINER entry. Signed-off-by: Simon Glass --- MAINTAINERS | 7 +++ doc/fdt_check_sign.1 | 74 +++++++++++++++++++++++++++++ doc/fdt_sign.1 | 111 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 192 insertions(+) create mode 100644 doc/fdt_check_sign.1 create mode 100644 doc/fdt_sign.1 diff --git a/MAINTAINERS b/MAINTAINERS index 00ff572d4d2..9f476d03eb0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -780,6 +780,13 @@ F: cmd/fdt.c F: common/fdt_support.c F: scripts/dtc-version.sh +FDT SIGNING +M: Simon Glass +S: Maintained +F: doc/fdt_*sign.1 +F: tools/fdt_check_sign.c +F: tools/fdt_sign.c + FREEBSD M: Rafal Jaworowski S: Maintained diff --git a/doc/fdt_check_sign.1 b/doc/fdt_check_sign.1 new file mode 100644 index 00000000000..ca4d338a92b --- /dev/null +++ b/doc/fdt_check_sign.1 @@ -0,0 +1,74 @@ +.TH FDT_CHECK_SIGN 1 "2021-11-11" + +.SH NAME +fdt_check_sign \- Check the signature in a flat device tree (FDT) file +.SH SYNOPSIS +.B fdt_check_sign +.RB [\fIoptions\fP] " \-f [" "device tree binary file" "] " \-K " [" "key file" "]" + +.SH "DESCRIPTION" +The +.B fdt_check_sign +command is used to check the signatures in a device tree binary file (.dtb +file) to ensure it has not been modified since it was signed. + +Permitted modifications are to the +.B /chosen +node and +.B /signature +node/subnodes only. + +.SH "OPTIONS" + +.TP +.BI "\-f [" "device tree binary file" "]" +Selects the .dtb file to check. + +.TP +.BI "\-k [" "key directory" "]" +Selects the device tree binary file containing the public key to check against. + +.SH EXAMPLES + +.P +Generate a key pair with openssl: + +.nf + $ openssl genpkey -algorithm RSA -out name.key \\ + -pkeyopt rsa_keygen_bits:2048 \\ + -pkeyopt rsa_keygen_pubexp:65537 + $ openssl req -batch -new -x509 -key name.key -out name.crt +.fi + +.P +Create a .dtb file to accept the public key, called pubkey.dtb in this example. + + # echo "/dts-v1/; /{};" | dtc - -o pubkey.dtb + +Sign a device tree binary: + +.nf + $ fdt_sign -f input.dtb -G name.key -K pubkey.dtb -k . -r + Signature written to 'input.dtb', node '/signature/name' + Public key written to 'pubkey.dtb', node '/signature/key-name +.fi + +.P +Check the signatures: + +.nf + $ fdt_check_sign -f input.dtb -k pubkey.dtb + name+ + Verify OK + Signature check OK +.fi + +.SH SEE ALSO + +fdt_sign + +.SH HOMEPAGE +http://www.denx.de/wiki/U-Boot/WebHome +.PP +.SH AUTHOR +This manual page was written by Simon Glass . diff --git a/doc/fdt_sign.1 b/doc/fdt_sign.1 new file mode 100644 index 00000000000..39f8bdc2a40 --- /dev/null +++ b/doc/fdt_sign.1 @@ -0,0 +1,111 @@ +.TH FDT_SIGN 1 "2021-11-11" + +.SH NAME +fdt_sign \- Sign a flat device tree (FDT) file +.SH SYNOPSIS +.B fdt_sign +.RB [\fIoptions\fP] " \-f [" "device tree binary file" "] " \-G " [" "key file" "]" + +.SH "DESCRIPTION" +The +.B fdt_sign +command is used to sign device tree binary files (.dtb files) so that they be +protected against unwanted modification. + +.B fdt_sign +adds a /signature node to the FDT, if not already present, then adds a node with +the signature itself, in a simplified format. It uses a private key to generate +the signature. + +.B fdt_check_sign +can then be used to verify the signature against a public key. + +The /chosen node is ignored when signing. A /signature node is added containing +the signature. + +.SH "OPTIONS" + +.TP +.BI "\-f [" "device tree binary file" "]" +Selects the .dtb file to sign. + +.TP +.BI "\-G [" "key file" "]" +Selects the key file to sign with. This should be a .key file containing an +RSA private key. + +.TP +.BI "\-k [" "key directory" "]" +Selects the directory containing the key file. + +.TP +.BI "\-K [" "key .dtb file" "]" +Selects the device tree binary file to write the public key into. This is +updated with a /signature subnode containing the public key the can be used to +verify the signed device tree. + +.TP +.BI "\-o [" "output file" "]" +Selects the output file to write to. If omitted, the device tree binary file is +updated in-place and only the +.B -f +parameter is used. + +.TP +.BI "\-q +Selects quiet mode which supresses non-error output. + +.TP +.BI "\-r +Marks the key as 'required', meaning that it must be used to check a signature +in the device tree, when fdt_check_sign is used. + +.TP +.BI "\-S +Selects the key name to sign with. This is optional and defaults to the base +name of the key file. + +.SH EXAMPLES + +.P +Generate a key pair with openssl: + +.nf + $ openssl genpkey -algorithm RSA -out name.key \\ + -pkeyopt rsa_keygen_bits:2048 \\ + -pkeyopt rsa_keygen_pubexp:65537 + $ openssl req -batch -new -x509 -key name.key -out name.crt +.fi + +.P +Create a .dtb file to accept the public key, called pubkey.dtb in this example. + + # echo "/dts-v1/; /{};" | dtc - -o pubkey.dtb + +Sign a device tree binary: + +.nf + $ fdt_sign -f input.dtb -G name.key -K pubkey.dtb -k . -r + Signature written to 'input.dtb', node '/signature/name' + Public key written to 'pubkey.dtb', node '/signature/key-name +.fi + +.P +Check the signatures: + +.nf + $ fdt_check_sign -f input.dtb -k pubkey.dtb + name+ + Verify OK + Signature check OK +.fi + +.SH SEE ALSO + +fdt_check_sign + +.SH HOMEPAGE +http://www.denx.de/wiki/U-Boot/WebHome +.PP +.SH AUTHOR +This manual page was written by Simon Glass . -- 2.34.0.rc1.387.gb447b232ab-goog