diff options
author | Jonathan Buhacoff <jonathan@buhacoff.net> | 2020-04-27 19:19:30 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2020-05-08 02:37:26 +0300 |
commit | d135b508e907585bfe699e4edbe2c3c6d1785dcd (patch) | |
tree | d37d2ca5ab879091eb2700023a953077d17e2c5f /doc/api/crypto.md | |
parent | ab22d2cdcbf5fa193a5e237200dd3e17c7084b49 (diff) |
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.
Diffstat (limited to 'doc/api/crypto.md')
-rw-r--r-- | doc/api/crypto.md | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 7b97edac68f..9dc9fe537bb 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -520,8 +520,9 @@ cipher text should be discarded due to failed authentication. If the tag length is invalid according to [NIST SP 800-38D][] or does not match the value of the `authTagLength` option, `decipher.setAuthTag()` will throw an error. -The `decipher.setAuthTag()` method must be called before -[`decipher.final()`][] and can only be called once. +The `decipher.setAuthTag()` method must be called before [`decipher.update()`][] +for `CCM` mode or before [`decipher.final()`][] for `GCM` and `OCB` modes. +`decipher.setAuthTag()` can only be called once. ### `decipher.setAutoPadding([autoPadding])` <!-- YAML |