diff options
author | Stefan Budeanu <stefan@budeanu.com> | 2015-11-10 16:33:25 -0500 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2015-11-14 09:13:56 -0800 |
commit | 11ad744a92374ad71730cbfb7abea71fda0abb74 (patch) | |
tree | bc5a7bd6348294548e9231ec609f0b64618ecf24 /test/parallel/test-crypto-dh-odd-key.js | |
parent | a49b3af00b06dfd0e9301115cf077cc00a99a1c3 (diff) | |
download | node-new-11ad744a92374ad71730cbfb7abea71fda0abb74.tar.gz |
test: increase crypto strength for FIPS standard
Use stronger crypto (larger keys, etc.) for arbitrary tests so
they will pass in both FIPS and non-FIPS mode without altering
the original intent of the test cases.
PR-URL: https://github.com/nodejs/node/pull/3758
Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-crypto-dh-odd-key.js')
-rw-r--r-- | test/parallel/test-crypto-dh-odd-key.js | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/test/parallel/test-crypto-dh-odd-key.js b/test/parallel/test-crypto-dh-odd-key.js index abb4860b23..503ba2fe08 100644 --- a/test/parallel/test-crypto-dh-odd-key.js +++ b/test/parallel/test-crypto-dh-odd-key.js @@ -8,9 +8,18 @@ if (!common.hasCrypto) { } var crypto = require('crypto'); -var odd = new Buffer(39); -odd.fill('A'); +function test() { + var odd = new Buffer(39); + odd.fill('A'); -var c = crypto.createDiffieHellman(32); -c.setPrivateKey(odd); -c.generateKeys(); + var c = crypto.createDiffieHellman(32); + c.setPrivateKey(odd); + c.generateKeys(); +} + +// FIPS requires a length of at least 1024 +if (!common.hasFipsCrypto) { + assert.doesNotThrow(function() { test(); }); +} else { + assert.throws(function() { test(); }, /key size too small/); +} |