mirror of https://github.com/wolfSSL/wolfssl.git
Handle registeredID correctly
parent
90f5665318
commit
fdc95f9ba6
|
@ -7815,6 +7815,9 @@ then
|
|||
|
||||
# Uses alt name
|
||||
ENABLED_ALTNAMES="yes"
|
||||
|
||||
AM_CFLAGS="$AM_CFLAGS -DHAVE_OID_ENCODING -DWOLFSSL_NO_ASN_STRICT"
|
||||
|
||||
fi
|
||||
|
||||
if test "$ENABLED_STRONGSWAN" = "yes"; then
|
||||
|
|
|
@ -5797,7 +5797,7 @@ static int X509PrintSubjAltName(WOLFSSL_BIO* bio, WOLFSSL_X509* x509,
|
|||
}
|
||||
else if (entry->type == ASN_RID_TYPE) {
|
||||
len = XSNPRINTF(scratch, MAX_WIDTH, "Registered ID:%s",
|
||||
entry->name);
|
||||
entry->ridString);
|
||||
if (len >= MAX_WIDTH) {
|
||||
ret = WOLFSSL_FAILURE;
|
||||
break;
|
||||
|
|
|
@ -11159,6 +11159,9 @@ void FreeAltNames(DNS_entry* altNames, void* heap)
|
|||
XFREE(altNames->name, heap, DYNAMIC_TYPE_ALTNAME);
|
||||
#if defined(OPENSSL_ALL) || defined(WOLFSSL_IP_ALT_NAME)
|
||||
XFREE(altNames->ipString, heap, DYNAMIC_TYPE_ALTNAME);
|
||||
#endif
|
||||
#if defined(OPENSSL_ALL)
|
||||
XFREE(altNames->ridString, heap, DYNAMIC_TYPE_ALTNAME);
|
||||
#endif
|
||||
XFREE(altNames, heap, DYNAMIC_TYPE_ALTNAME);
|
||||
altNames = tmp;
|
||||
|
@ -12337,6 +12340,66 @@ static int GenerateDNSEntryIPString(DNS_entry* entry, void* heap)
|
|||
}
|
||||
#endif /* OPENSSL_ALL || WOLFSSL_IP_ALT_NAME */
|
||||
|
||||
#if defined(OPENSSL_ALL)
|
||||
/* used to set the human readable string for the registeredID with an
|
||||
* ASN_RID_TYPE DNS entry
|
||||
* return 0 on success
|
||||
*/
|
||||
static int GenerateDNSEntryRIDString(DNS_entry* entry, void* heap)
|
||||
{
|
||||
int i, j, ret = 0;
|
||||
int nameSz;
|
||||
int tmpSize = MAX_OID_SZ;
|
||||
word16 tmpName[MAX_OID_SZ];
|
||||
char* rid;
|
||||
char dottedName[MAX_OID_SZ] = {0};
|
||||
|
||||
if (entry == NULL || entry->type != ASN_RID_TYPE) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
if (entry->len <= 0) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
rid = entry->name;
|
||||
|
||||
/* Decode OBJECT_ID into dotted form array. */
|
||||
ret = DecodeObjectId((const byte*)(rid),(word32)entry->len, tmpName,
|
||||
(word32*)&tmpSize);
|
||||
if (ret == 0) {
|
||||
j = 0;
|
||||
/* Append each number of dotted form. */
|
||||
for (i = 0; i < tmpSize; i++) {
|
||||
ret = XSNPRINTF(dottedName + j, MAX_OID_SZ, "%d", tmpName[i]);
|
||||
if (ret >= 0) {
|
||||
j += ret;
|
||||
if (i < tmpSize - 1) {
|
||||
dottedName[j] = '.';
|
||||
j++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return BUFFER_E;
|
||||
}
|
||||
}
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
nameSz = (int)XSTRLEN((const char*)dottedName);
|
||||
entry->ridString = (char*)XMALLOC(nameSz + 1, heap, DYNAMIC_TYPE_ALTNAME);
|
||||
if (entry->ridString == NULL) {
|
||||
ret = MEMORY_E;
|
||||
}
|
||||
|
||||
XMEMCPY(entry->ridString, dottedName, nameSz);
|
||||
entry->ridString[nameSz] = '\0';
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* OPENSSL_ALL */
|
||||
|
||||
#ifdef WOLFSSL_ASN_TEMPLATE
|
||||
|
||||
#if defined(WOLFSSL_CERT_GEN) || !defined(NO_CERTS)
|
||||
|
@ -12423,6 +12486,13 @@ static int SetDNSEntry(DecodedCert* cert, const char* str, int strLen,
|
|||
XFREE(dnsEntry, cert->heap, DYNAMIC_TYPE_ALTNAME);
|
||||
}
|
||||
}
|
||||
/* store registeredID as a string */
|
||||
else if (type == ASN_RID_TYPE) {
|
||||
if ((ret = GenerateDNSEntryRIDString(dnsEntry, cert->heap)) != 0) {
|
||||
XFREE(dnsEntry->name, cert->heap, DYNAMIC_TYPE_ALTNAME);
|
||||
XFREE(dnsEntry, cert->heap, DYNAMIC_TYPE_ALTNAME);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ret == 0) {
|
||||
#endif
|
||||
|
|
|
@ -1360,6 +1360,10 @@ struct DNS_entry {
|
|||
#if defined(OPENSSL_ALL) || defined(WOLFSSL_IP_ALT_NAME)
|
||||
char* ipString; /* human readable form of IP address */
|
||||
#endif
|
||||
#if defined(OPENSSL_ALL)
|
||||
char* ridString; /* human readable form of registeredID */
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_FPKI
|
||||
int oidSum; /* provide oid sum for verification */
|
||||
#endif
|
||||
|
@ -2162,7 +2166,7 @@ WOLFSSL_LOCAL int GetInt(mp_int* mpi, const byte* input, word32* inOutIdx,
|
|||
word32 maxIdx);
|
||||
|
||||
#ifdef HAVE_OID_ENCODING
|
||||
WOLFSSL_LOCAL int EncodeObjectId(const word16* in, word32 inSz,
|
||||
WOLFSSL_API int EncodeObjectId(const word16* in, word32 inSz,
|
||||
byte* out, word32* outSz);
|
||||
#endif
|
||||
#if defined(HAVE_OID_DECODING) || defined(WOLFSSL_ASN_PRINT)
|
||||
|
|
Loading…
Reference in New Issue