Skip to content

Commit c7709f7

Browse files
JakujeNIIBE Yutaka
authored andcommitted
Do not allow PKCS #1.5 padding for encryption in FIPS
* cipher/pubkey-util.c (_gcry_pk_util_data_to_mpi): Block PKCS #1.5 padding for encryption in FIPS mode * cipher/rsa.c (rsa_decrypt): Block PKCS #1.5 decryption in FIPS mode -- GnuPG-bug-id: 5918 Signed-off-by: Jakub Jelen <jjelen@redhat.com>
1 parent f436bf4 commit c7709f7

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

cipher/pubkey-util.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,10 @@ _gcry_pk_util_data_to_mpi (gcry_sexp_t input, gcry_mpi_t *ret_mpi,
957957
void *random_override = NULL;
958958
size_t random_override_len = 0;
959959

960-
if ( !(value=sexp_nth_data (lvalue, 1, &valuelen)) || !valuelen )
960+
/* The RSA PKCS#1.5 encryption is no longer supported by FIPS */
961+
if (fips_mode ())
962+
rc = GPG_ERR_INV_FLAG;
963+
else if ( !(value=sexp_nth_data (lvalue, 1, &valuelen)) || !valuelen )
961964
rc = GPG_ERR_INV_OBJ;
962965
else
963966
{

cipher/rsa.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,6 +1391,11 @@ rsa_decrypt (gcry_sexp_t *r_plain, gcry_sexp_t s_data, gcry_sexp_t keyparms)
13911391
rc = GPG_ERR_INV_DATA;
13921392
goto leave;
13931393
}
1394+
if (fips_mode () && (ctx.encoding == PUBKEY_ENC_PKCS1))
1395+
{
1396+
rc = GPG_ERR_INV_FLAG;
1397+
goto leave;
1398+
}
13941399

13951400
/* Extract the key. */
13961401
rc = sexp_extract_param (keyparms, NULL, "nedp?q?u?",

0 commit comments

Comments
 (0)