mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-10 05:03:02 +03:00
test: update guards also for pkwrite and pkparse
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
This commit is contained in:
@@ -17,9 +17,8 @@ void pk_parse_keyfile_rsa(char *key_file, char *password, int result)
|
|||||||
int res;
|
int res;
|
||||||
char *pwd = password;
|
char *pwd = password;
|
||||||
|
|
||||||
MD_PSA_INIT();
|
|
||||||
|
|
||||||
mbedtls_pk_init(&ctx);
|
mbedtls_pk_init(&ctx);
|
||||||
|
MD_PSA_INIT();
|
||||||
|
|
||||||
if (strcmp(pwd, "NULL") == 0) {
|
if (strcmp(pwd, "NULL") == 0) {
|
||||||
pwd = NULL;
|
pwd = NULL;
|
||||||
@@ -50,9 +49,8 @@ void pk_parse_public_keyfile_rsa(char *key_file, int result)
|
|||||||
mbedtls_pk_context ctx;
|
mbedtls_pk_context ctx;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
MD_PSA_INIT();
|
|
||||||
|
|
||||||
mbedtls_pk_init(&ctx);
|
mbedtls_pk_init(&ctx);
|
||||||
|
MD_PSA_INIT();
|
||||||
|
|
||||||
res = mbedtls_pk_parse_public_keyfile(&ctx, key_file);
|
res = mbedtls_pk_parse_public_keyfile(&ctx, key_file);
|
||||||
|
|
||||||
@@ -78,6 +76,7 @@ void pk_parse_public_keyfile_ec(char *key_file, int result)
|
|||||||
int res;
|
int res;
|
||||||
|
|
||||||
mbedtls_pk_init(&ctx);
|
mbedtls_pk_init(&ctx);
|
||||||
|
USE_PSA_INIT();
|
||||||
|
|
||||||
res = mbedtls_pk_parse_public_keyfile(&ctx, key_file);
|
res = mbedtls_pk_parse_public_keyfile(&ctx, key_file);
|
||||||
|
|
||||||
@@ -92,6 +91,7 @@ void pk_parse_public_keyfile_ec(char *key_file, int result)
|
|||||||
|
|
||||||
exit:
|
exit:
|
||||||
mbedtls_pk_free(&ctx);
|
mbedtls_pk_free(&ctx);
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
@@ -101,8 +101,8 @@ void pk_parse_keyfile_ec(char *key_file, char *password, int result)
|
|||||||
mbedtls_pk_context ctx;
|
mbedtls_pk_context ctx;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
USE_PSA_INIT();
|
|
||||||
mbedtls_pk_init(&ctx);
|
mbedtls_pk_init(&ctx);
|
||||||
|
USE_PSA_INIT();
|
||||||
|
|
||||||
res = mbedtls_pk_parse_keyfile(&ctx, key_file, password,
|
res = mbedtls_pk_parse_keyfile(&ctx, key_file, password,
|
||||||
mbedtls_test_rnd_std_rand, NULL);
|
mbedtls_test_rnd_std_rand, NULL);
|
||||||
@@ -128,11 +128,13 @@ void pk_parse_key(data_t *buf, int result)
|
|||||||
mbedtls_pk_context pk;
|
mbedtls_pk_context pk;
|
||||||
|
|
||||||
mbedtls_pk_init(&pk);
|
mbedtls_pk_init(&pk);
|
||||||
|
USE_PSA_INIT();
|
||||||
|
|
||||||
TEST_ASSERT(mbedtls_pk_parse_key(&pk, buf->x, buf->len, NULL, 0,
|
TEST_ASSERT(mbedtls_pk_parse_key(&pk, buf->x, buf->len, NULL, 0,
|
||||||
mbedtls_test_rnd_std_rand, NULL) == result);
|
mbedtls_test_rnd_std_rand, NULL) == result);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
mbedtls_pk_free(&pk);
|
mbedtls_pk_free(&pk);
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
@@ -36,6 +36,9 @@ static void pk_write_check_common(char *key_file, int is_public_key, int is_der)
|
|||||||
size_t buf_len, check_buf_len;
|
size_t buf_len, check_buf_len;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
mbedtls_pk_init(&key);
|
||||||
|
USE_PSA_INIT();
|
||||||
|
|
||||||
/* Note: if mbedtls_pk_load_file() successfully reads the file, then
|
/* Note: if mbedtls_pk_load_file() successfully reads the file, then
|
||||||
it also allocates check_buf, which should be freed on exit */
|
it also allocates check_buf, which should be freed on exit */
|
||||||
TEST_EQUAL(mbedtls_pk_load_file(key_file, &check_buf, &check_buf_len), 0);
|
TEST_EQUAL(mbedtls_pk_load_file(key_file, &check_buf, &check_buf_len), 0);
|
||||||
@@ -56,7 +59,6 @@ static void pk_write_check_common(char *key_file, int is_public_key, int is_der)
|
|||||||
|
|
||||||
ASSERT_ALLOC(buf, check_buf_len);
|
ASSERT_ALLOC(buf, check_buf_len);
|
||||||
|
|
||||||
mbedtls_pk_init(&key);
|
|
||||||
if (is_public_key) {
|
if (is_public_key) {
|
||||||
TEST_EQUAL(mbedtls_pk_parse_public_keyfile(&key, key_file), 0);
|
TEST_EQUAL(mbedtls_pk_parse_public_keyfile(&key, key_file), 0);
|
||||||
if (is_der) {
|
if (is_der) {
|
||||||
@@ -98,6 +100,7 @@ exit:
|
|||||||
mbedtls_free(buf);
|
mbedtls_free(buf);
|
||||||
mbedtls_free(check_buf);
|
mbedtls_free(check_buf);
|
||||||
mbedtls_pk_free(&key);
|
mbedtls_pk_free(&key);
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_HEADER */
|
/* END_HEADER */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user