diff options
author | XadillaX <i@2333.moe> | 2021-06-03 10:40:50 +0300 |
---|---|---|
committer | XadillaX <i@2333.moe> | 2021-06-15 09:21:28 +0300 |
commit | 7a9635b094b11201c9098312c805f8f72ac775ed (patch) | |
tree | bd2c4a678e4e56a1e42d75e71886b6fbb73a8911 /test | |
parent | 98140238ee19ba80e6b5eb13cc8fdf9c88e2558f (diff) |
crypto: fix aes crash when tag length too small
Fixes: https://github.com/nodejs/node/issues/38883
PR-URL: https://github.com/nodejs/node/pull/38914
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-crypto-webcrypto-aes-decrypt-tag-too-small.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/parallel/test-crypto-webcrypto-aes-decrypt-tag-too-small.js b/test/parallel/test-crypto-webcrypto-aes-decrypt-tag-too-small.js new file mode 100644 index 00000000000..b9f9c74b262 --- /dev/null +++ b/test/parallel/test-crypto-webcrypto-aes-decrypt-tag-too-small.js @@ -0,0 +1,29 @@ +'use strict'; + +const common = require('../common'); + +if (!common.hasCrypto) + common.skip('missing crypto'); + +const assert = require('assert'); +const crypto = require('crypto').webcrypto; + +crypto.subtle.importKey( + 'raw', + new Uint8Array(32), + { + name: 'AES-GCM' + }, + false, + [ 'encrypt', 'decrypt' ]) + .then((k) => { + assert.rejects(() => { + return crypto.subtle.decrypt({ + name: 'AES-GCM', + iv: new Uint8Array(12), + }, k, new Uint8Array(0)); + }, { + name: 'OperationError', + message: /The provided data is too small/, + }); + }); |