crypto: simplify Hmac::HmacUpdate
This makes HmacUpdate slightly simpler and introduces a CHECK instead of ignoring invalid input types. PR-URL: https://github.com/nodejs/node/pull/22132 Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
5fded26e9e
commit
7e29453d2f
@ -3252,15 +3252,14 @@ void Hmac::HmacUpdate(const FunctionCallbackInfo<Value>& args) {
|
||||
ASSIGN_OR_RETURN_UNWRAP(&hmac, args.Holder());
|
||||
|
||||
// Only copy the data if we have to, because it's a string
|
||||
bool r = true;
|
||||
bool r = false;
|
||||
if (args[0]->IsString()) {
|
||||
StringBytes::InlineDecoder decoder;
|
||||
if (!decoder.Decode(env, args[0].As<String>(), args[1], UTF8)) {
|
||||
args.GetReturnValue().Set(false);
|
||||
return;
|
||||
if (decoder.Decode(env, args[0].As<String>(), args[1], UTF8)) {
|
||||
r = hmac->HmacUpdate(decoder.out(), decoder.size());
|
||||
}
|
||||
r = hmac->HmacUpdate(decoder.out(), decoder.size());
|
||||
} else if (args[0]->IsArrayBufferView()) {
|
||||
} else {
|
||||
CHECK(args[0]->IsArrayBufferView());
|
||||
char* buf = Buffer::Data(args[0]);
|
||||
size_t buflen = Buffer::Length(args[0]);
|
||||
r = hmac->HmacUpdate(buf, buflen);
|
||||
|
Loading…
x
Reference in New Issue
Block a user