From patchwork Tue Nov 16 04:32:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1555626 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=x19raZ+I; 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)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HtYCD16Kjz9sX3 for ; Tue, 16 Nov 2021 15:35:36 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 898B4837E9; Tue, 16 Nov 2021 05:35:22 +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="x19raZ+I"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 09FA183618; Tue, 16 Nov 2021 05:34:03 +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-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) (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 8B31083800 for ; Tue, 16 Nov 2021 05:33:51 +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-pj1-x102a.google.com with SMTP id v23so14681454pjr.5 for ; Mon, 15 Nov 2021 20:33:51 -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=rYuYsY1CHK5N10vJQnPljYwrrzsxsuZoNwthGvpXAYo=; b=x19raZ+IWNCcLKhoEwgOnysKWNrc+laTS6XIFy1Yl3HpiBx3EGhQ9uXb1hfPL1Zjs0 h6qf8VAmmIpVDCIOHIUh/fVE96iz+aUnrYUWnGg+TNQiG4xcSeZ03FJ4EiCZZzNdbGte Unki8Tc8aBkPAOLaRk/7oimbXHS9gSjbwZB9zdricfMqJaAgQe7XrB+iKvd73xo97XAW s777dPduuwETCfC/BZPvR+oicxzIzDwZepXM6kDQ6GbS3xYg7Q73z4aCTNgJrkuHsmCZ jRU9m3tDD5PWz2INPemwEjfGFaD7SfcVjhHJb8rts/N55OukXgM8pUnk66sKmnaXt9zz LGcA== 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=rYuYsY1CHK5N10vJQnPljYwrrzsxsuZoNwthGvpXAYo=; b=F8mY396BxdwRp8g9eWrp6WKoRVCUgymAeWJFJneQOCtXV7fd8lKyM2rmc9PUqcnktG fKV/AVaPJ7QHMlv0gvf+MpyNQi5m+T6sidi4aY06lYiVfSBlIfbk8WxzB7cluM8vwnEV dXsvfTzniGO/u0pQ4aEVx1yRRuFBXJRSU7hbwfjCFB+GEop9N+rtm4dRtgcaGxcJ9D47 ge+RiMEDZku7bIMbYfEFZPtBkgwZEihgbaMgb4CpsmhYkaCXsfeClOVXESy7FN4DEK6b Sz+nUmqY1TmXPYPPxf+oIDAk1lOCT7jGWp0fHhz0uxhf35RTInAgjydq7iHzXHsT45zR XNjw== X-Gm-Message-State: AOAM530wSop2W07iy3km48hQJTvtudzjZoO8elW1JwrQRogs6csIi7q9 NnWMXJisOZxpq4Ztaye/EBDpVg== X-Google-Smtp-Source: ABdhPJy6ZBNitO3Tul8nvYDC+Ntj6s+IqUkRGZwHOPL9WElIoEzJmPoMAW3xKfuidCD2zXRke1YqGQ== X-Received: by 2002:a17:90b:3a89:: with SMTP id om9mr71773960pjb.29.1637037229673; Mon, 15 Nov 2021 20:33:49 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:d07c:c772:1ab9:a9e0]) by smtp.gmail.com with ESMTPSA id lt5sm782914pjb.43.2021.11.15.20.33.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 20:33:49 -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 v7 11/12] (RFC) tools: add fdtsig.sh Date: Tue, 16 Nov 2021 13:32:37 +0900 Message-Id: <20211116043238.67226-12-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211116043238.67226-1-takahiro.akashi@linaro.org> References: <20211116043238.67226-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 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 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 813674eb2898..8233a53c29dc 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -742,6 +742,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