Merge pull request #10192 from valeriosetti/fixes-for-ecp-restartable-part2

[development] Some pre-requisites for psa#299
This commit is contained in:
Gilles Peskine
2025-06-05 07:50:53 +00:00
committed by GitHub
6 changed files with 80 additions and 84 deletions

View File

@@ -33,9 +33,17 @@ static int pkcs7_parse_buffer(unsigned char *pkcs7_buf, int buflen)
void pkcs7_asn1_fail(data_t *pkcs7_buf)
{
int res;
/* PKCS7 uses X509 which itself relies on PK under the hood and the latter
* can use PSA to store keys and perform operations so psa_crypto_init()
* must be called before. */
USE_PSA_INIT();
res = pkcs7_parse_buffer(pkcs7_buf->x, pkcs7_buf->len);
TEST_ASSERT(res != MBEDTLS_PKCS7_SIGNED_DATA);
exit:
USE_PSA_DONE();
}
/* END_CASE */
@@ -46,6 +54,11 @@ void pkcs7_parse(char *pkcs7_file, int res_expect)
size_t buflen;
int res;
/* PKCS7 uses X509 which itself relies on PK under the hood and the latter
* can use PSA to store keys and perform operations so psa_crypto_init()
* must be called before. */
USE_PSA_INIT();
res = mbedtls_pk_load_file(pkcs7_file, &pkcs7_buf, &buflen);
TEST_EQUAL(res, 0);
@@ -54,6 +67,7 @@ void pkcs7_parse(char *pkcs7_file, int res_expect)
exit:
mbedtls_free(pkcs7_buf);
USE_PSA_DONE();
}
/* END_CASE */
@@ -77,7 +91,7 @@ void pkcs7_verify(char *pkcs7_file,
mbedtls_pkcs7 pkcs7;
mbedtls_x509_crt **crts = NULL;
MD_OR_USE_PSA_INIT();
USE_PSA_INIT();
mbedtls_pkcs7_init(&pkcs7);
@@ -166,6 +180,6 @@ exit:
mbedtls_free(crts);
mbedtls_free(data);
mbedtls_free(pkcs7_buf);
MD_OR_USE_PSA_DONE();
USE_PSA_DONE();
}
/* END_CASE */

View File

@@ -1669,6 +1669,9 @@ void x509_crt_parse_subjectkeyid(char *file, data_t *subjectKeyId, int ref_ret)
mbedtls_x509_crt crt;
mbedtls_x509_crt_init(&crt);
/* X509 relies on PK under the hood and the latter can use PSA to store keys
* and perform operations so psa_crypto_init() must be called before. */
USE_PSA_INIT();
TEST_EQUAL(mbedtls_x509_crt_parse_file(&crt, file), ref_ret);
@@ -1683,6 +1686,7 @@ void x509_crt_parse_subjectkeyid(char *file, data_t *subjectKeyId, int ref_ret)
exit:
mbedtls_x509_crt_free(&crt);
USE_PSA_DONE();
}
/* END_CASE */
@@ -1698,6 +1702,9 @@ void x509_crt_parse_authoritykeyid(char *file,
char name_buf[128];
mbedtls_x509_crt_init(&crt);
/* X509 relies on PK under the hood and the latter can use PSA to store keys
* and perform operations so psa_crypto_init() must be called before. */
USE_PSA_INIT();
TEST_EQUAL(mbedtls_x509_crt_parse_file(&crt, file), ref_ret);
@@ -1749,6 +1756,7 @@ void x509_crt_parse_authoritykeyid(char *file,
exit:
mbedtls_x509_crt_free(&crt);
USE_PSA_DONE();
}
/* END_CASE */