diff options
author | Tobias Nießen <tniessen@tnie.de> | 2020-01-21 22:14:15 +0300 |
---|---|---|
committer | Shelley Vohr <shelley.vohr@gmail.com> | 2020-02-17 21:58:17 +0300 |
commit | f84b34d42c88329b23e5de9592bb9d5e9bb51ac8 (patch) | |
tree | 2b3418a319927c28bee0b86c897559040a0ddf92 /src/node_crypto.cc | |
parent | 4591202e660d4b58766f468d99d25f6330e47067 (diff) |
crypto: improve errors in DiffieHellmanGroup
1. The DiffieHellmanGroup class is only instantiated from within
Node.js, which always passes exactly one argument.
2. Use the existing ERR_CRYPTO_UNKNOWN_DH_GROUP error code for the
existing "Unknown group" error. The message has not been changed
to prevent breaking existing applications.
PR-URL: https://github.com/nodejs/node/pull/31445
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_crypto.cc')
-rw-r--r-- | src/node_crypto.cc | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 47000b79d52..7f9818bba33 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -5682,10 +5682,7 @@ void DiffieHellman::DiffieHellmanGroup( Environment* env = Environment::GetCurrent(args); DiffieHellman* diffieHellman = new DiffieHellman(env, args.This()); - if (args.Length() != 1) { - return THROW_ERR_MISSING_ARGS(env, "Group name argument is mandatory"); - } - + CHECK_EQ(args.Length(), 1); THROW_AND_RETURN_IF_NOT_STRING(env, args[0], "Group name"); bool initialized = false; @@ -5693,7 +5690,7 @@ void DiffieHellman::DiffieHellmanGroup( const node::Utf8Value group_name(env->isolate(), args[0]); const modp_group* group = FindDiffieHellmanGroup(*group_name); if (group == nullptr) - return env->ThrowError("Unknown group"); + return THROW_ERR_CRYPTO_UNKNOWN_DH_GROUP(env, "Unknown group"); initialized = diffieHellman->Init(group->prime, group->prime_size, |