aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2026-02-12 13:57:23 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2026-02-15 15:16:26 +0100
commit2ab2c258479ef140ea59481fb493b113219201b9 (patch)
tree8faace3b20925b7382488dc37ad218a0977695cc
parent5a1bcdf036840ee3c70beb458c421e7f5a294b8d (diff)
downloadbusybox-w32-2ab2c258479ef140ea59481fb493b113219201b9.tar.gz
busybox-w32-2ab2c258479ef140ea59481fb493b113219201b9.tar.bz2
busybox-w32-2ab2c258479ef140ea59481fb493b113219201b9.zip
tls: remove unnecessary malloc/free in psRsaDecryptPriv()
function old new delta .rodata 108007 108023 +16 psRsaDecryptPriv 200 171 -29 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 16/-29) Total: -13 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/tls_rsa.c32
1 files changed, 10 insertions, 22 deletions
diff --git a/networking/tls_rsa.c b/networking/tls_rsa.c
index 8a9c0c6db..cb1ff11b2 100644
--- a/networking/tls_rsa.c
+++ b/networking/tls_rsa.c
@@ -280,35 +280,23 @@ int32 FAST_FUNC psRsaDecryptPriv(psPool_t *pool, psRsaKey_t *key,
280 unsigned char *out, uint32 outlen, void *data) 280 unsigned char *out, uint32 outlen, void *data)
281{ 281{
282 int32 err; 282 int32 err;
283 uint32 size, ptLen; 283 uint32 ptLen;
284 unsigned char *tmp;
285 284
286 size = key->size; 285 if (inlen != key->size) {
287 if (inlen != size) { 286 psTraceCrypto("Error on bad inlen parameter to psRsaDecryptPriv\n");
288 psTraceCrypto("psRsaDecryptPriv: input size mismatch\n");
289 return PS_ARG_FAIL; 287 return PS_ARG_FAIL;
290 } 288 }
291 289 ptLen = inlen;
292 /* Allocate temp buffer for decrypted padded data */ 290 if ((err = psRsaCrypt(pool, in, inlen, in, &ptLen, key,
293 tmp = xmalloc(size);
294
295 /* Perform RSA decryption */
296 ptLen = size;
297 if ((err = psRsaCrypt(pool, in, inlen, tmp, &ptLen, key,
298 PRIVKEY_TYPE, data)) < PS_SUCCESS) { 291 PRIVKEY_TYPE, data)) < PS_SUCCESS) {
299 psTraceCrypto("Error performing psRsaDecryptPriv\n"); 292 psTraceCrypto("Error performing psRsaDecryptPriv\n");
300 free(tmp);
301 return err; 293 return err;
302 } 294 }
303 295 if (ptLen != inlen) {
304 /* Remove PKCS#1 padding */ 296 psTraceCrypto("Decrypted size error in psRsaDecryptPriv\n");
305 err = pkcs1Unpad(tmp, ptLen, out, outlen);
306 free(tmp);
307
308 if (err < 0) {
309 psTraceCrypto("Error unpadding in psRsaDecryptPriv\n");
310 return PS_FAILURE; 297 return PS_FAILURE;
311 } 298 }
312 299 err = pkcs1Unpad(in, inlen, out, outlen);
313 return err; /* Return length of unpadded message */ 300 memset(in, 0x0, inlen);
301 return err;
314} 302}