diff --git a/ChangeLog.d/Switch-pkparse-to-new-pbe-funsctions.txt b/ChangeLog.d/Switch-pkparse-to-new-pbe-funsctions.txt index 6ceab6eaf..d819e8293 100644 --- a/ChangeLog.d/Switch-pkparse-to-new-pbe-funsctions.txt +++ b/ChangeLog.d/Switch-pkparse-to-new-pbe-funsctions.txt @@ -6,6 +6,4 @@ New deprecations of the output. Bugfix - * Pass real length of key to pk_parse_key_pkcs8_unencrypted_der() - after decrypting the key to avoid trailing padding data which are not - part of the original key before encrypting. + * mbedtls_pk_parse_key() now rejects trailing garbage in encrypted keys. diff --git a/tests/suites/test_suite_pkparse.function b/tests/suites/test_suite_pkparse.function index 02ef47594..64a3175bc 100644 --- a/tests/suites/test_suite_pkparse.function +++ b/tests/suites/test_suite_pkparse.function @@ -5,6 +5,11 @@ #include "mbedtls/ecp.h" #include "mbedtls/psa_util.h" #include "pk_internal.h" + +#if defined(MBEDTLS_PKCS12_C) || defined(MBEDTLS_PKCS5_C) +#define HAVE_mbedtls_pk_parse_key_pkcs8_encrypted_der +#endif + /* END_HEADER */ /* BEGIN_DEPENDENCIES @@ -150,25 +155,19 @@ exit: } /* END_CASE */ -/* BEGIN_CASE depends_on:MBEDTLS_TEST_HOOKS */ +/* BEGIN_CASE depends_on:MBEDTLS_TEST_HOOKS:HAVE_mbedtls_pk_parse_key_pkcs8_encrypted_der */ void pk_parse_key_encrypted(data_t *buf, data_t *pass, int result) { mbedtls_pk_context pk; mbedtls_pk_init(&pk); USE_PSA_INIT(); -#if defined(MBEDTLS_PKCS12_C) || defined(MBEDTLS_PKCS5_C) + TEST_EQUAL(mbedtls_pk_parse_key_pkcs8_encrypted_der(&pk, buf->x, buf->len, pass->x, pass->len, mbedtls_test_rnd_std_rand, NULL), result); exit: -#else - (void) buf; - (void) pass; - (void) result; -#endif - mbedtls_pk_free(&pk); USE_PSA_DONE(); }