0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-crypto-classes.js
Bryan English 3e4f34cdb9 test: fix flaky test-crypto-classes.js
On non-FIPS, we can instantiate DiffieHellman with 256 instead of 1024.
This should be quite a bit faster, and therefore prevent the timeouts.

PR-URL: https://github.com/nodejs/node/pull/15662
Fixes: https://github.com/nodejs/node/issues/15655
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2017-09-30 22:07:18 -07:00

34 lines
904 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
const crypto = require('crypto');
// 'ClassName' : ['args', 'for', 'constructor']
const TEST_CASES = {
'Hash': ['sha1'],
'Hmac': ['sha1', 'Node'],
'Cipheriv': ['des-ede3-cbc', '0123456789abcd0123456789', '12345678'],
'Decipheriv': ['des-ede3-cbc', '0123456789abcd0123456789', '12345678'],
'Sign': ['RSA-SHA1'],
'Verify': ['RSA-SHA1'],
'DiffieHellman': [1024],
'DiffieHellmanGroup': ['modp5'],
'ECDH': ['prime256v1'],
'Credentials': []
};
if (!common.hasFipsCrypto) {
TEST_CASES.Cipher = ['aes192', 'secret'];
TEST_CASES.Decipher = ['aes192', 'secret'];
TEST_CASES.DiffieHellman = [256];
}
for (const [clazz, args] of Object.entries(TEST_CASES)) {
assert(crypto[`create${clazz}`](...args) instanceof crypto[clazz]);
}