Renaming x509_get_subject_alt_name to x509_get_general_names and mbedtls_x509_parse_subject_alt_name to mbedtls_x509_parse_general_name so they can be used not only to collect subject alt name, but the V3 authority cert issuer that is also GeneralName type.
Also updated the x509_get_general_names function to be able to parse rfc822Names
Test are also updated according these changes.
Signed-off-by: toth92g <toth92g@gmail.com>
diff --git a/tests/suites/test_suite_x509parse.function b/tests/suites/test_suite_x509parse.function
index 2dab7ef..f258970 100644
--- a/tests/suites/test_suite_x509parse.function
+++ b/tests/suites/test_suite_x509parse.function
@@ -458,7 +458,7 @@
if (crt.ext_types & MBEDTLS_X509_EXT_SUBJECT_ALT_NAME) {
cur = &crt.subject_alt_names;
while (cur != NULL) {
- ret = mbedtls_x509_parse_subject_alt_name(&cur->buf, &san);
+ ret = mbedtls_x509_parse_general_name(&cur->buf, &san);
TEST_ASSERT(ret == 0 || ret == MBEDTLS_ERR_X509_FEATURE_UNAVAILABLE);
/*
* If san type not supported, ignore.
@@ -1517,11 +1517,12 @@
TEST_ASSERT(crt.authority_key_id.keyIdentifier.len == keyIdLength);
/* Issuer test */
- mbedtls_x509_name *issuerPtr = &crt.authority_key_id.authorityCertIssuer;
+ mbedtls_x509_sequence *issuerPtr = &crt.authority_key_id.authorityCertIssuer;
while (issuerPtr != NULL) {
- for (issuerCounter = 0u; issuerCounter < issuerPtr->val.len; issuerCounter++) {
+ /* First 9 bytes are always ASN1 coding related information that does not matter right now. Only the values are asserted */
+ for (issuerCounter = 9u; issuerCounter < issuerPtr->buf.len; issuerCounter++) {
result |=
- (authorityKeyId_issuer[bufferCounter++] != issuerPtr->val.p[issuerCounter]);
+ (authorityKeyId_issuer[bufferCounter++] != issuerPtr->buf.p[issuerCounter]);
}
bufferCounter++; /* Skipping the slash */
issuerPtr = issuerPtr->next;