diff options
author | XadillaX <i@2333.moe> | 2021-06-03 10:40:50 +0300 |
---|---|---|
committer | Danielle Adams <adamzdanielle@gmail.com> | 2021-06-21 18:08:05 +0300 |
commit | cf9d686c353c5658048e8cfa999363cc848d43a4 (patch) | |
tree | ee3d8a8544a85a36a46660a7af0085d2037756bd /test | |
parent | c6aa68598d2fccc5a64305897d83a569471fc07d (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/, + }); + }); |