mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-01 10:06:53 +03:00
tests: suite_x509parse: rename variable in x509parse_crt()
- rename result_ext to result_back_comp - add a comment to describe its purpose Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
This commit is contained in:
@ -1123,15 +1123,18 @@ void x509parse_crt(data_t *buf, char *result_str, int result)
|
||||
#else
|
||||
((void) result_str);
|
||||
#endif
|
||||
/* Pick an error which is not used in the test_suite_x509parse.data file. */
|
||||
int result_ext = MBEDTLS_ERR_ERROR_GENERIC_ERROR;
|
||||
/* Tests whose result is MBEDTLS_ERR_PK_INVALID_PUBKEY might return
|
||||
* MBEDTLS_ERR_ASN1_UNEXPECTED_TAG until psa#308 is merged. This variable
|
||||
* is therefore used for backward compatiblity and will be removed in
|
||||
* mbedtls#10229. */
|
||||
int result_back_comp = result;
|
||||
int res;
|
||||
|
||||
#if !defined(MBEDTLS_PK_USE_PSA_RSA_DATA)
|
||||
/* Support for mbedtls#10213 before psa#308. Once psa#308 will be
|
||||
* merged this dirty fix can be removed. */
|
||||
if (result == MBEDTLS_ERR_PK_INVALID_PUBKEY) {
|
||||
result_ext = MBEDTLS_ERR_ASN1_UNEXPECTED_TAG;
|
||||
result_back_comp = MBEDTLS_ERR_ASN1_UNEXPECTED_TAG;
|
||||
}
|
||||
#endif /* MBEDTLS_PK_USE_PSA_RSA_DATA */
|
||||
|
||||
@ -1139,8 +1142,7 @@ void x509parse_crt(data_t *buf, char *result_str, int result)
|
||||
USE_PSA_INIT();
|
||||
|
||||
res = mbedtls_x509_crt_parse_der(&crt, buf->x, buf->len);
|
||||
fprintf(stderr, "\n res=%d, result=%d, result_ext=%d \n", res, result, result_ext);
|
||||
TEST_ASSERT((res == result) || (res == result_ext));
|
||||
TEST_ASSERT((res == result) || (res == result_back_comp));
|
||||
#if !defined(MBEDTLS_X509_REMOVE_INFO)
|
||||
if ((result) == 0) {
|
||||
res = mbedtls_x509_crt_info((char *) output, 2000, "", &crt);
|
||||
@ -1156,7 +1158,7 @@ void x509parse_crt(data_t *buf, char *result_str, int result)
|
||||
mbedtls_x509_crt_init(&crt);
|
||||
|
||||
res = mbedtls_x509_crt_parse_der_nocopy(&crt, buf->x, buf->len);
|
||||
TEST_ASSERT((res == result) || (res == result_ext));
|
||||
TEST_ASSERT((res == result) || (res == result_back_comp));
|
||||
#if !defined(MBEDTLS_X509_REMOVE_INFO)
|
||||
if ((result) == 0) {
|
||||
memset(output, 0, 2000);
|
||||
@ -1175,7 +1177,7 @@ void x509parse_crt(data_t *buf, char *result_str, int result)
|
||||
mbedtls_x509_crt_init(&crt);
|
||||
|
||||
res = mbedtls_x509_crt_parse_der_with_ext_cb(&crt, buf->x, buf->len, 0, NULL, NULL);
|
||||
TEST_ASSERT((res == result) || (res == result_ext));
|
||||
TEST_ASSERT((res == result) || (res == result_back_comp));
|
||||
#if !defined(MBEDTLS_X509_REMOVE_INFO)
|
||||
if ((result) == 0) {
|
||||
res = mbedtls_x509_crt_info((char *) output, 2000, "", &crt);
|
||||
@ -1192,7 +1194,7 @@ void x509parse_crt(data_t *buf, char *result_str, int result)
|
||||
mbedtls_x509_crt_init(&crt);
|
||||
|
||||
res = mbedtls_x509_crt_parse_der_with_ext_cb(&crt, buf->x, buf->len, 1, NULL, NULL);
|
||||
TEST_ASSERT((res == result) || (res == result_ext));
|
||||
TEST_ASSERT((res == result) || (res == result_back_comp));
|
||||
#if !defined(MBEDTLS_X509_REMOVE_INFO)
|
||||
if ((result) == 0) {
|
||||
res = mbedtls_x509_crt_info((char *) output, 2000, "", &crt);
|
||||
|
Reference in New Issue
Block a user