From mboxrd@z Thu Jan 1 00:00:00 1970 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 3BC03C74A5B for ; Sat, 18 Mar 2023 23:42:53 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4393B8569C; Sun, 19 Mar 2023 00:42:51 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com 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=gmail.com header.i=@gmail.com header.b="l7QI7ibi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 68B6A858F1; Sun, 19 Mar 2023 00:42:50 +0100 (CET) Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) (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 8BFBD85480 for ; Sun, 19 Mar 2023 00:42:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=fr0st61te@gmail.com Received: by mail-lf1-x12d.google.com with SMTP id y15so10761988lfa.7 for ; Sat, 18 Mar 2023 16:42:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679182967; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=6QzPD8IMQzL5IqyT0V1a61R97NxIYvGh5m6Pwoem0d8=; b=l7QI7ibiyiB1Sks6XpwhcyEpxVUcu7f1RZ0/YZmitjvcO5e1Q8ccsjriHJhbc4tudm ZaTOgkgOSFOBQ3ZTX6jrS7u7W4ALvpqlgofKLFkk0gQLDfKaCGEOMgkD21qnGWymM4Ky zc+zrq4w34DFUNuflEPv7hXv5qXq3zd/YhHzXz3urzJunxN6tgtfdMErqYvRV/qQ+4MC znnDrn/vmkS3OWqyk6pvg0mtCzLjrgfgiBXI8enm7nJehsdLCCLaVHuLVvrW5QoXJSo/ +HqwANXxLnA0SzikKMqVj1LEtqV+zdwcdhwQGtR3r3YVvnuHJDPB/SX2YM2OwH/qFg53 fFUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679182967; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6QzPD8IMQzL5IqyT0V1a61R97NxIYvGh5m6Pwoem0d8=; b=5S9hx28jH4pjM/Jz8mhl49c5r1Q6h/SGETV+CQ+CgNJC9sN+4RkSTbFmgRxCBQeAYn CVQn2jGFu4UHeCfr6sOhY6ubs30C+/v4eHui5xUqsSmtjYhnJYqv+ot+s6Z7T+XLTiLz +WVBlDbD9Wh1bBbWPFvQlBasrBGiBCmZOiaEFOmJvgmpaSKGBUl7YXwcw6xywJlfyP/q INuEVgbDHl7ZOwJ7aLas3hgLbj8tkiofjIDtOL2bFD/yY3hjLrlJZa+wwalEC60ErjeW v3oIPw7IKivn0GXNuVirvOIPM5n1/gSSZOXKH6p2TcXhaYbLLzxqk6UM1Il2RouAYk1K Ji4w== X-Gm-Message-State: AO0yUKU5LiLdsANf3LZVfxg3zTOa2cHz+VIFwJdgnBuzDYHo1HwELP7e 2bJaR21MFSK67LwHbCF+X9A= X-Google-Smtp-Source: AK7set9TF5tB5cPcXFBzfFo6Uk5pSBIBtN1FqKP4oJP82u80VxOoMKiilTg+bJZ+TSNOkA4U4oX9Hw== X-Received: by 2002:ac2:44c5:0:b0:4d8:58a7:6d90 with SMTP id d5-20020ac244c5000000b004d858a76d90mr5478402lfm.42.1679182966577; Sat, 18 Mar 2023 16:42:46 -0700 (PDT) Received: from localhost.localdomain (93-80-67-52.broadband.corbina.ru. [93.80.67.52]) by smtp.googlemail.com with ESMTPSA id l18-20020ac24312000000b004dc4af9089bsm999768lfh.231.2023.03.18.16.42.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Mar 2023 16:42:46 -0700 (PDT) From: Ivan Mikhaylov To: Simon Glass , Jan Kiszka Cc: u-boot@lists.denx.de, Roman Kopytin , Ivan Mikhaylov , Rasmus Villemoes Subject: [PATCH v3] test_vboot.py: include test of fdt_add_pubkey tool Date: Sun, 19 Mar 2023 02:42:32 +0000 Message-Id: <20230319024232.50020-1-fr0st61te@gmail.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.8 at phobos.denx.de X-Virus-Status: Clean From: Roman Kopytin Signed-off-by: Roman Kopytin Signed-off-by: Ivan Mikhaylov Cc: Rasmus Villemoes --- test/py/tests/test_vboot.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/py/tests/test_vboot.py b/test/py/tests/test_vboot.py index e3e7ca4b21..5ae622fe21 100644 --- a/test/py/tests/test_vboot.py +++ b/test/py/tests/test_vboot.py @@ -491,6 +491,37 @@ def test_vboot(u_boot_console, name, sha_algo, padding, sign_options, required, # Check that the boot fails if the global signature is not provided run_bootm(sha_algo, 'global image signature', 'signature is mandatory', False) + def test_fdt_add_pubkey(sha_algo, padding, sign_options): + """Test fdt_add_pubkey utility with given hash algorithm and padding. + + This function tests if fdt_add_pubkey utility may add public keys into dtb. + + Args: + sha_algo: Either 'sha1' or 'sha256', to select the algorithm to use + padding: Either '' or '-pss', to select the padding to use for the + rsa signature algorithm. + sign_options: Options to mkimage when signing a fit image. + """ + + # Create a fresh .dtb without the public keys + dtc('sandbox-u-boot.dts') + make_fit('sign-configs-%s%s.its' % (sha_algo, padding)) + + # Sign images with our dev keys + sign_fit(sha_algo, sign_options) + + # Create a fresh .dtb without the public keys + dtc('sandbox-u-boot.dts') + + cons.log.action('%s: Test fdt_add_pubkey with signed configuration' % sha_algo) + # Then add the dev key via the fdt_add_pubkey tool + util.run_and_log(cons, [fdt_add_pubkey, '-a', '%s,%s' % ('sha256' if algo_arg else sha_algo, \ + 'rsa3072' if sha_algo == 'sha384' else 'rsa2048'), + '-k', tmpdir, '-n', 'dev', '-r', 'conf', dtb]) + + # Check with fit_check_sign that FIT is signed with key + util.run_and_log(cons, [fit_check_sign, '-f', fit, '-k', dtb]) + cons = u_boot_console tmpdir = os.path.join(cons.config.result_dir, name) + '/' if not os.path.exists(tmpdir): @@ -500,6 +531,7 @@ def test_vboot(u_boot_console, name, sha_algo, padding, sign_options, required, mkimage = cons.config.build_dir + '/tools/mkimage' binman = cons.config.source_dir + '/tools/binman/binman' fit_check_sign = cons.config.build_dir + '/tools/fit_check_sign' + fdt_add_pubkey = cons.config.build_dir + '/tools/fdt_add_pubkey' dtc_args = '-I dts -O dtb -i %s' % tmpdir dtb = '%ssandbox-u-boot.dtb' % tmpdir sig_node = '/configurations/conf-1/signature' @@ -516,6 +548,7 @@ def test_vboot(u_boot_console, name, sha_algo, padding, sign_options, required, with open(evil_kernel, 'wb') as fd: fd.write(500 * b'\x01') + test_fdt_add_pubkey(sha_algo, padding, sign_options) try: # We need to use our own device tree file. Remember to restore it # afterwards. -- 2.39.1