Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3363,15 +3363,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");
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!


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

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.

Expand Down