Skip to content

Commit 9361005

Browse files
committed
Fixes per review comments
1 parent 938b192 commit 9361005

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/wp_rsa_asym.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ static int wp_rsaa_encrypt(wp_RsaAsymCtx* ctx, unsigned char* out,
282282
size_t* outLen, size_t outSize, const unsigned char* in, size_t inLen)
283283
{
284284
int ok = 1;
285+
word32 sz;
285286

286287
if (!wolfssl_prov_is_running()) {
287288
ok = 0;
@@ -319,9 +320,9 @@ static int wp_rsaa_encrypt(wp_RsaAsymCtx* ctx, unsigned char* out,
319320
}
320321
}
321322
else if (ctx->padMode == RSA_NO_PADDING) {
322-
rc = wc_RsaDirect((byte *)in, (word32)inLen, out,
323-
(word32 *)&outSize, wp_rsa_get_key(ctx->rsa),
324-
RSA_PUBLIC_ENCRYPT, &ctx->rng);
323+
sz = outSize;
324+
rc = wc_RsaDirect((byte*)in, (word32)inLen, out, &sz,
325+
wp_rsa_get_key(ctx->rsa), RSA_PUBLIC_ENCRYPT, &ctx->rng);
325326
if (rc < 0) {
326327
ok = 0;
327328
}
@@ -379,6 +380,7 @@ static int wp_rsaa_decrypt(wp_RsaAsymCtx* ctx, unsigned char* out,
379380
size_t* outLen, size_t outSize, const unsigned char* in, size_t inLen)
380381
{
381382
int ok = 1;
383+
word32 sz;
382384

383385
if (!wolfssl_prov_is_running()) {
384386
ok = 0;
@@ -464,9 +466,11 @@ static int wp_rsaa_decrypt(wp_RsaAsymCtx* ctx, unsigned char* out,
464466
}
465467
}
466468
else if (ctx->padMode == RSA_NO_PADDING) {
467-
rc = wc_RsaDirect((byte *)in, (word32)inLen, out,
468-
(word32 *)&outSize, wp_rsa_get_key(ctx->rsa),
469-
RSA_PRIVATE_DECRYPT, &ctx->rng);
469+
sz = outSize;
470+
PRIVATE_KEY_UNLOCK();
471+
rc = wc_RsaDirect((byte*)in, (word32)inLen, out, &sz,
472+
wp_rsa_get_key(ctx->rsa), RSA_PRIVATE_DECRYPT, &ctx->rng);
473+
PRIVATE_KEY_LOCK();
470474
if (rc < 0) {
471475
ok = 0;
472476
}

0 commit comments

Comments
 (0)