Skip to content

Commit 03e05cb

Browse files
danbevaddaleax
authored andcommitted
src: fix FIPS section in Sign::SignFinal
Currently, while FIPS is not supported yet for this release there might be an option to dynamically link against a FIPS compatible OpenSSL version. This commit fixes the compiler errors. PR-URL: #25412 Reviewed-By: Sam Roberts <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent 47d040d commit 03e05cb

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/node_crypto.cc

+9-4
Original file line numberDiff line numberDiff line change
@@ -4478,9 +4478,14 @@ Sign::SignResult Sign::SignFinal(
44784478

44794479
#ifdef NODE_FIPS_MODE
44804480
/* Validate DSA2 parameters from FIPS 186-4 */
4481-
if (FIPS_mode() && EVP_PKEY_DSA == pkey->type) {
4482-
size_t L = BN_num_bits(pkey->pkey.dsa->p);
4483-
size_t N = BN_num_bits(pkey->pkey.dsa->q);
4481+
if (FIPS_mode() && EVP_PKEY_DSA == EVP_PKEY_base_id(pkey.get())) {
4482+
DSA* dsa = EVP_PKEY_get0_DSA(pkey.get());
4483+
const BIGNUM* p;
4484+
DSA_get0_pqg(dsa, &p, nullptr, nullptr);
4485+
size_t L = BN_num_bits(p);
4486+
const BIGNUM* q;
4487+
DSA_get0_pqg(dsa, nullptr, &q, nullptr);
4488+
size_t N = BN_num_bits(q);
44844489
bool result = false;
44854490

44864491
if (L == 1024 && N == 160)
@@ -4493,7 +4498,7 @@ Sign::SignResult Sign::SignFinal(
44934498
result = true;
44944499

44954500
if (!result) {
4496-
return kSignPrivateKey;
4501+
return SignResult(kSignPrivateKey);
44974502
}
44984503
}
44994504
#endif // NODE_FIPS_MODE

0 commit comments

Comments
 (0)