improve checking on UUID getter function

This commit is contained in:
JacobBarthelmeh
2022-05-22 14:09:14 -07:00
parent 9e4de4bfc8
commit cdfdefe9af
2 changed files with 28 additions and 12 deletions

View File

@ -21116,8 +21116,18 @@ int wc_GetUUIDFromCert(struct DecodedCert* cert, byte* uuid, word32* uuidSz)
int ret = ALT_NAME_E; int ret = ALT_NAME_E;
DNS_entry* id = NULL; DNS_entry* id = NULL;
do {
id = wc_GetAltName(cert, ASN_URI_TYPE, id); id = wc_GetAltName(cert, ASN_URI_TYPE, id);
if (id != NULL) { if (id != NULL) {
/* check if URI string matches expected format for UUID */
if (id->len != DEFAULT_UUID_SZ) {
continue; /* size not right not a UUID URI */
}
if (XMEMCMP(id->name, "urn:uuid:", 9) != 0) {
continue; /* beginning text not right for a UUID URI */
}
if (uuid == NULL) { if (uuid == NULL) {
*uuidSz = id->len; *uuidSz = id->len;
return LENGTH_ONLY_E; return LENGTH_ONLY_E;
@ -21129,7 +21139,9 @@ int wc_GetUUIDFromCert(struct DecodedCert* cert, byte* uuid, word32* uuidSz)
XMEMCPY(uuid, id->name, id->len); XMEMCPY(uuid, id->name, id->len);
ret = 0; /* success */ ret = 0; /* success */
break;
} }
} while (id != NULL);
return ret; return ret;
} }

View File

@ -1293,6 +1293,10 @@ struct DNS_entry {
#endif #endif
}; };
#ifdef WOLFSSL_FPKI
/* RFC4122 i.e urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6 */
#define DEFAULT_UUID_SZ 45
#endif
typedef struct Base_entry Base_entry; typedef struct Base_entry Base_entry;