From 47350fa95caed78e1599cbcc7cf48f2b34310384 Mon Sep 17 00:00:00 2001 From: Lealem Amedie Date: Tue, 27 Jun 2023 12:33:57 -0600 Subject: [PATCH] Remove manual encoding of OID in txt2oidBuf --- src/ssl.c | 31 ++++--------------------------- wolfssl/wolfcrypt/asn.h | 2 +- 2 files changed, 5 insertions(+), 28 deletions(-) diff --git a/src/ssl.c b/src/ssl.c index e5660994c0..d4ebe9cc25 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -29370,13 +29370,11 @@ void* wolfSSL_GetHKDFExtractCtx(WOLFSSL* ssl) #endif /* OPENSSL_EXTRA || OPENSSL_EXTRA_X509_SMALL */ #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) { - char *token; - byte* oidBuf = NULL; word32 oid; - word16 dotted[ASN1_OID_DOTTED_MAX_SZ]; - word32 dottedCount = 0; int nid; if (buf == NULL) @@ -29385,32 +29383,11 @@ const byte* wolfSSL_OBJ_txt2oidBuf(char* buf, word32* inOutSz, word32 oidType) nid = wolfSSL_OBJ_txt2nid(buf); if (nid != NID_undef) { - /* Handle named OID case */ 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) { - 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; + return NULL; } #endif /* OPENSSL_ALL */ diff --git a/wolfssl/wolfcrypt/asn.h b/wolfssl/wolfcrypt/asn.h index a476cfc7fb..c6e56372fe 100644 --- a/wolfssl/wolfcrypt/asn.h +++ b/wolfssl/wolfcrypt/asn.h @@ -2169,7 +2169,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)