Skip to content

Commit

Permalink
crypto: rename generateKeyPairEdDSA
Browse files Browse the repository at this point in the history
Now that support for X25519 and X448 has been added, this function is
not used exclusively for EdDSA keys anymore.

PR-URL: #26900
Refs: #26774
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
  • Loading branch information
tniessen committed Mar 28, 2019
1 parent 230f1f2 commit df1c9eb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions lib/internal/crypto/keygen.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const {
generateKeyPairRSA,
generateKeyPairDSA,
generateKeyPairEC,
generateKeyPairEdDSA,
generateKeyPairNid,
EVP_PKEY_ED25519,
EVP_PKEY_ED448,
EVP_PKEY_X25519,
Expand Down Expand Up @@ -217,10 +217,10 @@ function check(type, options, callback) {
id = EVP_PKEY_X448;
break;
}
impl = (wrap) => generateKeyPairEdDSA(id,
publicFormat, publicType,
privateFormat, privateType,
cipher, passphrase, wrap);
impl = (wrap) => generateKeyPairNid(id,
publicFormat, publicType,
privateFormat, privateType,
cipher, passphrase, wrap);
}
break;
default:
Expand Down
10 changes: 5 additions & 5 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5835,9 +5835,9 @@ class ECKeyPairGenerationConfig : public KeyPairGenerationConfig {
const int param_encoding_;
};

class EdDSAKeyPairGenerationConfig : public KeyPairGenerationConfig {
class NidKeyPairGenerationConfig : public KeyPairGenerationConfig {
public:
explicit EdDSAKeyPairGenerationConfig(int id) : id_(id) {}
explicit NidKeyPairGenerationConfig(int id) : id_(id) {}

EVPKeyCtxPointer Setup() override {
return EVPKeyCtxPointer(EVP_PKEY_CTX_new_id(id_, nullptr));
Expand Down Expand Up @@ -6020,11 +6020,11 @@ void GenerateKeyPairEC(const FunctionCallbackInfo<Value>& args) {
GenerateKeyPair(args, 2, std::move(config));
}

void GenerateKeyPairEdDSA(const FunctionCallbackInfo<Value>& args) {
void GenerateKeyPairNid(const FunctionCallbackInfo<Value>& args) {
CHECK(args[0]->IsInt32());
const int id = args[0].As<Int32>()->Value();
std::unique_ptr<KeyPairGenerationConfig> config(
new EdDSAKeyPairGenerationConfig(id));
new NidKeyPairGenerationConfig(id));
GenerateKeyPair(args, 1, std::move(config));
}

Expand Down Expand Up @@ -6447,7 +6447,7 @@ void Initialize(Local<Object> target,
env->SetMethod(target, "generateKeyPairRSA", GenerateKeyPairRSA);
env->SetMethod(target, "generateKeyPairDSA", GenerateKeyPairDSA);
env->SetMethod(target, "generateKeyPairEC", GenerateKeyPairEC);
env->SetMethod(target, "generateKeyPairEdDSA", GenerateKeyPairEdDSA);
env->SetMethod(target, "generateKeyPairNid", GenerateKeyPairNid);
NODE_DEFINE_CONSTANT(target, EVP_PKEY_ED25519);
NODE_DEFINE_CONSTANT(target, EVP_PKEY_ED448);
NODE_DEFINE_CONSTANT(target, EVP_PKEY_X25519);
Expand Down

0 comments on commit df1c9eb

Please sign in to comment.