mirror of
https://github.com/cuberite/polarssl.git
synced 2025-08-28 07:21:02 -04:00
test: fix USE_PSA_INIT/DONE for x509 test suite
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
This commit is contained in:
parent
19c8196212
commit
e7373a8a0f
@ -409,6 +409,7 @@ void x509_parse_san(char *crt_file, char *result_str)
|
|||||||
|
|
||||||
mbedtls_x509_crt_init(&crt);
|
mbedtls_x509_crt_init(&crt);
|
||||||
memset(buf, 0, 2000);
|
memset(buf, 0, 2000);
|
||||||
|
USE_PSA_INIT();
|
||||||
|
|
||||||
TEST_ASSERT(mbedtls_x509_crt_parse_file(&crt, crt_file) == 0);
|
TEST_ASSERT(mbedtls_x509_crt_parse_file(&crt, crt_file) == 0);
|
||||||
|
|
||||||
@ -432,6 +433,7 @@ void x509_parse_san(char *crt_file, char *result_str)
|
|||||||
exit:
|
exit:
|
||||||
|
|
||||||
mbedtls_x509_crt_free(&crt);
|
mbedtls_x509_crt_free(&crt);
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
@ -444,6 +446,7 @@ void x509_cert_info(char *crt_file, char *result_str)
|
|||||||
|
|
||||||
mbedtls_x509_crt_init(&crt);
|
mbedtls_x509_crt_init(&crt);
|
||||||
memset(buf, 0, 2000);
|
memset(buf, 0, 2000);
|
||||||
|
USE_PSA_INIT();
|
||||||
|
|
||||||
TEST_ASSERT(mbedtls_x509_crt_parse_file(&crt, crt_file) == 0);
|
TEST_ASSERT(mbedtls_x509_crt_parse_file(&crt, crt_file) == 0);
|
||||||
res = mbedtls_x509_crt_info(buf, 2000, "", &crt);
|
res = mbedtls_x509_crt_info(buf, 2000, "", &crt);
|
||||||
@ -455,6 +458,7 @@ void x509_cert_info(char *crt_file, char *result_str)
|
|||||||
|
|
||||||
exit:
|
exit:
|
||||||
mbedtls_x509_crt_free(&crt);
|
mbedtls_x509_crt_free(&crt);
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
@ -467,6 +471,7 @@ void mbedtls_x509_crl_info(char *crl_file, char *result_str)
|
|||||||
|
|
||||||
mbedtls_x509_crl_init(&crl);
|
mbedtls_x509_crl_init(&crl);
|
||||||
memset(buf, 0, 2000);
|
memset(buf, 0, 2000);
|
||||||
|
USE_PSA_INIT();
|
||||||
|
|
||||||
TEST_ASSERT(mbedtls_x509_crl_parse_file(&crl, crl_file) == 0);
|
TEST_ASSERT(mbedtls_x509_crl_parse_file(&crl, crl_file) == 0);
|
||||||
res = mbedtls_x509_crl_info(buf, 2000, "", &crl);
|
res = mbedtls_x509_crl_info(buf, 2000, "", &crl);
|
||||||
@ -478,6 +483,7 @@ void mbedtls_x509_crl_info(char *crl_file, char *result_str)
|
|||||||
|
|
||||||
exit:
|
exit:
|
||||||
mbedtls_x509_crl_free(&crl);
|
mbedtls_x509_crl_free(&crl);
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
@ -489,11 +495,13 @@ void mbedtls_x509_crl_parse(char *crl_file, int result)
|
|||||||
|
|
||||||
mbedtls_x509_crl_init(&crl);
|
mbedtls_x509_crl_init(&crl);
|
||||||
memset(buf, 0, 2000);
|
memset(buf, 0, 2000);
|
||||||
|
USE_PSA_INIT();
|
||||||
|
|
||||||
TEST_ASSERT(mbedtls_x509_crl_parse_file(&crl, crl_file) == result);
|
TEST_ASSERT(mbedtls_x509_crl_parse_file(&crl, crl_file) == result);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
mbedtls_x509_crl_free(&crl);
|
mbedtls_x509_crl_free(&crl);
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
@ -506,6 +514,7 @@ void mbedtls_x509_csr_info(char *csr_file, char *result_str)
|
|||||||
|
|
||||||
mbedtls_x509_csr_init(&csr);
|
mbedtls_x509_csr_init(&csr);
|
||||||
memset(buf, 0, 2000);
|
memset(buf, 0, 2000);
|
||||||
|
USE_PSA_INIT();
|
||||||
|
|
||||||
TEST_ASSERT(mbedtls_x509_csr_parse_file(&csr, csr_file) == 0);
|
TEST_ASSERT(mbedtls_x509_csr_parse_file(&csr, csr_file) == 0);
|
||||||
res = mbedtls_x509_csr_info(buf, 2000, "", &csr);
|
res = mbedtls_x509_csr_info(buf, 2000, "", &csr);
|
||||||
@ -517,6 +526,7 @@ void mbedtls_x509_csr_info(char *csr_file, char *result_str)
|
|||||||
|
|
||||||
exit:
|
exit:
|
||||||
mbedtls_x509_csr_free(&csr);
|
mbedtls_x509_csr_free(&csr);
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
@ -526,6 +536,7 @@ void x509_verify_info(int flags, char *prefix, char *result_str)
|
|||||||
char buf[2000];
|
char buf[2000];
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
|
USE_PSA_INIT();
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
|
|
||||||
res = mbedtls_x509_crt_verify_info(buf, sizeof(buf), prefix, flags);
|
res = mbedtls_x509_crt_verify_info(buf, sizeof(buf), prefix, flags);
|
||||||
@ -533,6 +544,9 @@ void x509_verify_info(int flags, char *prefix, char *result_str)
|
|||||||
TEST_ASSERT(res >= 0);
|
TEST_ASSERT(res >= 0);
|
||||||
|
|
||||||
TEST_ASSERT(strcmp(buf, result_str) == 0);
|
TEST_ASSERT(strcmp(buf, result_str) == 0);
|
||||||
|
|
||||||
|
exit:
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
@ -556,10 +570,10 @@ void x509_verify_restart(char *crt_file, char *ca_file,
|
|||||||
* - x509_verify() for server5 -> test-ca2: ~ 18800
|
* - x509_verify() for server5 -> test-ca2: ~ 18800
|
||||||
* - x509_verify() for server10 -> int-ca3 -> int-ca2: ~ 25500
|
* - x509_verify() for server10 -> int-ca3 -> int-ca2: ~ 25500
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mbedtls_x509_crt_restart_init(&rs_ctx);
|
mbedtls_x509_crt_restart_init(&rs_ctx);
|
||||||
mbedtls_x509_crt_init(&crt);
|
mbedtls_x509_crt_init(&crt);
|
||||||
mbedtls_x509_crt_init(&ca);
|
mbedtls_x509_crt_init(&ca);
|
||||||
|
USE_PSA_INIT();
|
||||||
|
|
||||||
TEST_ASSERT(mbedtls_x509_crt_parse_file(&crt, crt_file) == 0);
|
TEST_ASSERT(mbedtls_x509_crt_parse_file(&crt, crt_file) == 0);
|
||||||
TEST_ASSERT(mbedtls_x509_crt_parse_file(&ca, ca_file) == 0);
|
TEST_ASSERT(mbedtls_x509_crt_parse_file(&ca, ca_file) == 0);
|
||||||
@ -589,6 +603,7 @@ exit:
|
|||||||
mbedtls_x509_crt_restart_free(&rs_ctx);
|
mbedtls_x509_crt_restart_free(&rs_ctx);
|
||||||
mbedtls_x509_crt_free(&crt);
|
mbedtls_x509_crt_free(&crt);
|
||||||
mbedtls_x509_crt_free(&ca);
|
mbedtls_x509_crt_free(&ca);
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
@ -695,6 +710,7 @@ void x509_verify_ca_cb_failure(char *crt_file, char *ca_file, char *name,
|
|||||||
|
|
||||||
mbedtls_x509_crt_init(&crt);
|
mbedtls_x509_crt_init(&crt);
|
||||||
mbedtls_x509_crt_init(&ca);
|
mbedtls_x509_crt_init(&ca);
|
||||||
|
USE_PSA_INIT();
|
||||||
|
|
||||||
TEST_ASSERT(mbedtls_x509_crt_parse_file(&crt, crt_file) == 0);
|
TEST_ASSERT(mbedtls_x509_crt_parse_file(&crt, crt_file) == 0);
|
||||||
TEST_ASSERT(mbedtls_x509_crt_parse_file(&ca, ca_file) == 0);
|
TEST_ASSERT(mbedtls_x509_crt_parse_file(&ca, ca_file) == 0);
|
||||||
@ -712,6 +728,7 @@ void x509_verify_ca_cb_failure(char *crt_file, char *ca_file, char *name,
|
|||||||
exit:
|
exit:
|
||||||
mbedtls_x509_crt_free(&crt);
|
mbedtls_x509_crt_free(&crt);
|
||||||
mbedtls_x509_crt_free(&ca);
|
mbedtls_x509_crt_free(&ca);
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
@ -762,6 +779,7 @@ void mbedtls_x509_dn_gets(char *crt_file, char *entity, char *result_str)
|
|||||||
|
|
||||||
mbedtls_x509_crt_init(&crt);
|
mbedtls_x509_crt_init(&crt);
|
||||||
memset(buf, 0, 2000);
|
memset(buf, 0, 2000);
|
||||||
|
USE_PSA_INIT();
|
||||||
|
|
||||||
TEST_ASSERT(mbedtls_x509_crt_parse_file(&crt, crt_file) == 0);
|
TEST_ASSERT(mbedtls_x509_crt_parse_file(&crt, crt_file) == 0);
|
||||||
if (strcmp(entity, "subject") == 0) {
|
if (strcmp(entity, "subject") == 0) {
|
||||||
@ -779,6 +797,7 @@ void mbedtls_x509_dn_gets(char *crt_file, char *entity, char *result_str)
|
|||||||
|
|
||||||
exit:
|
exit:
|
||||||
mbedtls_x509_crt_free(&crt);
|
mbedtls_x509_crt_free(&crt);
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
@ -794,6 +813,7 @@ void mbedtls_x509_dn_gets_subject_replace(char *crt_file,
|
|||||||
|
|
||||||
mbedtls_x509_crt_init(&crt);
|
mbedtls_x509_crt_init(&crt);
|
||||||
memset(buf, 0, 2000);
|
memset(buf, 0, 2000);
|
||||||
|
USE_PSA_INIT();
|
||||||
|
|
||||||
TEST_ASSERT(mbedtls_x509_crt_parse_file(&crt, crt_file) == 0);
|
TEST_ASSERT(mbedtls_x509_crt_parse_file(&crt, crt_file) == 0);
|
||||||
crt.subject.next->val.p = (unsigned char *) new_subject_ou;
|
crt.subject.next->val.p = (unsigned char *) new_subject_ou;
|
||||||
@ -810,6 +830,7 @@ void mbedtls_x509_dn_gets_subject_replace(char *crt_file,
|
|||||||
}
|
}
|
||||||
exit:
|
exit:
|
||||||
mbedtls_x509_crt_free(&crt);
|
mbedtls_x509_crt_free(&crt);
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
@ -823,6 +844,7 @@ void mbedtls_x509_get_name(char *rdn_sequence, int exp_ret)
|
|||||||
mbedtls_x509_name *allocated, *prev;
|
mbedtls_x509_name *allocated, *prev;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
USE_PSA_INIT();
|
||||||
memset(&head, 0, sizeof(head));
|
memset(&head, 0, sizeof(head));
|
||||||
|
|
||||||
name = mbedtls_test_unhexify_alloc(rdn_sequence, &name_len);
|
name = mbedtls_test_unhexify_alloc(rdn_sequence, &name_len);
|
||||||
@ -843,6 +865,9 @@ void mbedtls_x509_get_name(char *rdn_sequence, int exp_ret)
|
|||||||
TEST_EQUAL(ret, exp_ret);
|
TEST_EQUAL(ret, exp_ret);
|
||||||
|
|
||||||
mbedtls_free(name);
|
mbedtls_free(name);
|
||||||
|
|
||||||
|
exit:
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
@ -852,6 +877,7 @@ void mbedtls_x509_time_is_past(char *crt_file, char *entity, int result)
|
|||||||
mbedtls_x509_crt crt;
|
mbedtls_x509_crt crt;
|
||||||
|
|
||||||
mbedtls_x509_crt_init(&crt);
|
mbedtls_x509_crt_init(&crt);
|
||||||
|
USE_PSA_INIT();
|
||||||
|
|
||||||
TEST_ASSERT(mbedtls_x509_crt_parse_file(&crt, crt_file) == 0);
|
TEST_ASSERT(mbedtls_x509_crt_parse_file(&crt, crt_file) == 0);
|
||||||
|
|
||||||
@ -865,6 +891,7 @@ void mbedtls_x509_time_is_past(char *crt_file, char *entity, int result)
|
|||||||
|
|
||||||
exit:
|
exit:
|
||||||
mbedtls_x509_crt_free(&crt);
|
mbedtls_x509_crt_free(&crt);
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
@ -874,6 +901,7 @@ void mbedtls_x509_time_is_future(char *crt_file, char *entity, int result)
|
|||||||
mbedtls_x509_crt crt;
|
mbedtls_x509_crt crt;
|
||||||
|
|
||||||
mbedtls_x509_crt_init(&crt);
|
mbedtls_x509_crt_init(&crt);
|
||||||
|
USE_PSA_INIT();
|
||||||
|
|
||||||
TEST_ASSERT(mbedtls_x509_crt_parse_file(&crt, crt_file) == 0);
|
TEST_ASSERT(mbedtls_x509_crt_parse_file(&crt, crt_file) == 0);
|
||||||
|
|
||||||
@ -887,6 +915,7 @@ void mbedtls_x509_time_is_future(char *crt_file, char *entity, int result)
|
|||||||
|
|
||||||
exit:
|
exit:
|
||||||
mbedtls_x509_crt_free(&crt);
|
mbedtls_x509_crt_free(&crt);
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
@ -896,11 +925,13 @@ void x509parse_crt_file(char *crt_file, int result)
|
|||||||
mbedtls_x509_crt crt;
|
mbedtls_x509_crt crt;
|
||||||
|
|
||||||
mbedtls_x509_crt_init(&crt);
|
mbedtls_x509_crt_init(&crt);
|
||||||
|
USE_PSA_INIT();
|
||||||
|
|
||||||
TEST_ASSERT(mbedtls_x509_crt_parse_file(&crt, crt_file) == result);
|
TEST_ASSERT(mbedtls_x509_crt_parse_file(&crt, crt_file) == result);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
mbedtls_x509_crt_free(&crt);
|
mbedtls_x509_crt_free(&crt);
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
@ -913,6 +944,7 @@ void x509parse_crt(data_t *buf, char *result_str, int result)
|
|||||||
|
|
||||||
mbedtls_x509_crt_init(&crt);
|
mbedtls_x509_crt_init(&crt);
|
||||||
memset(output, 0, 2000);
|
memset(output, 0, 2000);
|
||||||
|
USE_PSA_INIT();
|
||||||
|
|
||||||
TEST_ASSERT(mbedtls_x509_crt_parse_der(&crt, buf->x, buf->len) == (result));
|
TEST_ASSERT(mbedtls_x509_crt_parse_der(&crt, buf->x, buf->len) == (result));
|
||||||
if ((result) == 0) {
|
if ((result) == 0) {
|
||||||
@ -970,6 +1002,7 @@ void x509parse_crt(data_t *buf, char *result_str, int result)
|
|||||||
|
|
||||||
exit:
|
exit:
|
||||||
mbedtls_x509_crt_free(&crt);
|
mbedtls_x509_crt_free(&crt);
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
@ -987,6 +1020,7 @@ void x509parse_crt_cb(data_t *buf, char *result_str, int result)
|
|||||||
|
|
||||||
mbedtls_x509_crt_init(&crt);
|
mbedtls_x509_crt_init(&crt);
|
||||||
memset(output, 0, 2000);
|
memset(output, 0, 2000);
|
||||||
|
USE_PSA_INIT();
|
||||||
|
|
||||||
TEST_ASSERT(mbedtls_x509_crt_parse_der_with_ext_cb(&crt, buf->x, buf->len, 0, parse_crt_ext_cb,
|
TEST_ASSERT(mbedtls_x509_crt_parse_der_with_ext_cb(&crt, buf->x, buf->len, 0, parse_crt_ext_cb,
|
||||||
&oid) == (result));
|
&oid) == (result));
|
||||||
@ -1016,6 +1050,7 @@ void x509parse_crt_cb(data_t *buf, char *result_str, int result)
|
|||||||
|
|
||||||
exit:
|
exit:
|
||||||
mbedtls_x509_crt_free(&crt);
|
mbedtls_x509_crt_free(&crt);
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
@ -1028,7 +1063,7 @@ void x509parse_crl(data_t *buf, char *result_str, int result)
|
|||||||
|
|
||||||
mbedtls_x509_crl_init(&crl);
|
mbedtls_x509_crl_init(&crl);
|
||||||
memset(output, 0, 2000);
|
memset(output, 0, 2000);
|
||||||
|
USE_PSA_INIT();
|
||||||
|
|
||||||
TEST_ASSERT(mbedtls_x509_crl_parse(&crl, buf->x, buf->len) == (result));
|
TEST_ASSERT(mbedtls_x509_crl_parse(&crl, buf->x, buf->len) == (result));
|
||||||
if ((result) == 0) {
|
if ((result) == 0) {
|
||||||
@ -1042,6 +1077,7 @@ void x509parse_crl(data_t *buf, char *result_str, int result)
|
|||||||
|
|
||||||
exit:
|
exit:
|
||||||
mbedtls_x509_crl_free(&crl);
|
mbedtls_x509_crl_free(&crl);
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
@ -1054,6 +1090,7 @@ void mbedtls_x509_csr_parse(data_t *csr_der, char *ref_out, int ref_ret)
|
|||||||
|
|
||||||
mbedtls_x509_csr_init(&csr);
|
mbedtls_x509_csr_init(&csr);
|
||||||
memset(my_out, 0, sizeof(my_out));
|
memset(my_out, 0, sizeof(my_out));
|
||||||
|
USE_PSA_INIT();
|
||||||
|
|
||||||
my_ret = mbedtls_x509_csr_parse_der(&csr, csr_der->x, csr_der->len);
|
my_ret = mbedtls_x509_csr_parse_der(&csr, csr_der->x, csr_der->len);
|
||||||
TEST_ASSERT(my_ret == ref_ret);
|
TEST_ASSERT(my_ret == ref_ret);
|
||||||
@ -1066,6 +1103,7 @@ void mbedtls_x509_csr_parse(data_t *csr_der, char *ref_out, int ref_ret)
|
|||||||
|
|
||||||
exit:
|
exit:
|
||||||
mbedtls_x509_csr_free(&csr);
|
mbedtls_x509_csr_free(&csr);
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
@ -1076,6 +1114,7 @@ void mbedtls_x509_crt_parse_path(char *crt_path, int ret, int nb_crt)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
mbedtls_x509_crt_init(&chain);
|
mbedtls_x509_crt_init(&chain);
|
||||||
|
USE_PSA_INIT();
|
||||||
|
|
||||||
TEST_ASSERT(mbedtls_x509_crt_parse_path(&chain, crt_path) == ret);
|
TEST_ASSERT(mbedtls_x509_crt_parse_path(&chain, crt_path) == ret);
|
||||||
|
|
||||||
@ -1090,6 +1129,7 @@ void mbedtls_x509_crt_parse_path(char *crt_path, int ret, int nb_crt)
|
|||||||
|
|
||||||
exit:
|
exit:
|
||||||
mbedtls_x509_crt_free(&chain);
|
mbedtls_x509_crt_free(&chain);
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
@ -1106,10 +1146,8 @@ void mbedtls_x509_crt_verify_max(char *ca_file, char *chain_dir, int nb_int,
|
|||||||
* We expect chain_dir to contain certificates 00.crt, 01.crt, etc.
|
* We expect chain_dir to contain certificates 00.crt, 01.crt, etc.
|
||||||
* with NN.crt signed by NN-1.crt
|
* with NN.crt signed by NN-1.crt
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mbedtls_x509_crt_init(&trusted);
|
mbedtls_x509_crt_init(&trusted);
|
||||||
mbedtls_x509_crt_init(&chain);
|
mbedtls_x509_crt_init(&chain);
|
||||||
|
|
||||||
USE_PSA_INIT();
|
USE_PSA_INIT();
|
||||||
|
|
||||||
/* Load trusted root */
|
/* Load trusted root */
|
||||||
@ -1148,7 +1186,6 @@ void mbedtls_x509_crt_verify_chain(char *chain_paths, char *trusted_ca,
|
|||||||
|
|
||||||
mbedtls_x509_crt_init(&chain);
|
mbedtls_x509_crt_init(&chain);
|
||||||
mbedtls_x509_crt_init(&trusted);
|
mbedtls_x509_crt_init(&trusted);
|
||||||
|
|
||||||
USE_PSA_INIT();
|
USE_PSA_INIT();
|
||||||
|
|
||||||
while ((act = mystrsep(&chain_paths, " ")) != NULL) {
|
while ((act = mystrsep(&chain_paths, " ")) != NULL) {
|
||||||
@ -1188,7 +1225,7 @@ void x509_oid_desc(data_t *buf, char *ref_desc)
|
|||||||
const char *desc = NULL;
|
const char *desc = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
USE_PSA_INIT();
|
||||||
oid.tag = MBEDTLS_ASN1_OID;
|
oid.tag = MBEDTLS_ASN1_OID;
|
||||||
oid.p = buf->x;
|
oid.p = buf->x;
|
||||||
oid.len = buf->len;
|
oid.len = buf->len;
|
||||||
@ -1203,6 +1240,9 @@ void x509_oid_desc(data_t *buf, char *ref_desc)
|
|||||||
TEST_ASSERT(desc != NULL);
|
TEST_ASSERT(desc != NULL);
|
||||||
TEST_ASSERT(strcmp(desc, ref_desc) == 0);
|
TEST_ASSERT(strcmp(desc, ref_desc) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exit:
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
@ -1212,6 +1252,7 @@ void x509_oid_numstr(data_t *oid_buf, char *numstr, int blen, int ret)
|
|||||||
mbedtls_x509_buf oid;
|
mbedtls_x509_buf oid;
|
||||||
char num_buf[100];
|
char num_buf[100];
|
||||||
|
|
||||||
|
USE_PSA_INIT();
|
||||||
memset(num_buf, 0x2a, sizeof(num_buf));
|
memset(num_buf, 0x2a, sizeof(num_buf));
|
||||||
|
|
||||||
oid.tag = MBEDTLS_ASN1_OID;
|
oid.tag = MBEDTLS_ASN1_OID;
|
||||||
@ -1226,6 +1267,9 @@ void x509_oid_numstr(data_t *oid_buf, char *numstr, int blen, int ret)
|
|||||||
TEST_ASSERT(num_buf[ret] == 0);
|
TEST_ASSERT(num_buf[ret] == 0);
|
||||||
TEST_ASSERT(strcmp(num_buf, numstr) == 0);
|
TEST_ASSERT(strcmp(num_buf, numstr) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exit:
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
@ -1235,6 +1279,7 @@ void x509_check_key_usage(char *crt_file, int usage, int ret)
|
|||||||
mbedtls_x509_crt crt;
|
mbedtls_x509_crt crt;
|
||||||
|
|
||||||
mbedtls_x509_crt_init(&crt);
|
mbedtls_x509_crt_init(&crt);
|
||||||
|
USE_PSA_INIT();
|
||||||
|
|
||||||
TEST_ASSERT(mbedtls_x509_crt_parse_file(&crt, crt_file) == 0);
|
TEST_ASSERT(mbedtls_x509_crt_parse_file(&crt, crt_file) == 0);
|
||||||
|
|
||||||
@ -1242,6 +1287,7 @@ void x509_check_key_usage(char *crt_file, int usage, int ret)
|
|||||||
|
|
||||||
exit:
|
exit:
|
||||||
mbedtls_x509_crt_free(&crt);
|
mbedtls_x509_crt_free(&crt);
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
@ -1252,7 +1298,7 @@ void x509_check_extended_key_usage(char *crt_file, data_t *oid, int ret
|
|||||||
mbedtls_x509_crt crt;
|
mbedtls_x509_crt crt;
|
||||||
|
|
||||||
mbedtls_x509_crt_init(&crt);
|
mbedtls_x509_crt_init(&crt);
|
||||||
|
USE_PSA_INIT();
|
||||||
|
|
||||||
TEST_ASSERT(mbedtls_x509_crt_parse_file(&crt, crt_file) == 0);
|
TEST_ASSERT(mbedtls_x509_crt_parse_file(&crt, crt_file) == 0);
|
||||||
|
|
||||||
@ -1261,6 +1307,7 @@ void x509_check_extended_key_usage(char *crt_file, data_t *oid, int ret
|
|||||||
|
|
||||||
exit:
|
exit:
|
||||||
mbedtls_x509_crt_free(&crt);
|
mbedtls_x509_crt_free(&crt);
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
@ -1273,6 +1320,7 @@ void x509_get_time(int tag, char *time_str, int ret, int year, int mon,
|
|||||||
unsigned char *start = buf;
|
unsigned char *start = buf;
|
||||||
unsigned char *end = buf;
|
unsigned char *end = buf;
|
||||||
|
|
||||||
|
USE_PSA_INIT();
|
||||||
memset(&time, 0x00, sizeof(time));
|
memset(&time, 0x00, sizeof(time));
|
||||||
*end = (unsigned char) tag; end++;
|
*end = (unsigned char) tag; end++;
|
||||||
*end = strlen(time_str);
|
*end = strlen(time_str);
|
||||||
@ -1290,6 +1338,9 @@ void x509_get_time(int tag, char *time_str, int ret, int year, int mon,
|
|||||||
TEST_ASSERT(min == time.min);
|
TEST_ASSERT(min == time.min);
|
||||||
TEST_ASSERT(sec == time.sec);
|
TEST_ASSERT(sec == time.sec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exit:
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
@ -1303,6 +1354,8 @@ void x509_parse_rsassa_pss_params(data_t *params, int params_tag,
|
|||||||
mbedtls_md_type_t my_msg_md, my_mgf_md;
|
mbedtls_md_type_t my_msg_md, my_mgf_md;
|
||||||
int my_salt_len;
|
int my_salt_len;
|
||||||
|
|
||||||
|
USE_PSA_INIT();
|
||||||
|
|
||||||
buf.p = params->x;
|
buf.p = params->x;
|
||||||
buf.len = params->len;
|
buf.len = params->len;
|
||||||
buf.tag = params_tag;
|
buf.tag = params_tag;
|
||||||
@ -1319,13 +1372,17 @@ void x509_parse_rsassa_pss_params(data_t *params, int params_tag,
|
|||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
;;
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
/* BEGIN_CASE depends_on:MBEDTLS_X509_CRT_PARSE_C:MBEDTLS_SELF_TEST */
|
/* BEGIN_CASE depends_on:MBEDTLS_X509_CRT_PARSE_C:MBEDTLS_SELF_TEST */
|
||||||
void x509_selftest()
|
void x509_selftest()
|
||||||
{
|
{
|
||||||
|
USE_PSA_INIT();
|
||||||
TEST_ASSERT(mbedtls_x509_self_test(1) == 0);
|
TEST_ASSERT(mbedtls_x509_self_test(1) == 0);
|
||||||
|
|
||||||
|
exit:
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
@ -145,8 +145,9 @@ void x509_csr_check(char *key_file, char *cert_req_check_file, int md_type,
|
|||||||
memset(&rnd_info, 0x2a, sizeof(mbedtls_test_rnd_pseudo_info));
|
memset(&rnd_info, 0x2a, sizeof(mbedtls_test_rnd_pseudo_info));
|
||||||
|
|
||||||
mbedtls_x509write_csr_init(&req);
|
mbedtls_x509write_csr_init(&req);
|
||||||
|
|
||||||
mbedtls_pk_init(&key);
|
mbedtls_pk_init(&key);
|
||||||
|
USE_PSA_INIT();
|
||||||
|
|
||||||
TEST_ASSERT(mbedtls_pk_parse_keyfile(&key, key_file, NULL) == 0);
|
TEST_ASSERT(mbedtls_pk_parse_keyfile(&key, key_file, NULL) == 0);
|
||||||
|
|
||||||
mbedtls_x509write_csr_set_md_alg(&req, md_type);
|
mbedtls_x509write_csr_set_md_alg(&req, md_type);
|
||||||
@ -197,6 +198,7 @@ void x509_csr_check(char *key_file, char *cert_req_check_file, int md_type,
|
|||||||
exit:
|
exit:
|
||||||
mbedtls_x509write_csr_free(&req);
|
mbedtls_x509write_csr_free(&req);
|
||||||
mbedtls_pk_free(&key);
|
mbedtls_pk_free(&key);
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
@ -246,12 +248,11 @@ void x509_csr_check_opaque(char *key_file, int md_type, int key_usage,
|
|||||||
buf[pem_len] = '\0';
|
buf[pem_len] = '\0';
|
||||||
TEST_ASSERT(x509_crt_verifycsr(buf, pem_len + 1) == 0);
|
TEST_ASSERT(x509_crt_verifycsr(buf, pem_len + 1) == 0);
|
||||||
|
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
mbedtls_x509write_csr_free(&req);
|
mbedtls_x509write_csr_free(&req);
|
||||||
mbedtls_pk_free(&key);
|
mbedtls_pk_free(&key);
|
||||||
psa_destroy_key(key_id);
|
psa_destroy_key(key_id);
|
||||||
PSA_DONE();
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
@ -287,6 +288,7 @@ void x509_crt_check(char *subject_key_file, char *subject_pwd,
|
|||||||
mbedtls_pk_init(&issuer_key_alt);
|
mbedtls_pk_init(&issuer_key_alt);
|
||||||
|
|
||||||
mbedtls_x509write_crt_init(&crt);
|
mbedtls_x509write_crt_init(&crt);
|
||||||
|
USE_PSA_INIT();
|
||||||
|
|
||||||
TEST_ASSERT(mbedtls_pk_parse_keyfile(&subject_key, subject_key_file,
|
TEST_ASSERT(mbedtls_pk_parse_keyfile(&subject_key, subject_key_file,
|
||||||
subject_pwd) == 0);
|
subject_pwd) == 0);
|
||||||
@ -422,6 +424,7 @@ exit:
|
|||||||
mbedtls_pk_free(&subject_key);
|
mbedtls_pk_free(&subject_key);
|
||||||
mbedtls_pk_free(&issuer_key);
|
mbedtls_pk_free(&issuer_key);
|
||||||
mbedtls_mpi_free(&serial);
|
mbedtls_mpi_free(&serial);
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
@ -432,6 +435,7 @@ void x509_set_serial_check()
|
|||||||
mbedtls_mpi serial_mpi;
|
mbedtls_mpi serial_mpi;
|
||||||
uint8_t invalid_serial[MBEDTLS_X509_RFC5280_MAX_SERIAL_LEN + 1];
|
uint8_t invalid_serial[MBEDTLS_X509_RFC5280_MAX_SERIAL_LEN + 1];
|
||||||
|
|
||||||
|
USE_PSA_INIT();
|
||||||
memset(invalid_serial, 0x01, sizeof(invalid_serial));
|
memset(invalid_serial, 0x01, sizeof(invalid_serial));
|
||||||
|
|
||||||
mbedtls_mpi_init(&serial_mpi);
|
mbedtls_mpi_init(&serial_mpi);
|
||||||
@ -442,6 +446,7 @@ void x509_set_serial_check()
|
|||||||
|
|
||||||
exit:
|
exit:
|
||||||
mbedtls_mpi_free(&serial_mpi);
|
mbedtls_mpi_free(&serial_mpi);
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
@ -455,6 +460,8 @@ void mbedtls_x509_string_to_names(char *name, char *parsed_name, int result
|
|||||||
mbedtls_x509_name parsed, *parsed_cur, *parsed_prv;
|
mbedtls_x509_name parsed, *parsed_cur, *parsed_prv;
|
||||||
unsigned char buf[1024], out[1024], *c;
|
unsigned char buf[1024], out[1024], *c;
|
||||||
|
|
||||||
|
USE_PSA_INIT();
|
||||||
|
|
||||||
memset(&parsed, 0, sizeof(parsed));
|
memset(&parsed, 0, sizeof(parsed));
|
||||||
memset(out, 0, sizeof(out));
|
memset(out, 0, sizeof(out));
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
@ -488,5 +495,6 @@ exit:
|
|||||||
parsed_cur = parsed_cur->next;
|
parsed_cur = parsed_cur->next;
|
||||||
mbedtls_free(parsed_prv);
|
mbedtls_free(parsed_prv);
|
||||||
}
|
}
|
||||||
|
USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user