Skip to content

Commit dad17eb

Browse files
committed
Align RSA_generate_key_fips and EVP_PKEY_keygen indicator checks to be consistent generation constraints
1 parent 6b5fc31 commit dad17eb

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

crypto/fipsmodule/rsa/rsa_impl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,7 @@ int RSA_generate_key_fips(RSA *rsa, int bits, BN_GENCB *cb) {
12571257
// integer and greater than or equal to 2048 bits. Furthermore, this standard
12581258
// specifies that p and q be of the same bit length – namely, half the bit
12591259
// length of n
1260-
if (bits < 2048 || bits % 2 != 0) {
1260+
if (bits < 2048 || bits % 128 != 0) {
12611261
OPENSSL_PUT_ERROR(RSA, RSA_R_BAD_RSA_PARAMETERS);
12621262
return 0;
12631263
}

crypto/fipsmodule/service_indicator/service_indicator.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,10 @@ void ECDH_verify_service_indicator(const EC_KEY *ec_key) {
298298
void EVP_PKEY_keygen_verify_service_indicator(const EVP_PKEY *pkey) {
299299
if (pkey->type == EVP_PKEY_RSA || pkey->type == EVP_PKEY_RSA_PSS) {
300300
// The approved RSA key sizes for signing are key sizes >= 2048 bits and
301-
// bits % 2 == 0.
301+
// bits % 2 == 0, though we check bits % 128 == 0 for consistency with
302+
// our RSA key generation.
302303
size_t n_bits = RSA_bits(pkey->pkey.rsa);
303-
if (n_bits >= 2048 && n_bits % 2 == 0) {
304+
if (n_bits >= 2048 && n_bits % 128 == 0) {
304305
FIPS_service_indicator_update_state();
305306
}
306307
} else if (pkey->type == EVP_PKEY_EC) {

0 commit comments

Comments
 (0)