Merge pull request #6141 from SparkiDev/cert_name_enc_fix

Cert name encoding fix
This commit is contained in:
David Garske
2023-02-28 17:36:22 -08:00
committed by GitHub
2 changed files with 9 additions and 3 deletions

View File

@@ -26078,6 +26078,9 @@ static int SetNameRdnItems(ASNSetData* dataASN, ASNItem* namesASN,
j = -1; j = -1;
/* Put DomainComponents before OrgUnitName. */ /* Put DomainComponents before OrgUnitName. */
while (FindMultiAttrib(name, type, &j)) { while (FindMultiAttrib(name, type, &j)) {
if (GetCertNameId(i) != ASN_DOMAIN_COMPONENT) {
continue;
}
if (dataASN != NULL && namesASN != NULL) { if (dataASN != NULL && namesASN != NULL) {
if (idx > maxIdx - (int)rdnASN_Length) { if (idx > maxIdx - (int)rdnASN_Length) {
WOLFSSL_MSG("Wanted to write more ASN than allocated"); WOLFSSL_MSG("Wanted to write more ASN than allocated");
@@ -26136,6 +26139,9 @@ static int SetNameRdnItems(ASNSetData* dataASN, ASNItem* namesASN,
j = -1; j = -1;
/* Write all other attributes of this type. */ /* Write all other attributes of this type. */
while (FindMultiAttrib(name, type, &j)) { while (FindMultiAttrib(name, type, &j)) {
if (GetCertNameId(i) == ASN_DOMAIN_COMPONENT) {
continue;
}
if (dataASN != NULL && namesASN != NULL) { if (dataASN != NULL && namesASN != NULL) {
if (idx > maxIdx - (int)rdnASN_Length) { if (idx > maxIdx - (int)rdnASN_Length) {
WOLFSSL_MSG("Wanted to write more ASN than allocated"); WOLFSSL_MSG("Wanted to write more ASN than allocated");

View File

@@ -13837,20 +13837,20 @@ static void initDefaultName(void)
n = &certDefaultName.name[0]; n = &certDefaultName.name[0];
n->id = ASN_ORGUNIT_NAME; n->id = ASN_ORGUNIT_NAME;
n->type = CTC_UTF8; n->type = CTC_UTF8;
n->sz = sizeof("Development-2"); n->sz = XSTRLEN("Development-2");
XMEMCPY(n->value, "Development-2", sizeof("Development-2")); XMEMCPY(n->value, "Development-2", sizeof("Development-2"));
#if CTC_MAX_ATTRIB > 3 #if CTC_MAX_ATTRIB > 3
n = &certDefaultName.name[1]; n = &certDefaultName.name[1];
n->id = ASN_DOMAIN_COMPONENT; n->id = ASN_DOMAIN_COMPONENT;
n->type = CTC_UTF8; n->type = CTC_UTF8;
n->sz = sizeof("com"); n->sz = XSTRLEN("com");
XMEMCPY(n->value, "com", sizeof("com")); XMEMCPY(n->value, "com", sizeof("com"));
n = &certDefaultName.name[2]; n = &certDefaultName.name[2];
n->id = ASN_DOMAIN_COMPONENT; n->id = ASN_DOMAIN_COMPONENT;
n->type = CTC_UTF8; n->type = CTC_UTF8;
n->sz = sizeof("wolfssl"); n->sz = XSTRLEN("wolfssl");
XMEMCPY(n->value, "wolfssl", sizeof("wolfssl")); XMEMCPY(n->value, "wolfssl", sizeof("wolfssl"));
#endif #endif
#endif /* WOLFSSL_MULTI_ATTRIB && WOLFSSL_TEST_CERT */ #endif /* WOLFSSL_MULTI_ATTRIB && WOLFSSL_TEST_CERT */