-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update crypto.md to correct description of decipher.setAuthTag
#33097
Conversation
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.
That's not quite correct since only CCM mode needs to have |
Right, that should be documented. I suggested changing it to mention |
I think adding a note about the differences between the modes with regard to calling |
Restore note about calling setAuthTag before decipher.final and add new note about calling it before decipher.update for CCM mode.
Updated the pull request to address comments by @mscdex, please check it. |
doc/api/crypto.md
Outdated
@@ -522,6 +522,8 @@ is invalid according to [NIST SP 800-38D][] or does not match the value of the | |||
|
|||
The `decipher.setAuthTag()` method must be called before |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just modify this sentence instead to clarify, something like:
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks! I just pushed a correction with this advice.
Added detail to note about calling setAuthTag before decipher.final to mention that for CCM mode it must be called before decipher.update.
Added detail to descripption of `decipher.setAuthTag()` method that it must be called before `decipher.update()` for `CCM` mode.
/cc @nodejs/crypto to make sure this is the intended behavior |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that's correct. GCM and OCB are online AEADs, CCM is not.
Landed in d135b50, thanks for the PR! 🎉 |
Calling
decipher.setAuthTag
afterdecipher.update
will result in an error likeUnsupported state or unable to authenticate data
. The example code in CCM mode is correct, but to demonstrate the mistake in the documentation you can take the same example and move thesetAuthTag
call to in betweenupdate
andfinal
you will see the error.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes