diff --git a/scripts/make_generated_files.bat b/scripts/make_generated_files.bat index abcfc39454..6be0de7ee5 100644 --- a/scripts/make_generated_files.bat +++ b/scripts/make_generated_files.bat @@ -13,3 +13,35 @@ python scripts\generate_psa_constants.py || exit /b 1 python tests\scripts\generate_bignum_tests.py || exit /b 1 python tests\scripts\generate_ecp_tests.py || exit /b 1 python tests\scripts\generate_psa_tests.py || exit /b 1 +python tests\scripts\generate_test_keys.py --output tests\src\test_keys.h || exit /b 1 +python tests\scripts\generate_test_cert_macros.py --output tests\src\test_certs.h ^ + --string TEST_CA_CRT_EC_PEM=tests\data_files\test-ca2.crt ^ + --binary TEST_CA_CRT_EC_DER=tests\data_files\test-ca2.crt.der ^ + --string TEST_CA_KEY_EC_PEM=tests\data_files\test-ca2.key.enc ^ + --password TEST_CA_PWD_EC_PEM=PolarSSLTest ^ + --binary TEST_CA_KEY_EC_DER=tests\data_files\test-ca2.key.der ^ + --string TEST_CA_CRT_RSA_SHA256_PEM=tests\data_files\test-ca-sha256.crt ^ + --binary TEST_CA_CRT_RSA_SHA256_DER=tests\data_files\test-ca-sha256.crt.der ^ + --string TEST_CA_CRT_RSA_SHA1_PEM=tests\data_files\test-ca-sha1.crt ^ + --binary TEST_CA_CRT_RSA_SHA1_DER=tests\data_files\test-ca-sha1.crt.der ^ + --string TEST_CA_KEY_RSA_PEM=tests\data_files\test-ca.key ^ + --password TEST_CA_PWD_RSA_PEM=PolarSSLTest ^ + --binary TEST_CA_KEY_RSA_DER=tests\data_files\test-ca.key.der ^ + --string TEST_SRV_CRT_EC_PEM=tests\data_files\server5.crt ^ + --binary TEST_SRV_CRT_EC_DER=tests\data_files\server5.crt.der ^ + --string TEST_SRV_KEY_EC_PEM=tests\data_files\server5.key ^ + --binary TEST_SRV_KEY_EC_DER=tests\data_files\server5.key.der ^ + --string TEST_SRV_CRT_RSA_SHA256_PEM=tests\data_files\server2-sha256.crt ^ + --binary TEST_SRV_CRT_RSA_SHA256_DER=tests\data_files\server2-sha256.crt.der ^ + --string TEST_SRV_CRT_RSA_SHA1_PEM=tests\data_files\server2.crt ^ + --binary TEST_SRV_CRT_RSA_SHA1_DER=tests\data_files\server2.crt.der ^ + --string TEST_SRV_KEY_RSA_PEM=tests\data_files\server2.key ^ + --binary TEST_SRV_KEY_RSA_DER=tests\data_files\server2.key.der ^ + --string TEST_CLI_CRT_EC_PEM=tests\data_files\cli2.crt ^ + --binary TEST_CLI_CRT_EC_DER=tests\data_files\cli2.crt.der ^ + --string TEST_CLI_KEY_EC_PEM=tests\data_files\cli2.key ^ + --binary TEST_CLI_KEY_EC_DER=tests\data_files\cli2.key.der ^ + --string TEST_CLI_CRT_RSA_PEM=tests\data_files\cli-rsa-sha256.crt ^ + --binary TEST_CLI_CRT_RSA_DER=tests\data_files\cli-rsa-sha256.crt.der ^ + --string TEST_CLI_KEY_RSA_PEM=tests\data_files\cli-rsa.key ^ + --binary TEST_CLI_KEY_RSA_DER=tests\data_files\cli-rsa.key.der || exit /b 1 diff --git a/tests/Makefile b/tests/Makefile index 5b2ee10256..dbba507d28 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -39,7 +39,7 @@ ifeq ($(GENERATED_PSA_DATA_FILES),FAILED) $(error "$(PYTHON) scripts/generate_psa_tests.py --list" failed) endif GENERATED_FILES := $(GENERATED_PSA_DATA_FILES) $(GENERATED_ECP_DATA_FILES) $(GENERATED_BIGNUM_DATA_FILES) -generated_files: $(GENERATED_FILES) +generated_files: $(GENERATED_FILES) src/test_keys.h src/test_certs.h # generate_bignum_tests.py and generate_psa_tests.py spend more time analyzing # inputs than generating outputs. Its inputs are the same no matter which files @@ -236,7 +236,8 @@ $(BINARIES): %$(EXEXT): %.c $(MBEDLIBS) $(TEST_OBJS_DEPS) $(MBEDTLS_TEST_OBJS) clean: ifndef WINDOWS rm -rf $(BINARIES) *.c *.datax - rm -f src/*.o src/drivers/*.o src/test_helpers/*.o src/libmbed* + rm -f src/*.o src/drivers/*.o src/test_helpers/*.o src/libmbed* src/test_keys.h src/test_certs.h + rm -f src/test_keys.h src/test_certs.h rm -f include/test/instrument_record_status.h rm -f include/alt-extra/*/*_alt.h rm -rf libtestdriver1 @@ -247,6 +248,8 @@ else if exist *.datax del /Q /F *.datax if exist src/*.o del /Q /F src/*.o if exist src/drivers/*.o del /Q /F src/drivers/*.o + if exist src/test_keys.h del /Q /F src/test_keys.h + if exist src/test_certs.h del /Q /F src/test_cers.h if exist src/test_helpers/*.o del /Q /F src/test_helpers/*.o if exist src/libmbed* del /Q /F src/libmed* if exist include/test/instrument_record_status.h del /Q /F include/test/instrument_record_status.h diff --git a/tests/scripts/check-generated-files.sh b/tests/scripts/check-generated-files.sh index 2f20026afc..96f122130a 100755 --- a/tests/scripts/check-generated-files.sh +++ b/tests/scripts/check-generated-files.sh @@ -131,6 +131,7 @@ check scripts/generate_psa_constants.py programs/psa/psa_constant_names_generate check tests/scripts/generate_bignum_tests.py $(tests/scripts/generate_bignum_tests.py --list) check tests/scripts/generate_ecp_tests.py $(tests/scripts/generate_ecp_tests.py --list) check tests/scripts/generate_psa_tests.py $(tests/scripts/generate_psa_tests.py --list) +check tests/scripts/generate_test_keys.py tests/src/test_keys.h check scripts/generate_driver_wrappers.py $library_dir/psa_crypto_driver_wrappers.h $library_dir/psa_crypto_driver_wrappers_no_static.c # Additional checks for Mbed TLS only diff --git a/tests/scripts/generate_test_keys.py b/tests/scripts/generate_test_keys.py index dbdb9600e7..85ff9186e2 100755 --- a/tests/scripts/generate_test_keys.py +++ b/tests/scripts/generate_test_keys.py @@ -99,9 +99,9 @@ def main() -> None: args = argparser.parse_args() output_file = args.output - # Remove output file if already existing. + # If the output file already exists, then we can quit (successfully) if os.path.exists(output_file): - os.remove(output_file) + return output_file = open(output_file, 'at') output_file.write(