[PATCH v3 05/11] binman: ftest: Add test for u_boot_spl_pubkey_dtb

lukas.funke-oss at weidmueller.com lukas.funke-oss at weidmueller.com
Tue Jul 18 13:53:13 CEST 2023


From: Lukas Funke <lukas.funke at weidmueller.com>

Add test for u_boot_spl_pubkey_dtb. The test adds a public key to the
dtb and checks if the required nodes will be added to the images dtb.

Signed-off-by: Lukas Funke <lukas.funke at weidmueller.com>
Reviewed-by: Simon Glass <sjg at chromium.org>

---

Changes in v3:
- Add newline before main
- Adapted test due to property renaming

Changes in v2:
- Changed u_boot_spl_pubkey_dtb to u-boot-spl-pubkey-dtb

 tools/binman/ftest.py                    | 33 ++++++++++++++++++++++++
 tools/binman/test/281_spl_pubkey_dtb.dts | 16 ++++++++++++
 2 files changed, 49 insertions(+)
 create mode 100644 tools/binman/test/281_spl_pubkey_dtb.dts

diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 43b4f850a6..959c760792 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -638,6 +638,16 @@ class TestFunctional(unittest.TestCase):
         TestFunctional._MakeInputFile('vpl/u-boot-vpl',
             tools.read_file(cls.ElfTestFile(src_fname)))
 
+    @classmethod
+    def _SetupPmuFwlElf(cls, src_fname='bss_data'):
+        """Set up an ELF file with a '_dt_ucode_base_size' symbol
+
+        Args:
+            Filename of ELF file to use as VPL
+        """
+        TestFunctional._MakeInputFile('pmu-firmware.elf',
+            tools.read_file(cls.ElfTestFile(src_fname)))
+
     @classmethod
     def _SetupDescriptor(cls):
         with open(cls.TestFile('descriptor.bin'), 'rb') as fd:
@@ -6677,5 +6687,28 @@ fdt         fdtmap                Extract the devicetree blob from the fdtmap
         self.assertIn("Node '/fit': Missing tool: 'mkimage'", str(e.exception))
 
 
+    def testSplPubkeyDtb(self):
+         """Test u_boot_spl_pubkey_dtb etype"""
+         data = tools.read_file(self.TestFile("key.pem"))
+         self._MakeInputFile("key.crt", data)
+         self._DoReadFileRealDtb('281_spl_pubkey_dtb.dts')
+         image = control.images['image']
+         entries = image.GetEntries()
+         dtb_entry = entries['u-boot-spl-pubkey-dtb']
+         dtb_data = dtb_entry.GetData()
+         dtb = fdt.Fdt.FromData(dtb_data)
+         dtb.Scan()
+
+         signature_node = dtb.GetNode('/signature')
+         self.assertIsNotNone(signature_node)
+         key_node = signature_node.FindNode("key-key")
+         self.assertIsNotNone(key_node)
+         self.assertEqual(fdt_util.GetString(key_node, "required"),
+                          "conf")
+         self.assertEqual(fdt_util.GetString(key_node, "algo"),
+                          "sha384,rsa4096")
+         self.assertEqual(fdt_util.GetString(key_node, "key-name-hint"),
+                          "key")
+
 if __name__ == "__main__":
     unittest.main()
diff --git a/tools/binman/test/281_spl_pubkey_dtb.dts b/tools/binman/test/281_spl_pubkey_dtb.dts
new file mode 100644
index 0000000000..3256ff970c
--- /dev/null
+++ b/tools/binman/test/281_spl_pubkey_dtb.dts
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		u-boot-spl-pubkey-dtb {
+			algo = "sha384,rsa4096";
+			required = "conf";
+			key-name-hint = "key";
+		};
+	};
+};
-- 
2.30.2



More information about the U-Boot mailing list