openssl/openssl

Attempt to generate RSA key below FIPS-140/186 limit yields "invalid modulus" rather than "key too short"

Chiusa

#22.617 aperta il 3 nov 2023

 (2 commenti) (0 reazioni) (0 assegnatari)C (11.262 fork)batch import
backlog fixbranch: 3.0branch: 3.1branch: 3.2branch: masterhelp wantedtriaged: bugtriaged: feature

Metriche repository

Star
 (30.157 stelle)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

OpenSSL 3.0.10 in FIPS_140 mode, delivered with Solaris

OpenSSL 3 says:

$ /usr/openssl/3/bin/openssl genrsa 512
genrsa: Error generating RSA key
01000000:error:020000AE:rsa routines:ossl_rsa_sp800_56b_validate_strength:invalid modulus:../../openssl-3.0.10/crypto/rsa/rsa_sp800_56b_gen.c:179:

But 1.0.2zi-fips says:

$ openssl genrsa 512
Generating RSA private key, 512 bit long modulus
1:error:2D08F07C:FIPS routines:RSA_X931_generate_key_ex:key too short:rsa_x931g.c:216:

"key too short" seems much more human friendly than "invalid modulus".

It looks like the intent is that ossl_rsa_fips186_4_gen_prob_primes() yield "key size too small" (RSA_R_KEY_SIZE_TOO_SMALL), but the check in ossl_rsa_sp800_56b_validate_strength() catches it first.

Guida contributor