Description
We have an application running on Node.js v20.19.3(https://nodejs.org/dist/v20.19.3/).
Followed the steps listed in https://nodejs.org/dist/latest-v20.x/docs/api/crypto.html#fips-mode to enable FIPS on it.
We see that FIPS is enabled(as getFips() returns 1). But when I want to create a hash using SHA256, it threw an error saying 'ERR_OSSL_EVP_UNSUPPORTED'.
On futher analysis, we found that crypto.getHashes() is returning empty array when FIPS is enabled.
The sample program we tried is
===========================================================================
const crypto = require('crypto');
try {
crypto.setFips(1); // Enable FIPS
console.log("FIPS Mode:", crypto.getFips()); // Should print 1
console.log("Available Hashes:", crypto.getHashes()); // Should print only FIPS-compliant hashes
} catch (err) {
console.error("FIPS error:", err.message);
}
Response:
FIPS Mode: 1
Available Hashes: []
===========================================================================
But when we set FIPS to 0 (crypto.setFips(0)), it gave a list of hashes available.
We have also tried to build Node.js from source code, and even that resulted in the same issue.
Can someone help us with where we are going wrong with this?