diff options
author | James M Snell <jasnell@gmail.com> | 2017-10-24 10:04:25 -0700 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2017-10-26 07:47:16 -0700 |
commit | eeada6ca63d57354aef3e5907097c56a5b9fb347 (patch) | |
tree | 4f622499b23e44bedc34ef2fc1366eb167913979 /src/node_crypto.cc | |
parent | 664512678d8d02e2ef413136cf262dcf7debb42d (diff) | |
download | android-node-v8-eeada6ca63d57354aef3e5907097c56a5b9fb347.tar.gz android-node-v8-eeada6ca63d57354aef3e5907097c56a5b9fb347.tar.bz2 android-node-v8-eeada6ca63d57354aef3e5907097c56a5b9fb347.zip |
crypto: migrate timingSafeEqual to internal/errors
PR-URL: https://github.com/nodejs/node/pull/16448
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'src/node_crypto.cc')
-rw-r--r-- | src/node_crypto.cc | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 450a841eae..1b8d14825f 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -5848,15 +5848,11 @@ void ExportChallenge(const FunctionCallbackInfo<Value>& args) { } void TimingSafeEqual(const FunctionCallbackInfo<Value>& args) { - Environment* env = Environment::GetCurrent(args); - - THROW_AND_RETURN_IF_NOT_BUFFER(args[0], "First argument"); - THROW_AND_RETURN_IF_NOT_BUFFER(args[1], "Second argument"); + CHECK(Buffer::HasInstance(args[0])); + CHECK(Buffer::HasInstance(args[1])); size_t buf_length = Buffer::Length(args[0]); - if (buf_length != Buffer::Length(args[1])) { - return env->ThrowTypeError("Input buffers must have the same length"); - } + CHECK_EQ(buf_length, Buffer::Length(args[1])); const char* buf1 = Buffer::Data(args[0]); const char* buf2 = Buffer::Data(args[1]); |