test: make test-dh-regr more efficient where possible

test-dh-regr is timing out in CI because crypto.createDiffieHellman() is
considerably slower after an OpenSSL upgrade. This PR modifies the
change from 11ad744a92374ad71730cbfb7abea71fda0abb74 which made the test
FIPS-compatible. When not in FIPS mode, the test will use a shorter key
which will enable it to run much faster.

PR-URL: https://github.com/nodejs/node/pull/28390
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
This commit is contained in:
Rich Trott 2019-06-22 15:57:14 -06:00 committed by Daniel Bevenius
parent 2e8e0707d0
commit c3284822af

View File

@ -27,7 +27,11 @@ if (!common.hasCrypto)
const assert = require('assert');
const crypto = require('crypto');
const p = crypto.createDiffieHellman(1024).getPrime();
// FIPS requires length >= 1024 but we use 256 in this test to keep it from
// taking too long and timing out in CI.
const length = common.hasFipsCrypto ? 1024 : 256;
const p = crypto.createDiffieHellman(length).getPrime();
for (let i = 0; i < 2000; i++) {
const a = crypto.createDiffieHellman(p);