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,20 +21116,32 @@ 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;
id = wc_GetAltName(cert, ASN_URI_TYPE, id); do {
if (id != NULL) { id = wc_GetAltName(cert, ASN_URI_TYPE, id);
if (uuid == NULL) { if (id != NULL) {
*uuidSz = id->len; /* check if URI string matches expected format for UUID */
return LENGTH_ONLY_E; if (id->len != DEFAULT_UUID_SZ) {
} continue; /* size not right not a UUID URI */
}
if ((int)*uuidSz < id->len) { if (XMEMCMP(id->name, "urn:uuid:", 9) != 0) {
return BUFFER_E; continue; /* beginning text not right for a UUID URI */
} }
XMEMCPY(uuid, id->name, id->len); if (uuid == NULL) {
ret = 0; /* success */ *uuidSz = id->len;
} return LENGTH_ONLY_E;
}
if ((int)*uuidSz < id->len) {
return BUFFER_E;
}
XMEMCPY(uuid, id->name, id->len);
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;