From: Simon Glass <[email protected]> Move the signing-related test data (keys, certificates, OpenSSL and SoftHSM2 configuration, dummy engine source) into the fit/ subdirectory alongside the FIT DTS test files. Drop the 340_ prefix from files that had it. Update the Makefile and all ftest.py references.
Signed-off-by: Simon Glass <[email protected]> --- Changes in v2: - Add new patch to move FIT signing test data tools/binman/ftest.py | 20 +++++++++--------- tools/binman/test/Makefile | 2 +- tools/binman/test/{ => fit}/aes256.bin | Bin .../binman/test/{ => fit}/dummy-rsa-engine.c | 0 .../dummy-rsa4096.crt} | 0 .../{340_openssl.conf => fit/openssl.conf} | 0 .../test/{340_rsa2048.key => fit/rsa2048.key} | 0 .../{340_softhsm2.conf => fit/softhsm2.conf} | 0 8 files changed, 11 insertions(+), 11 deletions(-) rename tools/binman/test/{ => fit}/aes256.bin (100%) rename tools/binman/test/{ => fit}/dummy-rsa-engine.c (100%) rename tools/binman/test/{340_dummy-rsa4096.crt => fit/dummy-rsa4096.crt} (100%) rename tools/binman/test/{340_openssl.conf => fit/openssl.conf} (100%) rename tools/binman/test/{340_rsa2048.key => fit/rsa2048.key} (100%) rename tools/binman/test/{340_softhsm2.conf => fit/softhsm2.conf} (100%) diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 601d1f7eb8c..76d17e6d986 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -7927,7 +7927,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap 'default-dt': 'test-fdt1', 'atf-bl31-path': 'bl31.elf', } - data = tools.read_file(self.TestFile("340_rsa2048.key")) + data = tools.read_file(self.TestFile("fit/rsa2048.key")) self._MakeInputFile("keys/rsa2048.key", data) test_subdir = os.path.join(self._indir, TEST_FDT_SUBDIR) @@ -7964,7 +7964,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap 'atf-bl31-path': 'bl31.elf', } - x509_pubkey = '340_dummy-rsa4096.crt' + x509_pubkey = 'fit/dummy-rsa4096.crt' data = tools.read_file(self.TestFile(x509_pubkey)) self._MakeInputFile('dev.crt', data) @@ -8039,7 +8039,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap prefix = "testFitSignPKCS11Simple." # Configure SoftHSMv2 - data = tools.read_file(self.TestFile('340_softhsm2.conf')) + data = tools.read_file(self.TestFile('fit/softhsm2.conf')) softhsm2_conf = self._MakeInputFile(f'{prefix}softhsm2.conf', data) softhsm2_tokens_dir = self._MakeInputDir(f'{prefix}softhsm2.tokens') @@ -8070,7 +8070,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap test_subdir = os.path.join(self._indir, TEST_FDT_SUBDIR) # Make OpenSSL use softhsm2 engine - ossl_conf = self.TestFile('340_openssl.conf') + ossl_conf = self.TestFile('fit/openssl.conf') with unittest.mock.patch.dict('os.environ', {'OPENSSL_CONF': ossl_conf, 'SOFTHSM2_CONF': softhsm2_conf}): @@ -8114,7 +8114,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap prefix = "testFitSignPKCS11Object." # Configure SoftHSMv2 - data = tools.read_file(self.TestFile('340_softhsm2.conf')) + data = tools.read_file(self.TestFile('fit/softhsm2.conf')) softhsm2_conf = self._MakeInputFile(f'{prefix}softhsm2.conf', data) softhsm2_tokens_dir = self._MakeInputDir(f'{prefix}softhsm2.tokens') @@ -8147,7 +8147,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap # Make OpenSSL use softhsm2 engine and configure PIN for token # The PIN is incorrect on purpose, the correct one will be passed by # MKIMAGE_SIGN_PIN - ossl_conf = self.TestFile('340_openssl.conf') + ossl_conf = self.TestFile('fit/openssl.conf') with unittest.mock.patch.dict('os.environ', {'OPENSSL_CONF': ossl_conf, 'SOFTHSM2_CONF': softhsm2_conf, @@ -8204,9 +8204,9 @@ fdt fdtmap Extract the devicetree blob from the fdtmap 'default-dt': 'test-fdt1', 'atf-bl31-path': 'bl31.elf', } - data = tools.read_file(self.TestFile("340_rsa2048.key")) + data = tools.read_file(self.TestFile("fit/rsa2048.key")) self._MakeInputFile("keys1/rsa2048.key", data) - data = tools.read_file(self.TestFile("340_rsa2048.key")) + data = tools.read_file(self.TestFile("fit/rsa2048.key")) self._MakeInputFile("keys2/conf-rsa2048.key", data) test_subdir = os.path.join(self._indir, TEST_FDT_SUBDIR) @@ -8257,7 +8257,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap def testSimpleFitEncryptedData(self): """Test an image with a FIT containing data to be encrypted""" - data = tools.read_file(self.TestFile("aes256.bin")) + data = tools.read_file(self.TestFile("fit/aes256.bin")) self._MakeInputFile("keys/aes256.bin", data) keys_subdir = os.path.join(self._indir, "keys") @@ -8277,7 +8277,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap # Retrieve the key name from the FIT removing any null byte key_name = fit.GetProps(subnode)['key-name-hint'].bytes.replace(b'\x00', b'') - with open(self.TestFile(key_name.decode('ascii') + '.bin'), 'rb') as file: + with open(self.TestFile('fit/' + key_name.decode('ascii') + '.bin'), 'rb') as file: key = file.read() iv = fit.GetProps(subnode)['iv'].bytes.hex() enc_data = fit.GetProps(node)['data'].bytes diff --git a/tools/binman/test/Makefile b/tools/binman/test/Makefile index d5e4c0f556a..6b42db6559f 100644 --- a/tools/binman/test/Makefile +++ b/tools/binman/test/Makefile @@ -85,7 +85,7 @@ blob_syms: blob_syms.c elf_sections: CFLAGS += $(LDS_EFL_SECTIONS) elf_sections: elf_sections.c -dummy-rsa-engine.so: dummy-rsa-engine.c +dummy-rsa-engine.so: $(SRC)fit/dummy-rsa-engine.c $(CC) -fPIC -shared -lcrypto -lssl -o $@ $< clean: diff --git a/tools/binman/test/aes256.bin b/tools/binman/test/fit/aes256.bin similarity index 100% rename from tools/binman/test/aes256.bin rename to tools/binman/test/fit/aes256.bin diff --git a/tools/binman/test/dummy-rsa-engine.c b/tools/binman/test/fit/dummy-rsa-engine.c similarity index 100% rename from tools/binman/test/dummy-rsa-engine.c rename to tools/binman/test/fit/dummy-rsa-engine.c diff --git a/tools/binman/test/340_dummy-rsa4096.crt b/tools/binman/test/fit/dummy-rsa4096.crt similarity index 100% rename from tools/binman/test/340_dummy-rsa4096.crt rename to tools/binman/test/fit/dummy-rsa4096.crt diff --git a/tools/binman/test/340_openssl.conf b/tools/binman/test/fit/openssl.conf similarity index 100% rename from tools/binman/test/340_openssl.conf rename to tools/binman/test/fit/openssl.conf diff --git a/tools/binman/test/340_rsa2048.key b/tools/binman/test/fit/rsa2048.key similarity index 100% rename from tools/binman/test/340_rsa2048.key rename to tools/binman/test/fit/rsa2048.key diff --git a/tools/binman/test/340_softhsm2.conf b/tools/binman/test/fit/softhsm2.conf similarity index 100% rename from tools/binman/test/340_softhsm2.conf rename to tools/binman/test/fit/softhsm2.conf -- 2.43.0

