-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
crypto: fix aes crash when tag length too small
Fixes: #38883 PR-URL: #38914 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Loading branch information
Showing
2 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
test/parallel/test-crypto-webcrypto-aes-decrypt-tag-too-small.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/, | ||
}); | ||
}); |