X.509: fix test failures
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
This commit is contained in:
parent
a946489efd
commit
33a13028e5
3 changed files with 17 additions and 18 deletions
|
@ -75,6 +75,7 @@ void pkcs7_verify(char *pkcs7_file,
|
||||||
mbedtls_pkcs7 pkcs7;
|
mbedtls_pkcs7 pkcs7;
|
||||||
mbedtls_x509_crt **crts = NULL;
|
mbedtls_x509_crt **crts = NULL;
|
||||||
|
|
||||||
|
MD_OR_USE_PSA_INIT();
|
||||||
|
|
||||||
/* crt_files are space seprated list */
|
/* crt_files are space seprated list */
|
||||||
for (i = 0; i < strlen(crt_files); i++) {
|
for (i = 0; i < strlen(crt_files); i++) {
|
||||||
|
@ -104,8 +105,6 @@ void pkcs7_verify(char *pkcs7_file,
|
||||||
mbedtls_x509_crt_init(crts[i]);
|
mbedtls_x509_crt_init(crts[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
USE_PSA_INIT();
|
|
||||||
|
|
||||||
res = mbedtls_pk_load_file(pkcs7_file, &pkcs7_buf, &buflen);
|
res = mbedtls_pk_load_file(pkcs7_file, &pkcs7_buf, &buflen);
|
||||||
TEST_EQUAL(res, 0);
|
TEST_EQUAL(res, 0);
|
||||||
|
|
||||||
|
@ -164,6 +163,6 @@ exit:
|
||||||
mbedtls_free(crts);
|
mbedtls_free(crts);
|
||||||
mbedtls_free(data);
|
mbedtls_free(data);
|
||||||
mbedtls_free(pkcs7_buf);
|
mbedtls_free(pkcs7_buf);
|
||||||
USE_PSA_DONE();
|
MD_OR_USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
|
@ -592,7 +592,7 @@ void x509_verify_restart(char *crt_file, char *ca_file,
|
||||||
mbedtls_x509_crt_init(&crt);
|
mbedtls_x509_crt_init(&crt);
|
||||||
mbedtls_x509_crt_init(&ca);
|
mbedtls_x509_crt_init(&ca);
|
||||||
|
|
||||||
USE_PSA_INIT();
|
MD_OR_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);
|
||||||
|
@ -622,7 +622,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();
|
MD_OR_USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
|
@ -645,7 +645,7 @@ void x509_verify(char *crt_file, char *ca_file, char *crl_file,
|
||||||
mbedtls_x509_crt_init(&ca);
|
mbedtls_x509_crt_init(&ca);
|
||||||
mbedtls_x509_crl_init(&crl);
|
mbedtls_x509_crl_init(&crl);
|
||||||
|
|
||||||
USE_PSA_INIT();
|
MD_OR_USE_PSA_INIT();
|
||||||
|
|
||||||
if (strcmp(cn_name_str, "NULL") != 0) {
|
if (strcmp(cn_name_str, "NULL") != 0) {
|
||||||
cn_name = cn_name_str;
|
cn_name = cn_name_str;
|
||||||
|
@ -714,7 +714,7 @@ exit:
|
||||||
mbedtls_x509_crt_free(&crt);
|
mbedtls_x509_crt_free(&crt);
|
||||||
mbedtls_x509_crt_free(&ca);
|
mbedtls_x509_crt_free(&ca);
|
||||||
mbedtls_x509_crl_free(&crl);
|
mbedtls_x509_crl_free(&crl);
|
||||||
USE_PSA_DONE();
|
MD_OR_USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
|
@ -763,7 +763,7 @@ void x509_verify_callback(char *crt_file, char *ca_file, char *name,
|
||||||
mbedtls_x509_crt_init(&ca);
|
mbedtls_x509_crt_init(&ca);
|
||||||
verify_print_init(&vrfy_ctx);
|
verify_print_init(&vrfy_ctx);
|
||||||
|
|
||||||
USE_PSA_INIT();
|
MD_OR_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);
|
||||||
|
@ -783,7 +783,7 @@ void x509_verify_callback(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();
|
MD_OR_USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
|
@ -1246,7 +1246,7 @@ void mbedtls_x509_crt_verify_max(char *ca_file, char *chain_dir, int nb_int,
|
||||||
mbedtls_x509_crt_init(&trusted);
|
mbedtls_x509_crt_init(&trusted);
|
||||||
mbedtls_x509_crt_init(&chain);
|
mbedtls_x509_crt_init(&chain);
|
||||||
|
|
||||||
USE_PSA_INIT();
|
MD_OR_USE_PSA_INIT();
|
||||||
|
|
||||||
/* Load trusted root */
|
/* Load trusted root */
|
||||||
TEST_ASSERT(mbedtls_x509_crt_parse_file(&trusted, ca_file) == 0);
|
TEST_ASSERT(mbedtls_x509_crt_parse_file(&trusted, ca_file) == 0);
|
||||||
|
@ -1267,7 +1267,7 @@ void mbedtls_x509_crt_verify_max(char *ca_file, char *chain_dir, int nb_int,
|
||||||
exit:
|
exit:
|
||||||
mbedtls_x509_crt_free(&chain);
|
mbedtls_x509_crt_free(&chain);
|
||||||
mbedtls_x509_crt_free(&trusted);
|
mbedtls_x509_crt_free(&trusted);
|
||||||
USE_PSA_DONE();
|
MD_OR_USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
|
@ -1285,7 +1285,7 @@ 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();
|
MD_OR_USE_PSA_INIT();
|
||||||
|
|
||||||
while ((act = mystrsep(&chain_paths, " ")) != NULL) {
|
while ((act = mystrsep(&chain_paths, " ")) != NULL) {
|
||||||
TEST_ASSERT(mbedtls_x509_crt_parse_file(&chain, act) == 0);
|
TEST_ASSERT(mbedtls_x509_crt_parse_file(&chain, act) == 0);
|
||||||
|
@ -1313,7 +1313,7 @@ void mbedtls_x509_crt_verify_chain(char *chain_paths, char *trusted_ca,
|
||||||
exit:
|
exit:
|
||||||
mbedtls_x509_crt_free(&trusted);
|
mbedtls_x509_crt_free(&trusted);
|
||||||
mbedtls_x509_crt_free(&chain);
|
mbedtls_x509_crt_free(&chain);
|
||||||
USE_PSA_DONE();
|
MD_OR_USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
|
|
|
@ -178,7 +178,7 @@ void x509_csr_check(char *key_file, char *cert_req_check_file, int md_type,
|
||||||
|
|
||||||
mbedtls_x509write_csr_init(&req);
|
mbedtls_x509write_csr_init(&req);
|
||||||
|
|
||||||
USE_PSA_INIT();
|
MD_OR_USE_PSA_INIT();
|
||||||
|
|
||||||
mbedtls_pk_init(&key);
|
mbedtls_pk_init(&key);
|
||||||
TEST_ASSERT(mbedtls_pk_parse_keyfile(&key, key_file, NULL,
|
TEST_ASSERT(mbedtls_pk_parse_keyfile(&key, key_file, NULL,
|
||||||
|
@ -249,7 +249,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();
|
MD_OR_USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ void x509_csr_check_opaque(char *key_file, int md_type, int key_usage,
|
||||||
|
|
||||||
mbedtls_x509write_csr_init(&req);
|
mbedtls_x509write_csr_init(&req);
|
||||||
|
|
||||||
USE_PSA_INIT();
|
MD_OR_USE_PSA_INIT();
|
||||||
|
|
||||||
md_alg_psa = mbedtls_hash_info_psa_from_md((mbedtls_md_type_t) md_type);
|
md_alg_psa = mbedtls_hash_info_psa_from_md((mbedtls_md_type_t) md_type);
|
||||||
TEST_ASSERT(md_alg_psa != MBEDTLS_MD_NONE);
|
TEST_ASSERT(md_alg_psa != MBEDTLS_MD_NONE);
|
||||||
|
@ -357,7 +357,7 @@ void x509_crt_check(char *subject_key_file, char *subject_pwd,
|
||||||
mbedtls_mpi_init(&serial_mpi);
|
mbedtls_mpi_init(&serial_mpi);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
USE_PSA_INIT();
|
MD_OR_USE_PSA_INIT();
|
||||||
|
|
||||||
mbedtls_pk_init(&subject_key);
|
mbedtls_pk_init(&subject_key);
|
||||||
mbedtls_pk_init(&issuer_key);
|
mbedtls_pk_init(&issuer_key);
|
||||||
|
@ -588,7 +588,7 @@ exit:
|
||||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
psa_destroy_key(key_id);
|
psa_destroy_key(key_id);
|
||||||
#endif
|
#endif
|
||||||
USE_PSA_DONE();
|
MD_OR_USE_PSA_DONE();
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue