Skip to content

Commit a4c86d6

Browse files
committed
Initial implementation of RSA encrypt/decrypt without padding
1 parent 966c7b9 commit a4c86d6

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/wp_rsa_asym.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,14 @@ static int wp_rsaa_encrypt(wp_RsaAsymCtx* ctx, unsigned char* out,
318318
ok = 0;
319319
}
320320
}
321+
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);
325+
if (rc < 0) {
326+
ok = 0;
327+
}
328+
}
321329
else {
322330
ok = 0;
323331
}
@@ -455,6 +463,14 @@ static int wp_rsaa_decrypt(wp_RsaAsymCtx* ctx, unsigned char* out,
455463
}
456464
}
457465
}
466+
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);
470+
if (rc < 0) {
471+
ok = 0;
472+
}
473+
}
458474
else {
459475
ok = 0;
460476
}

0 commit comments

Comments
 (0)