GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: refactor ECDHBitsJob signature · nodejs/node@d26dedf

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/crypto
    • diffiehellman.js
  • src/crypto
    • crypto_ec.cc
    • crypto_ec.h
    • crypto_keys.cc
    • crypto_keys.h
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/crypto/diffiehellman.js‎

Copy file name to clipboardExpand all lines: lib/internal/crypto/diffiehellman.js
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,6 @@ async function ecdhDeriveBits(algorithm, baseKey, length) {
332332

333333
const bits = await jobPromise(() => new ECDHBitsJob(
334334
kCryptoJobAsync,
335-
key.algorithm.name === 'ECDH' ? baseKey.algorithm.namedCurve : baseKey.algorithm.name,
336335
key[kKeyObject][kHandle],
337336
baseKey[kKeyObject][kHandle]));
338337

Collapse file

‎src/crypto/crypto_ec.cc‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_ec.cc
+5-25Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,6 @@ int GetCurveFromName(const char* name) {
4545
return nid;
4646
}
4747

48-
int GetOKPCurveFromName(const char* name) {
49-
int nid;
50-
if (strcmp(name, "Ed25519") == 0) {
51-
nid = EVP_PKEY_ED25519;
52-
} else if (strcmp(name, "Ed448") == 0) {
53-
nid = EVP_PKEY_ED448;
54-
} else if (strcmp(name, "X25519") == 0) {
55-
nid = EVP_PKEY_X25519;
56-
} else if (strcmp(name, "X448") == 0) {
57-
nid = EVP_PKEY_X448;
58-
} else {
59-
nid = NID_undef;
60-
}
61-
return nid;
62-
}
63-
6448
void ECDH::Initialize(Environment* env, Local<Object> target) {
6549
Isolate* isolate = env->isolate();
6650
Local<Context> context = env->context();
@@ -450,25 +434,21 @@ Maybe<void> ECDHBitsTraits::AdditionalConfig(
450434
ECDHBitsConfig* params) {
451435
Environment* env = Environment::GetCurrent(args);
452436

453-
CHECK(args[offset]->IsString()); // curve name
454-
CHECK(args[offset + 1]->IsObject()); // public key
455-
CHECK(args[offset + 2]->IsObject()); // private key
437+
CHECK(args[offset]->IsObject()); // public key
438+
CHECK(args[offset + 1]->IsObject()); // private key
456439

457440
KeyObjectHandle* private_key;
458441
KeyObjectHandle* public_key;
459442

460-
Utf8Value name(env->isolate(), args[offset]);
461-
462-
ASSIGN_OR_RETURN_UNWRAP(&public_key, args[offset + 1], Nothing<void>());
463-
ASSIGN_OR_RETURN_UNWRAP(&private_key, args[offset + 2], Nothing<void>());
443+
ASSIGN_OR_RETURN_UNWRAP(&public_key, args[offset], Nothing<void>());
444+
ASSIGN_OR_RETURN_UNWRAP(&private_key, args[offset + 1], Nothing<void>());
464445

465446
if (private_key->Data().GetKeyType() != kKeyTypePrivate ||
466447
public_key->Data().GetKeyType() != kKeyTypePublic) {
467448
THROW_ERR_CRYPTO_INVALID_KEYTYPE(env);
468449
return Nothing<void>();
469450
}
470451

471-
params->id_ = GetOKPCurveFromName(*name);
472452
params->private_ = private_key->Data().addRef();
473453
params->public_ = public_key->Data().addRef();
474454

@@ -482,7 +462,7 @@ bool ECDHBitsTraits::DeriveBits(Environment* env,
482462
const auto& m_privkey = params.private_.GetAsymmetricKey();
483463
const auto& m_pubkey = params.public_.GetAsymmetricKey();
484464

485-
switch (params.id_) {
465+
switch (m_privkey.id()) {
486466
case EVP_PKEY_X25519:
487467
// Fall through
488468
case EVP_PKEY_X448: {
Collapse file

‎src/crypto/crypto_ec.h‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_ec.h
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
namespace node {
1717
namespace crypto {
1818
int GetCurveFromName(const char* name);
19-
int GetOKPCurveFromName(const char* name);
2019

2120
class ECDH final : public BaseObject {
2221
public:
Collapse file

‎src/crypto/crypto_keys.cc‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_keys.cc
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,22 @@ void KeyObjectHandle::InitECRaw(const FunctionCallbackInfo<Value>& args) {
909909
args.GetReturnValue().Set(true);
910910
}
911911

912+
int GetOKPCurveFromName(const char* name) {
913+
int nid;
914+
if (strcmp(name, "Ed25519") == 0) {
915+
nid = EVP_PKEY_ED25519;
916+
} else if (strcmp(name, "Ed448") == 0) {
917+
nid = EVP_PKEY_ED448;
918+
} else if (strcmp(name, "X25519") == 0) {
919+
nid = EVP_PKEY_X25519;
920+
} else if (strcmp(name, "X448") == 0) {
921+
nid = EVP_PKEY_X448;
922+
} else {
923+
nid = NID_undef;
924+
}
925+
return nid;
926+
}
927+
912928
void KeyObjectHandle::InitEDRaw(const FunctionCallbackInfo<Value>& args) {
913929
Environment* env = Environment::GetCurrent(args);
914930
KeyObjectHandle* key;
Collapse file

‎src/crypto/crypto_keys.h‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_keys.h
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,8 @@ WebCryptoKeyExportStatus PKEY_SPKI_Export(const KeyObjectData& key_data,
408408
WebCryptoKeyExportStatus PKEY_PKCS8_Export(const KeyObjectData& key_data,
409409
ByteSource* out);
410410

411+
int GetOKPCurveFromName(const char* name);
412+
411413
namespace Keys {
412414
void Initialize(Environment* env, v8::Local<v8::Object> target);
413415
void RegisterExternalReferences(ExternalReferenceRegistry* registry);

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.