summaryrefslogtreecommitdiff
path: root/test/parallel/test-crypto-dh-odd-key.js
diff options
context:
space:
mode:
authorStefan Budeanu <stefan@budeanu.com>2015-11-10 16:33:25 -0500
committerJames M Snell <jasnell@gmail.com>2015-11-14 09:13:56 -0800
commit11ad744a92374ad71730cbfb7abea71fda0abb74 (patch)
treebc5a7bd6348294548e9231ec609f0b64618ecf24 /test/parallel/test-crypto-dh-odd-key.js
parenta49b3af00b06dfd0e9301115cf077cc00a99a1c3 (diff)
downloadnode-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.js19
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/);
+}