Skip to content

Commit 0ea9c52

Browse files
committed
Fatal error if RSA-PSS is used for encryption operations
1 parent 985a5c4 commit 0ea9c52

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

RSA.pm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,12 @@ Encrypting user data directly with RSA is insecure.
246246
PKCS #1 v1.5 padding has been disabled as it is nearly impossible to use this
247247
padding method in a secure manner. It is known to be vulnerable to timing
248248
based side channel attacks.
249+
L<Marvin Attack|https://github.com/tomato42/marvin-toolkit/blob/master/README.md>
249250
250251
use_pkcs1_padding() now sets the padding method to use_pkcs1_pss_padding.
251252
252-
L<Marvin Attack|https://github.com/tomato42/marvin-toolkit/blob/master/README.md>
253+
B<Note>: RSA-PSS cannot be used for encryption/decryption and results in a
254+
fatal error. Call C<use_pkcs1_oaep_padding> for encryption operations.
253255
254256
=item use_pkcs1_oaep_padding
255257

RSA.xs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,10 @@ SV* rsa_crypt(rsaData* p_rsa, SV* p_from,
323323
size = EVP_PKEY_get_size(p_rsa->rsa);
324324
CHECK_NEW(to, size, UNSIGNED_CHAR);
325325
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
326+
327+
if(p_rsa->padding == RSA_PKCS1_PSS_PADDING)
328+
croak("PKCS#1 v2.1 RSA-PSS cannot be used for encryption operations call \"use_pkcs1_oaep_padding\" instead.");
329+
326330
EVP_PKEY_CTX *ctx;
327331

328332
OSSL_LIB_CTX *ossllibctx = OSSL_LIB_CTX_new();

0 commit comments

Comments
 (0)