Skip to content

Commit 7251d56

Browse files
author
Lealem Amedie
committed
Use new RID function in asn=original
1 parent 47350fa commit 7251d56

1 file changed

Lines changed: 50 additions & 2 deletions

File tree

wolfcrypt/src/asn.c

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12340,7 +12340,7 @@ static int GenerateDNSEntryIPString(DNS_entry* entry, void* heap)
1234012340
}
1234112341
#endif /* OPENSSL_ALL || WOLFSSL_IP_ALT_NAME */
1234212342

12343-
#if defined(OPENSSL_ALL) && defined(WOLFSSL_ASN_TEMPLATE)
12343+
#if defined(OPENSSL_ALL)
1234412344
/* used to set the human readable string for the registeredID with an
1234512345
* ASN_RID_TYPE DNS entry
1234612346
* return 0 on success
@@ -17544,7 +17544,55 @@ static int DecodeAltNames(const byte* input, word32 sz, DecodedCert* cert)
1754417544
length -= strLen;
1754517545
idx += (word32)strLen;
1754617546
}
17547-
#endif /* WOLFSSL_QT || OPENSSL_ALL */
17547+
#endif /* WOLFSSL_QT || OPENSSL_ALL || WOLFSSL_IP_ALT_NAME */
17548+
#if defined(OPENSSL_ALL)
17549+
else if (current_byte == (ASN_CONTEXT_SPECIFIC | ASN_RID_TYPE)) {
17550+
DNS_entry* rid;
17551+
int strLen;
17552+
word32 lenStartIdx = idx;
17553+
WOLFSSL_MSG("Decoding Subject Alt. Name: Registered Id");
17554+
17555+
if (GetLength(input, &idx, &strLen, sz) < 0) {
17556+
WOLFSSL_MSG("\tfail: str length");
17557+
return ASN_PARSE_E;
17558+
}
17559+
length -= (idx - lenStartIdx);
17560+
/* check that strLen at index is not past input buffer */
17561+
if (strLen + idx > sz) {
17562+
return BUFFER_E;
17563+
}
17564+
17565+
rid = AltNameNew(cert->heap);
17566+
if (rid == NULL) {
17567+
WOLFSSL_MSG("\tOut of Memory");
17568+
return MEMORY_E;
17569+
}
17570+
17571+
rid->type = ASN_RID_TYPE;
17572+
rid->name = (char*)XMALLOC((size_t)strLen + 1, cert->heap,
17573+
DYNAMIC_TYPE_ALTNAME);
17574+
if (rid->name == NULL) {
17575+
WOLFSSL_MSG("\tOut of Memory");
17576+
XFREE(rid, cert->heap, DYNAMIC_TYPE_ALTNAME);
17577+
return MEMORY_E;
17578+
}
17579+
rid->len = strLen;
17580+
XMEMCPY(rid->name, &input[idx], strLen);
17581+
rid->name[strLen] = '\0';
17582+
17583+
if (GenerateDNSEntryRIDString(rid, cert->heap) != 0) {
17584+
WOLFSSL_MSG("\tOut of Memory for registerd Id string");
17585+
XFREE(rid->name, cert->heap, DYNAMIC_TYPE_ALTNAME);
17586+
XFREE(rid, cert->heap, DYNAMIC_TYPE_ALTNAME);
17587+
return MEMORY_E;
17588+
}
17589+
17590+
AddAltName(cert, rid);
17591+
17592+
length -= strLen;
17593+
idx += (word32)strLen;
17594+
}
17595+
#endif /* OPENSSL_ALL */
1754817596
#endif /* IGNORE_NAME_CONSTRAINTS */
1754917597
else if (current_byte ==
1755017598
(ASN_CONTEXT_SPECIFIC | ASN_CONSTRUCTED | ASN_OTHER_TYPE)) {

0 commit comments

Comments
 (0)