Commit c27f7b0 1 parent a3b1fc3 commit c27f7b0 Copy full SHA for c27f7b0
File tree 2 files changed +30
-0
lines changed
2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -418,6 +418,11 @@ void Sign::SignFinal(const FunctionCallbackInfo<Value>& args) {
418
418
if (!key)
419
419
return ;
420
420
421
+ if (IsOneShot (key)) {
422
+ THROW_ERR_CRYPTO_UNSUPPORTED_OPERATION (env);
423
+ return ;
424
+ }
425
+
421
426
int padding = GetDefaultSignPadding (key);
422
427
if (!args[offset]->IsUndefined ()) {
423
428
CHECK (args[offset]->IsInt32 ());
@@ -543,6 +548,11 @@ void Verify::VerifyFinal(const FunctionCallbackInfo<Value>& args) {
543
548
if (!pkey)
544
549
return ;
545
550
551
+ if (IsOneShot (pkey)) {
552
+ THROW_ERR_CRYPTO_UNSUPPORTED_OPERATION (env);
553
+ return ;
554
+ }
555
+
546
556
ArrayBufferOrViewContents<char > hbuf (args[offset]);
547
557
if (UNLIKELY (!hbuf.CheckSizeInt32 ()))
548
558
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 : / T h e " k e y \. k e y " p r o p e r t y m u s t b e o f t y p e o b j e c t / } ) ;
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
+ }
You can’t perform that action at this time.
0 commit comments