1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-29 11:41:15 +03:00

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>
This commit is contained in:
toth92g
2021-05-10 15:16:33 +02:00
committed by Przemek Stekiel
parent 5042b104c2
commit 8d435a0c8b
5 changed files with 375 additions and 107 deletions

View File

@ -458,7 +458,7 @@ void x509_parse_san(char *crt_file, char *result_str, int parse_result)
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 @@ void x509_crt_parse_authoritykeyid(data_t *buf,
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;