diff options
author | Tobias Nießen <tniessen@tnie.de> | 2020-01-21 22:14:15 +0300 |
---|---|---|
committer | Tobias Nießen <tniessen@tnie.de> | 2020-01-23 22:33:06 +0300 |
commit | f6c6236d956be763ffe8eb1420e19eaab2962e8d (patch) | |
tree | f587d1da67b25379f94337b6630c917cf945bebe /src/node_crypto.cc | |
parent | 8c313ceedfcc337f05022ffaabf2e42ef26d0cdf (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 606b63b7535..b589eac6947 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -5679,10 +5679,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; @@ -5690,7 +5687,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, |