From 0bd8775eae7f32b9f61767b5c75aeca9047e6298 Mon Sep 17 00:00:00 2001 From: John Bland Date: Mon, 25 Mar 2024 10:53:58 -0400 Subject: [PATCH] update based on PR comments --- wolfcrypt/src/asn.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index c52b44ae7..41d8f7d13 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -25938,7 +25938,7 @@ int wc_RsaKeyToDer(RsaKey* key, byte* output, word32 inLen) #ifndef WOLFSSL_ASN_TEMPLATE int ret = 0, i; int mpSz; - word32 rawLen; + word32 rawLen; word32 seqSz = 0, verSz = 0, intTotalLen = 0, outLen = 0; word32 sizes[RSA_INTS]; byte seq[MAX_SEQ_SZ]; @@ -25966,7 +25966,7 @@ int wc_RsaKeyToDer(RsaKey* key, byte* output, word32 inLen) /* free outstanding tmps */ for (i = 0; i < RSA_INTS; i++) { if (tmps[i] != NULL) - XFREE(tmps[i]); + XFREE(tmps[i], key->heap, DYNAMIC_TYPE_RSA); } #endif return ret; @@ -26020,19 +26020,19 @@ int wc_RsaKeyToDer(RsaKey* key, byte* output, word32 inLen) XMEMCPY(output + j, tmps[i], sizes[i]); j += sizes[i]; #else - keyInt = GetRsaInt(key, i); - ret = mp_unsigned_bin_size(keyInt); - if (ret < 0) { - return ret; - } - rawLen = (word32)ret + 1; - ret = 0; - mpSz = SetASNIntMP(keyInt, MAX_RSA_INT_SZ, output + j); - if (mpSz < 0) { - ret = mpSz; - break; - } - j += mpSz; + keyInt = GetRsaInt(key, i); + ret = mp_unsigned_bin_size(keyInt); + if (ret < 0) { + return ret; + } + rawLen = (word32)ret + 1; + ret = 0; + mpSz = SetASNIntMP(keyInt, MAX_RSA_INT_SZ, output + j); + if (mpSz < 0) { + ret = mpSz; + break; + } + j += mpSz; #endif } }