wolfcrypt/src/asn.c: revert earlier WOLFSSL_NO_MALLOC changes (not needed, after proper gating in test.c).

pull/8065/head
Daniel Pouzzner 2024-10-11 13:54:41 -05:00
parent 551eb3f44b
commit 0665ff9de7
1 changed files with 2 additions and 28 deletions

View File

@ -28314,12 +28314,7 @@ int wc_EncodeNameCanonical(EncodedName* name, const char* nameStr,
int ParseKeyUsageStr(const char* value, word16* keyUsage, void* heap) int ParseKeyUsageStr(const char* value, word16* keyUsage, void* heap)
{ {
int ret = 0; int ret = 0;
#ifdef WOLFSSL_NO_MALLOC char *token, *str, *ptr;
char str[1024];
#else
char *str;
#endif
char *token, *ptr;
word32 len = 0; word32 len = 0;
word16 usage = 0; word16 usage = 0;
@ -28329,15 +28324,10 @@ int ParseKeyUsageStr(const char* value, word16* keyUsage, void* heap)
/* duplicate string (including terminator) */ /* duplicate string (including terminator) */
len = (word32)XSTRLEN(value); len = (word32)XSTRLEN(value);
#ifdef WOLFSSL_NO_MALLOC
if (len >= sizeof(str))
return MEMORY_E;
#else
str = (char*)XMALLOC(len + 1, heap, DYNAMIC_TYPE_TMP_BUFFER); str = (char*)XMALLOC(len + 1, heap, DYNAMIC_TYPE_TMP_BUFFER);
if (str == NULL) { if (str == NULL) {
return MEMORY_E; return MEMORY_E;
} }
#endif
XMEMCPY(str, value, len + 1); XMEMCPY(str, value, len + 1);
/* parse value, and set corresponding Key Usage value */ /* parse value, and set corresponding Key Usage value */
@ -32312,11 +32302,7 @@ static int SetKeyIdFromPublicKey(Cert *cert, RsaKey *rsakey, ecc_key *eckey,
dilithium_key* dilithiumKey, dilithium_key* dilithiumKey,
sphincs_key *sphincsKey, int kid_type) sphincs_key *sphincsKey, int kid_type)
{ {
#ifdef WOLFSSL_NO_MALLOC
byte buf[MAX_PUBLIC_KEY_SZ];
#else
byte *buf; byte *buf;
#endif
int bufferSz, ret; int bufferSz, ret;
if (cert == NULL || if (cert == NULL ||
@ -32326,12 +32312,10 @@ static int SetKeyIdFromPublicKey(Cert *cert, RsaKey *rsakey, ecc_key *eckey,
(kid_type != SKID_TYPE && kid_type != AKID_TYPE)) (kid_type != SKID_TYPE && kid_type != AKID_TYPE))
return BAD_FUNC_ARG; return BAD_FUNC_ARG;
#ifndef WOLFSSL_NO_MALLOC
buf = (byte *)XMALLOC(MAX_PUBLIC_KEY_SZ, cert->heap, buf = (byte *)XMALLOC(MAX_PUBLIC_KEY_SZ, cert->heap,
DYNAMIC_TYPE_TMP_BUFFER); DYNAMIC_TYPE_TMP_BUFFER);
if (buf == NULL) if (buf == NULL)
return MEMORY_E; return MEMORY_E;
#endif
/* Public Key */ /* Public Key */
bufferSz = -1; bufferSz = -1;
@ -33338,12 +33322,7 @@ int wc_SetDatesBuffer(Cert* cert, const byte* der, int derSz)
int EncodePolicyOID(byte *out, word32 *outSz, const char *in, void* heap) int EncodePolicyOID(byte *out, word32 *outSz, const char *in, void* heap)
{ {
word32 idx = 0, nb_val; word32 idx = 0, nb_val;
#ifdef WOLFSSL_NO_MALLOC char *token, *str, *ptr;
char str[1024];
#else
char *str;
#endif
char *token, *ptr;
word32 len; word32 len;
(void)heap; (void)heap;
@ -33353,14 +33332,9 @@ int EncodePolicyOID(byte *out, word32 *outSz, const char *in, void* heap)
/* duplicate string (including terminator) */ /* duplicate string (including terminator) */
len = (word32)XSTRLEN(in); len = (word32)XSTRLEN(in);
#ifdef WOLFSSL_NO_MALLOC
if (len >= sizeof(str))
return MEMORY_E;
#else
str = (char *)XMALLOC(len+1, heap, DYNAMIC_TYPE_TMP_BUFFER); str = (char *)XMALLOC(len+1, heap, DYNAMIC_TYPE_TMP_BUFFER);
if (str == NULL) if (str == NULL)
return MEMORY_E; return MEMORY_E;
#endif
XMEMCPY(str, in, len+1); XMEMCPY(str, in, len+1);
nb_val = 0; nb_val = 0;