summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTobias Nießen <tniessen@tnie.de>2019-01-07 20:27:31 +0100
committerTobias Nießen <tniessen@tnie.de>2019-01-11 17:17:34 +0100
commit7710235ec35586c15f83e826926ea8bfe2a35a22 (patch)
tree2b6df916100411646574d29af21ceeec7820a201 /test
parent84f0581d36bddbf7083e82c082275ef562fa8568 (diff)
downloadandroid-node-v8-7710235ec35586c15f83e826926ea8bfe2a35a22.tar.gz
android-node-v8-7710235ec35586c15f83e826926ea8bfe2a35a22.tar.bz2
android-node-v8-7710235ec35586c15f83e826926ea8bfe2a35a22.zip
test: improve test coverage of native crypto code
PR-URL: https://github.com/nodejs/node/pull/25400 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-crypto-cipheriv-decipheriv.js12
-rw-r--r--test/parallel/test-crypto-hmac.js6
-rw-r--r--test/parallel/test-crypto-sign-verify.js6
3 files changed, 24 insertions, 0 deletions
diff --git a/test/parallel/test-crypto-cipheriv-decipheriv.js b/test/parallel/test-crypto-cipheriv-decipheriv.js
index e4c7fced58..b0ad7a97da 100644
--- a/test/parallel/test-crypto-cipheriv-decipheriv.js
+++ b/test/parallel/test-crypto-cipheriv-decipheriv.js
@@ -205,3 +205,15 @@ for (let n = 1; n < 256; n += 1) {
if (common.hasFipsCrypto && n < 12) continue;
crypto.createCipheriv('aes-128-gcm', Buffer.alloc(16), Buffer.alloc(n));
}
+
+{
+ // Passing an invalid cipher name should throw.
+ assert.throws(
+ () => crypto.createCipheriv('aes-127', Buffer.alloc(16), null),
+ /Unknown cipher/);
+
+ // Passing a key with an invalid length should throw.
+ assert.throws(
+ () => crypto.createCipheriv('aes-128-ecb', Buffer.alloc(17), null),
+ /Invalid key length/);
+}
diff --git a/test/parallel/test-crypto-hmac.js b/test/parallel/test-crypto-hmac.js
index 9e0e364a4f..21ff3b0b04 100644
--- a/test/parallel/test-crypto-hmac.js
+++ b/test/parallel/test-crypto-hmac.js
@@ -449,3 +449,9 @@ common.expectsError(
assert.deepStrictEqual(h.digest('latin1'), '');
}
}
+
+{
+ assert.throws(
+ () => crypto.createHmac('sha7', 'key'),
+ /Unknown message digest/);
+}
diff --git a/test/parallel/test-crypto-sign-verify.js b/test/parallel/test-crypto-sign-verify.js
index 0499b3091c..da4e8aa331 100644
--- a/test/parallel/test-crypto-sign-verify.js
+++ b/test/parallel/test-crypto-sign-verify.js
@@ -363,3 +363,9 @@ common.expectsError(
assert.throws(() => verify.verify('test', input), errObj);
});
}
+
+{
+ assert.throws(
+ () => crypto.createSign('sha8'),
+ /Unknown message digest/);
+}