summaryrefslogtreecommitdiff
path: root/test/parallel/test-crypto-authenticated.js
diff options
context:
space:
mode:
authorTobias Nießen <tniessen@tnie.de>2017-12-22 18:51:33 +0100
committerJames M Snell <jasnell@gmail.com>2018-04-14 10:50:47 -0700
commitd81a7b4baae32efd63b8c9595c654502d64be4e3 (patch)
tree3d4e165de48af8ad28dac089faef59fd3238c90b /test/parallel/test-crypto-authenticated.js
parent2b0825e77feb262cf862982cabf7a67bf58f4d5b (diff)
downloadandroid-node-v8-d81a7b4baae32efd63b8c9595c654502d64be4e3.tar.gz
android-node-v8-d81a7b4baae32efd63b8c9595c654502d64be4e3.tar.bz2
android-node-v8-d81a7b4baae32efd63b8c9595c654502d64be4e3.zip
crypto: throw on invalid authentication tag length
Refs: https://github.com/nodejs/node/issues/17523 PR-URL: https://github.com/nodejs/node/pull/17825 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-crypto-authenticated.js')
-rw-r--r--test/parallel/test-crypto-authenticated.js26
1 files changed, 13 insertions, 13 deletions
diff --git a/test/parallel/test-crypto-authenticated.js b/test/parallel/test-crypto-authenticated.js
index 73e3a23f72..df5ba03923 100644
--- a/test/parallel/test-crypto-authenticated.js
+++ b/test/parallel/test-crypto-authenticated.js
@@ -534,13 +534,8 @@ const expectedWarnings = common.hasFipsCrypto ?
['Use Cipheriv for counter mode of aes-256-ccm', common.noWarnCode]
];
-const expectedDeprecationWarnings = [0, 1, 2, 6, 9, 10, 11, 17]
- .map((i) => [`Permitting authentication tag lengths of ${i} bytes is ` +
- 'deprecated. Valid GCM tag lengths are 4, 8, 12, 13, 14, 15, 16.',
- 'DEP0090']);
-
-expectedDeprecationWarnings.push(['crypto.DEFAULT_ENCODING is deprecated.',
- 'DEP0091']);
+const expectedDeprecationWarnings = ['crypto.DEFAULT_ENCODING is deprecated.',
+ 'DEP0091'];
common.expectWarning({
Warning: expectedWarnings,
@@ -719,13 +714,18 @@ for (const test of TEST_CASES) {
}
// GCM only supports specific authentication tag lengths, invalid lengths should
-// produce warnings.
+// throw.
{
- for (const length of [0, 1, 2, 4, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]) {
- const decrypt = crypto.createDecipheriv('aes-256-gcm',
- 'FxLKsqdmv0E9xrQhp0b1ZgI0K7JFZJM8',
- 'qkuZpJWCewa6Szih');
- decrypt.setAuthTag(Buffer.from('1'.repeat(length)));
+ for (const length of [0, 1, 2, 6, 9, 10, 11, 17]) {
+ common.expectsError(() => {
+ const decrypt = crypto.createDecipheriv('aes-128-gcm',
+ 'FxLKsqdmv0E9xrQh',
+ 'qkuZpJWCewa6Szih');
+ decrypt.setAuthTag(Buffer.from('1'.repeat(length)));
+ }, {
+ type: Error,
+ message: `Invalid GCM authentication tag length: ${length}`
+ });
}
}