summaryrefslogtreecommitdiff
path: root/tools/binman/ftest.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-03-02 17:02:45 -0700
committerSimon Glass <sjg@chromium.org>2023-03-08 13:15:15 -0800
commit953d4177afa0bee0ba0db4b81036d3197595b997 (patch)
tree4a99a2364403b620f5dc629e76d1d07225faf8fb /tools/binman/ftest.py
parent7caa372a5e41cadd3903165fb26a4b1e0268edbc (diff)
binman: Support generation of x509 certificates
And a new entry type which supports generation of x509 certificates. This uses a new 'openssl' btool with just one operation so far. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/binman/ftest.py')
-rw-r--r--tools/binman/ftest.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 76445969201..f1e14c6b3dc 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -6539,6 +6539,32 @@ fdt fdtmap Extract the devicetree blob from the fdtmap
finally:
shutil.rmtree(tmpdir)
+ def testX509Cert(self):
+ """Test creating an X509 certificate"""
+ keyfile = self.TestFile('key.key')
+ entry_args = {
+ 'keyfile': keyfile,
+ }
+ data = self._DoReadFileDtb('279_x509_cert.dts',
+ entry_args=entry_args)[0]
+ cert = data[:-4]
+ self.assertEqual(U_BOOT_DATA, data[-4:])
+
+ # TODO: verify the signature
+
+ def testX509CertMissing(self):
+ """Test that binman still produces an image if openssl is missing"""
+ keyfile = self.TestFile('key.key')
+ entry_args = {
+ 'keyfile': 'keyfile',
+ }
+ with test_util.capture_sys_output() as (_, stderr):
+ self._DoTestFile('279_x509_cert.dts',
+ force_missing_bintools='openssl',
+ entry_args=entry_args)
+ err = stderr.getvalue()
+ self.assertRegex(err, "Image 'image'.*missing bintools.*: openssl")
+
if __name__ == "__main__":
unittest.main()