diff options
author | Tobias Nießen <tniessen@tnie.de> | 2020-02-24 16:25:03 +0300 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2020-02-29 21:01:46 +0300 |
commit | 46b92c854deeca6cb0d1b3d473f7f006b3f59639 (patch) | |
tree | b8e4145d700ffd3673352d00ac8139cd7b74de79 /src/node_crypto.cc | |
parent | 311e12b96201c01d6c66c800d8cfc59ebf9bc4ae (diff) |
crypto: turn impossible DH errors into assertions
PR-URL: https://github.com/nodejs/node/pull/31934
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'src/node_crypto.cc')
-rw-r--r-- | src/node_crypto.cc | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/src/node_crypto.cc b/src/node_crypto.cc index a8a067086f6..ea719d3c5c9 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -5938,11 +5938,7 @@ void DiffieHellman::ComputeSecret(const FunctionCallbackInfo<Value>& args) { ClearErrorOnReturn clear_error_on_return; - if (args.Length() == 0) { - return THROW_ERR_MISSING_ARGS( - env, "Other party's public key argument is mandatory"); - } - + CHECK_EQ(args.Length(), 1); THROW_AND_RETURN_IF_NOT_BUFFER(env, args[0], "Other party's public key"); ArrayBufferViewContents<unsigned char> key_buf(args[0].As<ArrayBufferView>()); BignumPointer key(BN_bin2bn(key_buf.data(), key_buf.length(), nullptr)); @@ -5993,11 +5989,7 @@ void DiffieHellman::SetKey(const FunctionCallbackInfo<Value>& args, char errmsg[64]; - if (args.Length() == 0) { - snprintf(errmsg, sizeof(errmsg), "%s argument is mandatory", what); - return THROW_ERR_MISSING_ARGS(env, errmsg); - } - + CHECK_EQ(args.Length(), 1); if (!Buffer::HasInstance(args[0])) { snprintf(errmsg, sizeof(errmsg), "%s must be a buffer", what); return THROW_ERR_INVALID_ARG_TYPE(env, errmsg); |