From patchwork Mon Dec 20 05:02:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 526039 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp3767756imb; Sun, 19 Dec 2021 21:03:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJxgTH0xtA2xCoY2XSGmF1NWvuR37SOJwLzRPH1gp4cSxs9GZO93aPg6RZ2uwQm6oYH6+ube X-Received: by 2002:a17:907:75dc:: with SMTP id jl28mr11394075ejc.13.1639976626091; Sun, 19 Dec 2021 21:03:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639976626; cv=none; d=google.com; s=arc-20160816; b=dqbEY/H3gxOvPqaKSq9nKrew4HvI0v3LhGmVMu2lwd5JlBlVyoQFg7KY5Py1K+MLc5 K4E1gmSdqNX/8FKgLv/WEr5ZuBqeio9c98hprJTycBeO8jao0L7Z00XV82Pyfs9uSnBX ECefurhmg6Q1oK0qIWI41WzTZgT0QhLaWodvDfjtg8GwdbV8ooXK2VFwhK2g2rY2Q0cc HvTj0NK+uIQdpvskEhYeveVMUliXTE1H2/QLOMxzg+ajYc0lVQ0c1svfoyPq1osHvX4P 5utT9sfuQsZ9OYoUv190a0KRch+Zh29X04cuskTn5m7E0oIX1TD7C4qdPTrOHyQFY/Nd Ofiw== 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=9djj/bYcRQSAvvAlbOXBo45+U1oNB4g3P9AHXmJouoE=; b=QBMO/CLYyeTBosQtXRvLAMDJTdtqj+WtKEdXFh7+LDB2GM7VFCbZFlwtFXf+hLQtY8 c9W5fom9x6UOtgN6SQ4/k9ZOJaTNjJ0EqbEa9zG2r001FNrvp17zuq/+doYYHbCywWm/ Fs/KBa1MjTac7wyMimtjg/OWhZ85hHPGUoX5NFMvz0Y8QzNX8KuI0p7YyqaAnJpM/6B0 LqhZr43jsRPBxD2v+crmvfZn0Sa2kCdNwL4IJOu8TsmhxX3qSXFQXGvHnhWHtVkOqnVq AvkyttAiqda2u1AJ+63xiqJBVjiX7Ko7CIZhxYy+xTDMS3oVLZIqvIktMnqpgD5RPNnF lHCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="H2rR/eLu"; 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 bd11si5692654edb.442.2021.12.19.21.03.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Dec 2021 21:03:46 -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="H2rR/eLu"; 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 6365683031; Mon, 20 Dec 2021 06:03:42 +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="H2rR/eLu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6B9888307B; Mon, 20 Dec 2021 06:03:40 +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-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) (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 5628582F65 for ; Mon, 20 Dec 2021 06:03:36 +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-x102e.google.com with SMTP id iy13so2738522pjb.5 for ; Sun, 19 Dec 2021 21:03:36 -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=9djj/bYcRQSAvvAlbOXBo45+U1oNB4g3P9AHXmJouoE=; b=H2rR/eLuGmvUYQbUoIq6xrJijCVOgMriHx9RabUkbRb1rV0/s9hchzcFlYhaPWPKPn gPYxTUBpm2zIoaa+EacGnQhOTSMPPoju956EeBddos5tSRK/uBCxwuXMO86Eiq8+q2Vo m2sCRzDhVd9z4K60AauuG22JKfxYmXiNKoieBW5PmeYfSfQXvru/CI7m57LUqV2mkrp5 6BJbZnxTfP9aVPfTGY60uiAGCH6y1EDQtU7NBA2psa2hV0387WINrJIc+sur9thhvEjW orw9rIiaV8Y9KnsQKbCIn5MtCV+kIdOsBpSKJY+v2rG4GENiLXfcuMqY9lAkmV4CSUDD P3jA== 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=9djj/bYcRQSAvvAlbOXBo45+U1oNB4g3P9AHXmJouoE=; b=c9gA3wgiQ0oSPbmPQxteFgC4N+z1SgJCQcpF+gwM3pv+wJb8GKi2WANy0KO6oCAN/c wZbAdROM9y6kShLXjHIyYLCZcyidFXAArm1tVTk9Z1Xaxdkx+yVomAyjNEPtoseGXaWt Qxx8VFR8cNV6Kx6XSZRIQNqNvq+O2JqMhJDVc/7cJ3qonTC1L0MwGszPUDfzIRLYLiz8 e698Z6R1B1qbh6IKzgFrle0OaT6NZ5DqQqFhJYMcGCHvzlAGhdO5tnpz392c4FsGlh9K 23rEe6FUsuv8yTr8wQgikKN7Q5D1dnYTFKoxXjijc5L/kUg314LN0KFlLjQSdnq7knR8 Hs3g== X-Gm-Message-State: AOAM531IklocfpPs5VT4+E+C9yYkm1akX3FyadHK/waDr2Crh6a2d1e2 npT/9e65HLzx540wV02IVT2gvw== X-Received: by 2002:a17:902:e9d1:b0:149:114e:ac54 with SMTP id 17-20020a170902e9d100b00149114eac54mr3613308plk.23.1639976614277; Sun, 19 Dec 2021 21:03:34 -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.03.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Dec 2021 21:03:33 -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 00/12] efi_loader: capsule: improve capsule authentication support Date: Mon, 20 Dec 2021 14:02:41 +0900 Message-Id: <20211220050253.31163-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.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 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 * (as RFC) add CONFIG_EFI_CAPSULE_KEY_PATH and fdtsig.sh We have had some discussion about fdtsig.sh. So RFCs (patch#11,#12) are still included for further discussion if they are useful or not. For smooth merge, the rest (patch#1-10) should work without them. [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 ======= 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 (12): tools: mkeficapsule: rework the code a little bit tools: build mkeficapsule with tools-only_defconfig tools: mkeficapsule: add firmwware 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 (RFC) tools: add fdtsig.sh (RFC) efi_loader, dts: add public keys for capsules to device tree MAINTAINERS | 2 + configs/tools-only_defconfig | 1 + doc/develop/uefi/uefi.rst | 143 ++-- doc/mkeficapsule.1 | 107 +++ dts/Makefile | 23 +- lib/efi_loader/Kconfig | 7 + .../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/fdtsig.sh | 40 ++ tools/mkeficapsule.c | 680 +++++++++++++++--- 16 files changed, 1360 insertions(+), 193 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 create mode 100755 tools/fdtsig.sh