mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Merge remote-tracking branch 'dev' into fix-MBEDTLS_HAS_MD5_VIA_LOWLEVEL_OR_PSA
Conflicts: * tests/suites/test_suite_pkparse.data: the dependencies of "Parse EC Key #3 (SEC1 PEM encrypted)" were updated on both branches (development: ECP curve; this branch: MD5 hash).
This commit is contained in:
@ -5,10 +5,15 @@
|
||||
#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
|
||||
* depends_on:MBEDTLS_PK_PARSE_C:MBEDTLS_BIGNUM_C
|
||||
* depends_on:MBEDTLS_PK_PARSE_C
|
||||
* END_DEPENDENCIES
|
||||
*/
|
||||
|
||||
@ -150,6 +155,24 @@ exit:
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* 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();
|
||||
|
||||
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:
|
||||
mbedtls_pk_free(&pk);
|
||||
USE_PSA_DONE();
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_PK_HAVE_ECC_KEYS:MBEDTLS_PK_WRITE_C */
|
||||
void pk_parse_fix_montgomery(data_t *input_key, data_t *exp_output)
|
||||
{
|
||||
@ -169,13 +192,13 @@ void pk_parse_fix_montgomery(data_t *input_key, data_t *exp_output)
|
||||
mbedtls_test_rnd_std_rand, NULL), 0);
|
||||
|
||||
output_key_len = input_key->len;
|
||||
ASSERT_ALLOC(output_key, output_key_len);
|
||||
TEST_CALLOC(output_key, output_key_len);
|
||||
/* output_key_len is updated with the real amount of data written to
|
||||
* output_key buffer. */
|
||||
output_key_len = mbedtls_pk_write_key_der(&pk, output_key, output_key_len);
|
||||
TEST_ASSERT(output_key_len > 0);
|
||||
|
||||
ASSERT_COMPARE(exp_output->x, exp_output->len, output_key, output_key_len);
|
||||
TEST_MEMORY_COMPARE(exp_output->x, exp_output->len, output_key, output_key_len);
|
||||
|
||||
exit:
|
||||
if (output_key != NULL) {
|
||||
|
Reference in New Issue
Block a user