Skip to content

Commit 1ef401c

Browse files
fanatidjasnell
authored andcommitted
crypto: use check macros in CipherBase::SetAuthTag
PR-URL: #9395 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent a469f85 commit 1ef401c

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/node_crypto.cc

+2-5
Original file line numberDiff line numberDiff line change
@@ -3440,15 +3440,12 @@ bool CipherBase::SetAuthTag(const char* data, unsigned int len) {
34403440
void CipherBase::SetAuthTag(const FunctionCallbackInfo<Value>& args) {
34413441
Environment* env = Environment::GetCurrent(args);
34423442

3443-
Local<Object> buf = args[0].As<Object>();
3444-
3445-
if (!buf->IsObject() || !Buffer::HasInstance(buf))
3446-
return env->ThrowTypeError("Auth tag must be a Buffer");
3443+
THROW_AND_RETURN_IF_NOT_BUFFER(args[0], "Auth tag");
34473444

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

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

0 commit comments

Comments
 (0)