-
Notifications
You must be signed in to change notification settings - Fork 30k
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
crypto: use check macros in CipherBase::SetAuthTag #9395
Conversation
|
||
if (!buf->IsObject() || !Buffer::HasInstance(buf)) | ||
return env->ThrowTypeError("Auth tag must be a Buffer"); | ||
THROW_AND_RETURN_IF_NOT_BUFFER(args[0], "AAD"); |
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.
AAD
? I guess this line is copypasted, maybe this should be tag
or tagbuf
?
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.
Fixed. Should be "Auth tag".
Thank you.
3a0d076
to
5d01b27
Compare
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.
LGTM
|
||
CipherBase* cipher; | ||
ASSIGN_OR_RETURN_UNWRAP(&cipher, args.Holder()); | ||
|
||
if (!cipher->SetAuthTag(Buffer::Data(buf), Buffer::Length(buf))) |
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.
Note that the SPREAD_BUFFER_ARG
macro has been moved to util.h now and could likely be used to simplify this also.
|
||
if (!buf->IsObject() || !Buffer::HasInstance(buf)) | ||
return env->ThrowTypeError("Auth tag must be a Buffer"); | ||
THROW_AND_RETURN_IF_NOT_BUFFER(args[0], "Auth tag"); |
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.
There is a very subtle change in the error message here given that Buffer
is changed to buffer
. Unfortunately this means this has to be treated as a semver-major because it's a change in the error message. whee!
PR-URL: #9395 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Landed in 1ef401c |
PR-URL: nodejs#9395 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Checklist
Affected core subsystem(s)
crypto
Description of change
Use macros
THROW_AND_RETURN_IF_NOT_BUFFER
instead separate condition.