openssl/openssl

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

已關閉

#22,617 建立於 2023年11月3日

 (2 則留言) (0 個反應) (0 位負責人)C (11,262 個分叉)batch import
backlog fixbranch: 3.0branch: 3.1branch: 3.2branch: masterhelp wantedtriaged: bugtriaged: feature

倉庫指標

星標
 (30,157 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

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.

貢獻者指南