Improve pkparse test dependencies and changelog

Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
This commit is contained in:
Waleed Elmelegy 2023-09-21 15:21:10 +01:00
parent 556a0790f6
commit 38202a2b18
2 changed files with 8 additions and 11 deletions

View file

@ -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.

View file

@ -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();
}