Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: introduce --openssl-is-fips flag #25412

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@
dest='openssl_fips',
help='Build OpenSSL using FIPS canister .o file in supplied folder')

parser.add_option('--openssl-is-fips',
action='store_true',
dest='openssl_is_fips',
help='specifies that the OpenSSL library is FIPS compatible')

parser.add_option('--openssl-use-def-ca-store',
action='store_true',
dest='use_openssl_ca_store',
Expand Down Expand Up @@ -1187,6 +1192,7 @@ def configure_openssl(o):
variables = o['variables']
variables['node_use_openssl'] = b(not options.without_ssl)
variables['node_shared_openssl'] = b(options.shared_openssl)
variables['openssl_is_fips'] = b(options.openssl_is_fips)
variables['openssl_fips'] = ''

if options.openssl_no_asm:
Expand Down
2 changes: 1 addition & 1 deletion node.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@
[ 'node_use_openssl=="true"', {
'defines': [ 'HAVE_OPENSSL=1' ],
'conditions': [
['openssl_fips != ""', {
['openssl_fips != "" or openssl_is_fips=="true"', {
'defines': [ 'NODE_FIPS_MODE' ],
}],
[ 'node_shared_openssl=="false"', {
Expand Down
13 changes: 9 additions & 4 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4505,9 +4505,14 @@ Sign::SignResult Sign::SignFinal(

#ifdef NODE_FIPS_MODE
/* Validate DSA2 parameters from FIPS 186-4 */
if (FIPS_mode() && EVP_PKEY_DSA == pkey->type) {
size_t L = BN_num_bits(pkey->pkey.dsa->p);
size_t N = BN_num_bits(pkey->pkey.dsa->q);
if (FIPS_mode() && EVP_PKEY_DSA == EVP_PKEY_base_id(pkey.get())) {
DSA* dsa = EVP_PKEY_get0_DSA(pkey.get());
const BIGNUM* p;
DSA_get0_pqg(dsa, &p, nullptr, nullptr);
size_t L = BN_num_bits(p);
const BIGNUM* q;
DSA_get0_pqg(dsa, nullptr, &q, nullptr);
size_t N = BN_num_bits(q);
bool result = false;

if (L == 1024 && N == 160)
Expand All @@ -4520,7 +4525,7 @@ Sign::SignResult Sign::SignFinal(
result = true;

if (!result) {
return kSignPrivateKey;
return SignResult(kSignPrivateKey);
}
}
#endif // NODE_FIPS_MODE
Expand Down