node/test/parallel/test-dsa-fips-invalid-key.js
James M Snell 761de815c5
test: move crypto related common utilities in common/crypto
Since `common/crypto` already exists, it makes sense to keep
crypto-related utilities there. The only exception being
common.hasCrypto which is needed up front to determine
if tests should be skipped.

Eliminate the redundant check in hasFipsCrypto and just
use crypto.getFips() directly where needed.

PR-URL: https://github.com/nodejs/node/pull/56714
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2025-01-25 00:58:32 +00:00

26 lines
536 B
JavaScript

'use strict';
const common = require('../common');
if (!common.hasCrypto) {
common.skip('no crypto');
}
const fixtures = require('../common/fixtures');
const crypto = require('crypto');
if (!crypto.getFips()) {
common.skip('node compiled without FIPS OpenSSL.');
}
const assert = require('assert');
const input = 'hello';
const dsapri = fixtures.readKey('dsa_private_1025.pem');
const sign = crypto.createSign('SHA1');
sign.update(input);
assert.throws(function() {
sign.sign(dsapri);
}, /PEM_read_bio_PrivateKey failed/);