From patchwork Mon Dec 20 05:02:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1570832 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=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=LzzC9j1U; 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 4JHSGQ4GXRz9t0k for ; Mon, 20 Dec 2021 16:05:50 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CA6D683494; Mon, 20 Dec 2021 06:04:41 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="LzzC9j1U"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E50A28309A; Mon, 20 Dec 2021 06:04:19 +0100 (CET) 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_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) (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 9862A832DE for ; Mon, 20 Dec 2021 06:04:15 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pl1-x632.google.com with SMTP id q17so7127124plr.11 for ; Sun, 19 Dec 2021 21:04:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SM+IRbafxx8Qr/8kK8fKjePcwTpG3b764rPu/B5MUy4=; b=LzzC9j1UwBds7ADEFGCbgRs8mLZiocuWkI75F0c2+0wd3Blj4pxyS+3BZHb59w4ORU /X7CkHm84eSolapMCbZh0+rB0avJ6buZ2dVDLI2iLFXI8DQ++jzEYvuCsIm41u3fn3KT bIVTJwCTYe5VXK4qBqchpNwxJEOzcqKr9DJVLAapQKq4ZUAq3QzONp0A2HV26BAsT821 2kOYlZz1gJi71yHNUa2ZVdLpWCMRzhdabuKjrxZyOcMzDG8W/3Vf+7NCTR6PokkTdfH3 w1BoSrQVWLSgp+XilCYC+HiWj+V5skDdkZgYvVqrcYSkSi3GvKbFD3xZ/Zx2aINv27ME nbtQ== 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=SM+IRbafxx8Qr/8kK8fKjePcwTpG3b764rPu/B5MUy4=; b=nqWj7WpSLrxhMSPCIBv69fkDQ4FfmwYqpjiyRK05Haq+YCi+qrA2GwSm65jy3kMnCm BBXFTIAA+/sCSCfjjMF5Xe4vl8qyCfUZtdwfSohu00QdvHs2UDvwWwYZ4opERO4OIPn1 eIXop4FKQFQUWv6XP4AFhMQCDZ5vWapVY1hCZeS+fHERcPrtyjw/zOsCsfRqVWFAvEs2 UrhVnnX0Gu/7RGo146r2BvPiAdEZ5WMot1QyVR3kF9JER1DP7jeNMM3W2/39eyoLY7d3 owQ9BhOWDNssY6IoC6cXQEfuYLMi9COC+KcOmwtiCXb1WVhvwShLy2ZS92r0C3DMWLgT QZCw== X-Gm-Message-State: AOAM531iBEGMZFySv0dnMOg1cYcaetpsnufnKt+FkiS5i05UVeUnDRfQ K/osodazizMHYYERgfvUpUCwHw== X-Google-Smtp-Source: ABdhPJydsVl9PScPENmYGDfNj7o+/wfNra5cLSTEClVLSHA+2uI7LZT3yMM/IJC9KnYXX1EjY6EKQg== X-Received: by 2002:a17:90b:4c44:: with SMTP id np4mr17848969pjb.195.1639976654027; Sun, 19 Dec 2021 21:04:14 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:89bf:be4:468d:12c2]) by smtp.gmail.com with ESMTPSA id mu2sm4581163pjb.43.2021.12.19.21.04.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Dec 2021 21:04:13 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, sjg@chromium.org Cc: ilias.apalodimas@linaro.org, sughosh.ganu@linaro.org, masami.hiramatsu@linaro.org, mark.kettenis@xs4all.nl, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v8 11/12] (RFC) tools: add fdtsig.sh Date: Mon, 20 Dec 2021 14:02:52 +0900 Message-Id: <20211220050253.31163-12-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211220050253.31163-1-takahiro.akashi@linaro.org> References: <20211220050253.31163-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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 With this script, a public key is added to a device tree blob as the default efi_get_public_key_data() expects. Signed-off-by: AKASHI Takahiro --- MAINTAINERS | 1 + tools/fdtsig.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100755 tools/fdtsig.sh diff --git a/MAINTAINERS b/MAINTAINERS index 93ef5e297acc..e7cca02eac9b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -743,6 +743,7 @@ F: cmd/bootefi.c F: cmd/efidebug.c F: cmd/nvedit_efi.c F: tools/efivar.py +F: tools/fdtsig.sh F: tools/file2include.c F: tools/mkeficapsule.c diff --git a/tools/fdtsig.sh b/tools/fdtsig.sh new file mode 100755 index 000000000000..c2b2a6dc5ec8 --- /dev/null +++ b/tools/fdtsig.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0+ +# +# script to add a certificate (efi-signature-list) to dtb blob + +usage() { + if [ -n "$*" ]; then + echo "ERROR: $*" + fi + echo "Usage: "$(basename $0) " " +} + +if [ "$#" -ne 2 ]; then + usage "Arguments missing" + exit 1 +fi + +ESL=$1 +DTB=$2 +NEW_DTB=$(basename $DTB)_tmp +SIG=signature + +cat << 'EOF' > $SIG.dts +/dts-v1/; +/plugin/; + +&{/} { + signature { +EOF +echo "capsule-key = /incbin/(\"$ESL\");" >> $SIG.dts +cat << 'EOF' >> $SIG.dts + }; +}; +EOF + +dtc -@ -I dts -O dtb -o $SIG.dtbo $SIG.dts +fdtoverlay -i $DTB -o $NEW_DTB $SIG.dtbo +mv $NEW_DTB $DTB + +rm $SIG.dts $SIG.dtsn $SIG.dtbo