From patchwork Tue Jan 18 04:39:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 532852 Delivered-To: patch@linaro.org Received: by 2002:ad5:544f:0:0:0:0:0 with SMTP id a15csp3352108imp; Mon, 17 Jan 2022 20:40:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJzm0/QhsbMIXQr4kbSaRloOtHDXsZXoKJysMmetJkb6bkqQ8QeyMGGU3afhhNY1vYS5bEMS X-Received: by 2002:a17:906:edae:: with SMTP id sa14mr91235ejb.605.1642480820449; Mon, 17 Jan 2022 20:40:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642480820; cv=none; d=google.com; s=arc-20160816; b=uVcBZ1FET+v+nlOm6D+JWeU83cbKekiH7GWKedePbm7LBoxSJ54E5JSIWZJvspEGPO Y+ffhU0+F23Qg1wR9DDw71sPLSUu6V8Jd39fMGPdCXK+Kx5hKY4yE01C5PgUOaOWmKsW Nlohu3iHOqCWeahRRjgIiDLjFPjvgR8UYp1sE41TdaC7GAL4JJfddICOnxlMO8TC7lde SDrTy79df8GMJ8qxnNJnPTNgs58NMfnMnsbwXxenm8OqhXdX7/2b4fJVKGzlcvGkpGmf AfSmA2zw26s4Hl5lC0lB9qSj2UFSGiPzGymgs/69IrVryliXRbabuyfo/CuJEM5fqr37 W6hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=P8Ih6Jmu14zQF5Dak/bGT5RLx0m+6CCkaEVsJC6SXZU=; b=MrSYE1Z6jP1SObEveV08fs8QYzg1FkDFDBjOrf64eBq5cvgRIuEEbKKZ0t5SbYrwX1 0oIpP6f2eUt+VkCc4iAUpVIlAC7WyUTD/ni0OcKp6YcYOVKtZVL7k0mQyLXWvO0l4XZ9 nnwvCIPHdU4XqLiKZoVmbyj8AJ819pnAs8iS58m9ruK1uBS15bf6cRZAw6FpKeUQ5xAi 3JSABrTlyuF/0LNebX3zzR49iuIJK7UTEjPFqOkwqx4p1Q6e+Dy1H/h9zaQap3oCWmyy qntudhZq9a87QM3BEypPtplLJZDzT2aMEA6j636C63X4yLdpFnsrHLgmWeEyCZUZv5kF /Zdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CnWJbaR4; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id z22si8907316edm.153.2022.01.17.20.40.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jan 2022 20:40:20 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CnWJbaR4; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 25F1982DA1; Tue, 18 Jan 2022 05:40:16 +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="CnWJbaR4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D91EF830C0; Tue, 18 Jan 2022 05:40:14 +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-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) (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 C957081430 for ; Tue, 18 Jan 2022 05:40:10 +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-x102d.google.com with SMTP id b1-20020a17090a990100b001b14bd47532so1708962pjp.0 for ; Mon, 17 Jan 2022 20:40:10 -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:mime-version :content-transfer-encoding; bh=P8Ih6Jmu14zQF5Dak/bGT5RLx0m+6CCkaEVsJC6SXZU=; b=CnWJbaR4Sy0f2tD95cJqz3vy9WA/Nd1GKpYBy/2bTLHNHk4myqH9veUVl/wzLz4bPY 6zLRJ8tzpS4sxx7gqa6c9UHXli3+eNQ9VOEmQrX0M1yoDWwwPRZ+ZfBi8Tl4BIPY5voj skB503uAVp3eIwcHOlPGlOoTygYVzafg83kmVLbZ5qdhhOd8zEeMx8+7eHWnW0GAPRJa luQDXj3dCUGqPbJRp321Jj4xZOL1A5aUSroBhhOLGVzxpZo985+24XuiRoj8f9iTXbyb 9pq8XDbWqLs3Dg8PC2+uSjdtNoJVBpU76QFgbrrEGTV7TiEOQWVnzeBS7gD97dd54/Gp T09Q== 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:mime-version :content-transfer-encoding; bh=P8Ih6Jmu14zQF5Dak/bGT5RLx0m+6CCkaEVsJC6SXZU=; b=gPBfElDNNhF+QuzUdf5tiGSVU51J50pZs0iH79xbPNhntbY9VWhMeKR4X/USTJyBZv bb3iv8s3VPUWygQ8zl24QEVnTEJPsnsj93X3x3DOiIMrawLNEif0mN9Hg2tKXwOjmpVx 5GCoujh1In7ucwtjWOfR1GpE0rJGmGgpJ/KstdNTjxtiSxAJUxIce31Y6bRXaB47eVdL +r7IKre0pnr+PCoYTHBVDeVW5dUT+K0HMSMCd7jIYIS5FERd4mhxoJniTEJDsaAnDv21 Xdwna2SPR2M8aUlRqMztKl2pA8W4mbAZ9BkOlC9Hmbam0/Ju1DYNxI7gorVYVgIQ/RAi kybg== X-Gm-Message-State: AOAM532PD8R/b6bdnxLdjEvcQ24f7fnJJjBwwlCQQUwTlZIMqCzdhNBN KgYJ2tRh04ITHdr1I1XdXFPCfQ== X-Received: by 2002:a17:90a:55c7:: with SMTP id o7mr103380pjm.184.1642480808991; Mon, 17 Jan 2022 20:40:08 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:bc1a:291e:ac91:be98]) by smtp.gmail.com with ESMTPSA id y69sm15670770pfg.171.2022.01.17.20.40.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jan 2022 20:40:08 -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 v9 00/11] efi_loader: capsule: improve capsule authentication support Date: Tue, 18 Jan 2022 13:39:43 +0900 Message-Id: <20220118043954.55940-1-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 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.2 at phobos.denx.de X-Virus-Status: Clean As I proposed and discussed in [1] and [2], I have made a couple of improvements on the current implementation of capsule update in this patch set. * add signing feature to mkeficapsule * add "--guid" option to mkeficapsule * add man page of mkeficapsule * update uefi document regarding capsule update * revise pytests [1] https://lists.denx.de/pipermail/u-boot/2021-April/447918.html [2] https://lists.denx.de/pipermail/u-boot/2021-July/455292.html Prerequisite patches ==================== None Test ==== * locally passed the pytest which is included in this patch series on sandbox built. (CONFIG_EFI_CAPSULE_AUTHENTICATE should explicitly be turned on in order to exercise the authentication code.) Changes ======= v9 (Jan 18, 2022) * rebased on v2022.01 * print the output messages to stderr (patch#1,#2, #4 and #6) * use SIZE_MAX instead of (u32)!0U (patch#2) * revise and re-format the man page of mkeficapsule (patch#5) * add "code-block:: console" directives for command line examples in a ReST document (patch#6) * describe the case when a trailing '/' in EFITOOLS_PATH is needed (patch#7) * describe UUID data as a binary rather than a string (patch#8) * drop fdtsig.sh-related patches (patch#12,#13 in v8) v8 (Dec 20, 2021) * rebase on v2022.01-rc3 * move the definition of CONFIG_TOOLS_MKEFICAPSULE to a proper patch (patch#2) v7 (Nov 16, 2021) * rebased on pre-v2022.01-rc2 * drop already-merged patch * check for a size of firmware binary file (patch#1) * enable mkeficapsule in tools-only_defconfig (patch#2) * define eficapsule.h and include it from mkeficapsule (patch#3) Hopefully, the tool can now compile on non-linux host. v6 (Nov 02, 2021) * rebased on pre-v2022.01-rc1 * add patch#2 to rework/refactor the code for better readability (patch#2) * use exit(EXIT_SUCCESS/FAILURE) (patch#3) * truncate >80chars lines in pytest scripts (patch#6) v5 (Oct 27, 2021) * rebased on pre-v2022.01-rc1 (WIP/26Oct2021) * drop already-merged patches * drop __weak from efi_get_public_key_data() (patch#1) * describe the format of public key node in device tree (patch#4) * re-order patches by grouping closely-related patches (patch#6-8) * modify pytest to make the test results correctly verified either with or without CONFIG_EFI_CAPSULE_AUTHENTICATE (patch#9) * add RFCs for embedding public keys during the build process (patch#10,11) v4 (Oct 7, 2021) * rebased on v2021.10 * align with "Revert "efi_capsule: Move signature from DTB to .rodata"" * add more missing *revert* commits (patch#1,#2,#3) * add fdtsig.sh, replacing dtb support in mkeficapsule (patch#4) * update/revise the man/uefi doc (patch#6,#7) * fix a bug in parsing guid string (patch#8) * add a test for "--guid" option (patch#10) * use dtb-based authentication test as done in v1 (patch#11) v3 (Aug 31, 2021) * rebased on v2021.10-rc3 * remove pytest-related patches * add function descriptions in mkeficapsule.c * correct format specifiers in printf() * let main() return 0 or -1 only * update doc/develop/uefi/uefi.rst for syntax change of mkeficapsule v2 (July 28, 2021) * rebased on v2021.10-rc* * removed dependency on target's configuration * removed fdtsig.sh and others * add man page * update the UEFI document * add dedicate defconfig for testing on sandbox * add gitlab CI support * add "--guid" option to mkeficapsule (yet rather RFC) Initial release (May 12, 2021) * based on v2021.07-rc2 AKASHI Takahiro (11): tools: mkeficapsule: output messages to stderr instead of stdout tools: mkeficapsule: rework the code a little bit tools: build mkeficapsule with tools-only_defconfig tools: mkeficapsule: add firmware image signing tools: mkeficapsule: add man page doc: update UEFI document for usage of mkeficapsule test/py: efi_capsule: add image authentication test tools: mkeficapsule: allow for specifying GUID explicitly test/py: efi_capsule: align with the syntax change of mkeficapsule test/py: efi_capsule: add a test for "--guid" option test/py: efi_capsule: check the results in case of CAPSULE_AUTHENTICATE MAINTAINERS | 1 + configs/tools-only_defconfig | 1 + doc/develop/uefi/uefi.rst | 147 ++-- doc/mkeficapsule.1 | 111 +++ .../py/tests/test_efi_capsule/capsule_defs.py | 5 + test/py/tests/test_efi_capsule/conftest.py | 59 +- test/py/tests/test_efi_capsule/signature.dts | 10 + .../test_efi_capsule/test_capsule_firmware.py | 91 ++- .../test_capsule_firmware_signed.py | 254 +++++++ tools/Kconfig | 8 + tools/Makefile | 8 +- tools/eficapsule.h | 115 +++ tools/mkeficapsule.c | 707 +++++++++++++++--- 13 files changed, 1317 insertions(+), 200 deletions(-) create mode 100644 doc/mkeficapsule.1 create mode 100644 test/py/tests/test_efi_capsule/signature.dts create mode 100644 test/py/tests/test_efi_capsule/test_capsule_firmware_signed.py create mode 100644 tools/eficapsule.h