crypto: use check macros in CipherBase::SetAuthTag
PR-URL: https://github.com/nodejs/node/pull/9395 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
a469f85653
commit
1ef401ce92
@ -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");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user