Skip to content

Commit

Permalink
crypto: use check macros in CipherBase::SetAuthTag
Browse files Browse the repository at this point in the history
PR-URL: #9395
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
fanatid authored and jasnell committed Jan 11, 2017
1 parent a469f85 commit 1ef401c
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3440,15 +3440,12 @@ bool CipherBase::SetAuthTag(const char* data, unsigned int len) {
void CipherBase::SetAuthTag(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);

Local<Object> buf = args[0].As<Object>();

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");

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

if (!cipher->SetAuthTag(Buffer::Data(buf), Buffer::Length(buf)))
if (!cipher->SetAuthTag(Buffer::Data(args[0]), Buffer::Length(args[0])))
env->ThrowError("Attempting to set auth tag in unsupported state");
}

Expand Down

0 comments on commit 1ef401c

Please sign in to comment.