Remove manual encoding of OID in txt2oidBuf

This commit is contained in:
Lealem Amedie
2023-06-27 12:33:57 -06:00
parent ee63d73299
commit 47350fa95c
2 changed files with 5 additions and 28 deletions

View File

@ -29370,13 +29370,11 @@ void* wolfSSL_GetHKDFExtractCtx(WOLFSSL* ssl)
#endif /* OPENSSL_EXTRA || OPENSSL_EXTRA_X509_SMALL */ #endif /* OPENSSL_EXTRA || OPENSSL_EXTRA_X509_SMALL */
#if defined(OPENSSL_ALL) #if defined(OPENSSL_ALL)
/* Returns the oid buffer from the short name or long name of an ASN1_object
* and NULL on failure */
const byte* wolfSSL_OBJ_txt2oidBuf(char* buf, word32* inOutSz, word32 oidType) const byte* wolfSSL_OBJ_txt2oidBuf(char* buf, word32* inOutSz, word32 oidType)
{ {
char *token;
byte* oidBuf = NULL;
word32 oid; word32 oid;
word16 dotted[ASN1_OID_DOTTED_MAX_SZ];
word32 dottedCount = 0;
int nid; int nid;
if (buf == NULL) if (buf == NULL)
@ -29385,32 +29383,11 @@ const byte* wolfSSL_OBJ_txt2oidBuf(char* buf, word32* inOutSz, word32 oidType)
nid = wolfSSL_OBJ_txt2nid(buf); nid = wolfSSL_OBJ_txt2nid(buf);
if (nid != NID_undef) { if (nid != NID_undef) {
/* Handle named OID case */
oid = nid2oid(nid, oidType); oid = nid2oid(nid, oidType);
oidBuf = (byte*)OidFromId(oid, oidType,inOutSz); return OidFromId(oid, oidType,inOutSz);
} }
#if defined(HAVE_OID_ENCODING)
else {
/* Handle dotted form OID case*/
token = XSTRTOK(buf, ".", NULL);
while (token != NULL) { return NULL;
dotted[dottedCount] = XATOI(token);
dottedCount++;
token = XSTRTOK(NULL, ".", NULL);
}
if (EncodeObjectId(dotted, dottedCount, oidBuf, inOutSz) != 0) {
oidBuf = NULL;
}
}
#else
(void)token;
(void)dotted;
(void)dottedCount;
#endif
return (const byte*)oidBuf;
} }
#endif /* OPENSSL_ALL */ #endif /* OPENSSL_ALL */

View File

@ -2169,7 +2169,7 @@ WOLFSSL_LOCAL int GetInt(mp_int* mpi, const byte* input, word32* inOutIdx,
word32 maxIdx); word32 maxIdx);
#ifdef HAVE_OID_ENCODING #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); byte* out, word32* outSz);
#endif #endif
#if defined(HAVE_OID_DECODING) || defined(WOLFSSL_ASN_PRINT) #if defined(HAVE_OID_DECODING) || defined(WOLFSSL_ASN_PRINT)