Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

fanatid
Copy link
Contributor

@fanatid fanatid commented Nov 1, 2016

Checklist
  • commit message follows commit guidelines
Affected core subsystem(s)

crypto

Description of change

Use macros THROW_AND_RETURN_IF_NOT_BUFFER instead separate condition.

@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Nov 1, 2016

if (!buf->IsObject() || !Buffer::HasInstance(buf))
return env->ThrowTypeError("Auth tag must be a Buffer");
THROW_AND_RETURN_IF_NOT_BUFFER(args[0], "AAD");
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@addaleax addaleax added the crypto Issues and PRs related to the crypto subsystem. label Nov 1, 2016
@jasnell jasnell added the semver-major PRs that contain breaking changes and should be released in the next major version. label Nov 2, 2016

CipherBase* cipher;
ASSIGN_OR_RETURN_UNWRAP(&cipher, args.Holder());

if (!cipher->SetAuthTag(Buffer::Data(buf), Buffer::Length(buf)))
Copy link
Member

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");
Copy link
Member

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!

@addaleax addaleax added this to the 8.0.0 milestone Nov 20, 2016
@jasnell
Copy link
Member

jasnell commented Jan 11, 2017

jasnell pushed a commit that referenced this pull request Jan 11, 2017
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>
@jasnell
Copy link
Member

jasnell commented Jan 11, 2017

Landed in 1ef401c

@jasnell jasnell closed this Jan 11, 2017
@fanatid fanatid deleted the crypto/SetAuthTag branch January 11, 2017 06:31
italoacasas pushed a commit to italoacasas/node that referenced this pull request Jan 18, 2017
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>
@jasnell jasnell mentioned this pull request Apr 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. crypto Issues and PRs related to the crypto subsystem. semver-major PRs that contain breaking changes and should be released in the next major version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants