forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
crypto: deprecate implicitly shortened GCM tags
This introduces a doc-only deprecation of using GCM authentication tags that are shorter than the cipher's block size, unless the user specified the authTagLength option. Refs: nodejs#52327 PR-URL: nodejs#52345 Reviewed-By: Filip Skokan <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Loading branch information
Showing
6 changed files
with
107 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
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
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
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
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,47 @@ | ||
// Flags: --pending-deprecation | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
|
||
const assert = require('assert'); | ||
const { createDecipheriv, randomBytes } = require('crypto'); | ||
|
||
common.expectWarning({ | ||
DeprecationWarning: [] | ||
}); | ||
|
||
const key = randomBytes(32); | ||
const iv = randomBytes(16); | ||
|
||
{ | ||
// Full 128-bit tag. | ||
|
||
const tag = randomBytes(16); | ||
createDecipheriv('aes-256-gcm', key, iv).setAuthTag(tag); | ||
} | ||
|
||
{ | ||
// Shortened tag with explicit length option. | ||
|
||
const tag = randomBytes(12); | ||
createDecipheriv('aes-256-gcm', key, iv, { | ||
authTagLength: tag.byteLength | ||
}).setAuthTag(tag); | ||
} | ||
|
||
{ | ||
// Shortened tag with explicit but incorrect length option. | ||
|
||
const tag = randomBytes(12); | ||
assert.throws(() => { | ||
createDecipheriv('aes-256-gcm', key, iv, { | ||
authTagLength: 14 | ||
}).setAuthTag(tag); | ||
}, { | ||
name: 'TypeError', | ||
message: 'Invalid authentication tag length: 12', | ||
code: 'ERR_CRYPTO_INVALID_AUTH_TAG' | ||
}); | ||
} |
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,21 @@ | ||
// Flags: --pending-deprecation | ||
'use strict'; | ||
const common = require('../common'); | ||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
|
||
const { createDecipheriv, randomBytes } = require('crypto'); | ||
|
||
common.expectWarning({ | ||
DeprecationWarning: [ | ||
['Using AES-GCM authentication tags of less than 128 bits without ' + | ||
'specifying the authTagLength option when initializing decryption is ' + | ||
'deprecated.', | ||
'DEP0182'], | ||
] | ||
}); | ||
|
||
const key = randomBytes(32); | ||
const iv = randomBytes(16); | ||
const tag = randomBytes(12); | ||
createDecipheriv('aes-256-gcm', key, iv).setAuthTag(tag); |