| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 128c60d commit 9f939f5
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -423,6 +423,11 @@ void Sign::SignFinal(const FunctionCallbackInfo<Value>& args) { | |||
| 423 | 423 | if (!key) | |
| 424 | 424 | return; | |
| 425 | 425 | ||
| 426 | + if (IsOneShot(key)) { | ||
| 427 | + THROW_ERR_CRYPTO_UNSUPPORTED_OPERATION(env); | ||
| 428 | + return; | ||
| 429 | + } | ||
| 430 | + | ||
| 426 | 431 | int padding = GetDefaultSignPadding(key); | |
| 427 | 432 | if (!args[offset]->IsUndefined()) { | |
| 428 | 433 | CHECK(args[offset]->IsInt32()); | |
@@ -548,6 +553,11 @@ void Verify::VerifyFinal(const FunctionCallbackInfo<Value>& args) { | |||
| 548 | 553 | if (!pkey) | |
| 549 | 554 | return; | |
| 550 | 555 | ||
| 556 | + if (IsOneShot(pkey)) { | ||
| 557 | + THROW_ERR_CRYPTO_UNSUPPORTED_OPERATION(env); | ||
| 558 | + return; | ||
| 559 | + } | ||
| 560 | + | ||
| 551 | 561 | ArrayBufferOrViewContents<char> hbuf(args[offset]); | |
| 552 | 562 | if (UNLIKELY(!hbuf.CheckSizeInt32())) | |
| 553 | 563 | return THROW_ERR_OUT_OF_RANGE(env, "buffer is too big"); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -773,3 +773,23 @@ assert.throws( | |||
| 773 | 773 | }, { code: 'ERR_INVALID_ARG_TYPE', message: /The "key\.key" property must be of type object/ }); | |
| 774 | 774 | } | |
| 775 | 775 | } | |
| 776 | + | ||
| 777 | + { | ||
| 778 | + // Ed25519 and Ed448 must use the one-shot methods | ||
| 779 | + const keys = [{ privateKey: fixtures.readKey('ed25519_private.pem', 'ascii'), | ||
| 780 | + publicKey: fixtures.readKey('ed25519_public.pem', 'ascii') }, | ||
| 781 | + { privateKey: fixtures.readKey('ed448_private.pem', 'ascii'), | ||
| 782 | + publicKey: fixtures.readKey('ed448_public.pem', 'ascii') }]; | ||
| 783 | + | ||
| 784 | + for (const { publicKey, privateKey } of keys) { | ||
| 785 | + assert.throws(() => { | ||
| 786 | + crypto.createSign('SHA256').update('Test123').sign(privateKey); | ||
| 787 | + }, { code: 'ERR_CRYPTO_UNSUPPORTED_OPERATION', message: 'Unsupported crypto operation' }); | ||
| 788 | + assert.throws(() => { | ||
| 789 | + crypto.createVerify('SHA256').update('Test123').verify(privateKey, 'sig'); | ||
| 790 | + }, { code: 'ERR_CRYPTO_UNSUPPORTED_OPERATION', message: 'Unsupported crypto operation' }); | ||
| 791 | + assert.throws(() => { | ||
| 792 | + crypto.createVerify('SHA256').update('Test123').verify(publicKey, 'sig'); | ||
| 793 | + }, { code: 'ERR_CRYPTO_UNSUPPORTED_OPERATION', message: 'Unsupported crypto operation' }); | ||
| 794 | + } | ||
| 795 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments