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 — crypto: reject Ed25519/Ed448 in Sign/Verify prototypes · nodejs/node@d244204

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src/crypto
    • crypto_sig.cc
  • test/parallel
    • test-crypto-sign-verify.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/crypto/crypto_sig.cc‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_sig.cc
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,11 @@ void Sign::SignFinal(const FunctionCallbackInfo<Value>& args) {
420420
if (!key)
421421
return;
422422

423+
if (IsOneShot(key)) {
424+
THROW_ERR_CRYPTO_UNSUPPORTED_OPERATION(env);
425+
return;
426+
}
427+
423428
int padding = GetDefaultSignPadding(key);
424429
if (!args[offset]->IsUndefined()) {
425430
CHECK(args[offset]->IsInt32());
@@ -547,6 +552,11 @@ void Verify::VerifyFinal(const FunctionCallbackInfo<Value>& args) {
547552
if (!pkey)
548553
return;
549554

555+
if (IsOneShot(pkey)) {
556+
THROW_ERR_CRYPTO_UNSUPPORTED_OPERATION(env);
557+
return;
558+
}
559+
550560
ArrayBufferOrViewContents<char> hbuf(args[offset]);
551561
if (UNLIKELY(!hbuf.CheckSizeInt32()))
552562
return THROW_ERR_OUT_OF_RANGE(env, "buffer is too big");
Collapse file

‎test/parallel/test-crypto-sign-verify.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-crypto-sign-verify.js
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,3 +774,23 @@ assert.throws(
774774
}, { code: 'ERR_INVALID_ARG_TYPE', message: /The "key\.key" property must be of type object/ });
775775
}
776776
}
777+
778+
{
779+
// Ed25519 and Ed448 must use the one-shot methods
780+
const keys = [{ privateKey: fixtures.readKey('ed25519_private.pem', 'ascii'),
781+
publicKey: fixtures.readKey('ed25519_public.pem', 'ascii') },
782+
{ privateKey: fixtures.readKey('ed448_private.pem', 'ascii'),
783+
publicKey: fixtures.readKey('ed448_public.pem', 'ascii') }];
784+
785+
for (const { publicKey, privateKey } of keys) {
786+
assert.throws(() => {
787+
crypto.createSign('SHA256').update('Test123').sign(privateKey);
788+
}, { code: 'ERR_CRYPTO_UNSUPPORTED_OPERATION', message: 'Unsupported crypto operation' });
789+
assert.throws(() => {
790+
crypto.createVerify('SHA256').update('Test123').verify(privateKey, 'sig');
791+
}, { code: 'ERR_CRYPTO_UNSUPPORTED_OPERATION', message: 'Unsupported crypto operation' });
792+
assert.throws(() => {
793+
crypto.createVerify('SHA256').update('Test123').verify(publicKey, 'sig');
794+
}, { code: 'ERR_CRYPTO_UNSUPPORTED_OPERATION', message: 'Unsupported crypto operation' });
795+
}
796+
}

0 commit comments

Comments
0 (0)
You are visitor 01402503 — 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.