| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b097d85 commit d244204
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -420,6 +420,11 @@ void Sign::SignFinal(const FunctionCallbackInfo<Value>& args) { | |||
| 420 | 420 | if (!key) | |
| 421 | 421 | return; | |
| 422 | 422 | ||
| 423 | + if (IsOneShot(key)) { | ||
| 424 | + THROW_ERR_CRYPTO_UNSUPPORTED_OPERATION(env); | ||
| 425 | + return; | ||
| 426 | + } | ||
| 427 | + | ||
| 423 | 428 | int padding = GetDefaultSignPadding(key); | |
| 424 | 429 | if (!args[offset]->IsUndefined()) { | |
| 425 | 430 | CHECK(args[offset]->IsInt32()); | |
@@ -547,6 +552,11 @@ void Verify::VerifyFinal(const FunctionCallbackInfo<Value>& args) { | |||
| 547 | 552 | if (!pkey) | |
| 548 | 553 | return; | |
| 549 | 554 | ||
| 555 | + if (IsOneShot(pkey)) { | ||
| 556 | + THROW_ERR_CRYPTO_UNSUPPORTED_OPERATION(env); | ||
| 557 | + return; | ||
| 558 | + } | ||
| 559 | + | ||
| 550 | 560 | ArrayBufferOrViewContents<char> hbuf(args[offset]); | |
| 551 | 561 | if (UNLIKELY(!hbuf.CheckSizeInt32())) | |
| 552 | 562 | return THROW_ERR_OUT_OF_RANGE(env, "buffer is too big"); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -774,3 +774,23 @@ assert.throws( | |||
| 774 | 774 | }, { code: 'ERR_INVALID_ARG_TYPE', message: /The "key\.key" property must be of type object/ }); | |
| 775 | 775 | } | |
| 776 | 776 | } | |
| 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 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments