Skip to content

Commit

Permalink
Remove manual encoding of OID in txt2oidBuf
Browse files Browse the repository at this point in the history
  • Loading branch information
Lealem Amedie committed Jun 28, 2023
1 parent ee63d73 commit 47350fa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 28 deletions.
31 changes: 4 additions & 27 deletions src/ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 */

Expand Down
2 changes: 1 addition & 1 deletion wolfssl/wolfcrypt/asn.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 47350fa

Please sign in to comment.