Skip to content

Commit 0c7cf24

Browse files
jbuhacoffcodebytere
authored andcommittedJun 7, 2020
doc: correct description of decipher.setAuthTag in crypto.md
Calling `decipher.setAuthTag` after `decipher.update` will result in an error like `Unsupported state or unable to authenticate data`. The example code in [CCM mode](https://nodejs.org/docs/latest-v14.x/api/crypto.html#crypto_ccm_mode) is correct, but to demonstrate the mistake in the documentation you can take the same example and move the `setAuthTag` call to in between `update` and `final` you will see the error.
1 parent 0177cbf commit 0c7cf24

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed
 

‎doc/api/crypto.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,9 @@ cipher text should be discarded due to failed authentication. If the tag length
520520
is invalid according to [NIST SP 800-38D][] or does not match the value of the
521521
`authTagLength` option, `decipher.setAuthTag()` will throw an error.
522522

523-
The `decipher.setAuthTag()` method must be called before
524-
[`decipher.final()`][] and can only be called once.
523+
The `decipher.setAuthTag()` method must be called before [`decipher.update()`][]
524+
for `CCM` mode or before [`decipher.final()`][] for `GCM` and `OCB` modes.
525+
`decipher.setAuthTag()` can only be called once.
525526

526527
### `decipher.setAutoPadding([autoPadding])`
527528
<!-- YAML

0 commit comments

Comments
 (0)
Please sign in to comment.