@@ -891,7 +891,7 @@ if (hasOpenSSL(3, 2)) {
891891 } , { 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 / } ) ;
892892 assert . throws ( ( ) => {
893893 crypto . createSign ( 'sha256' ) . sign ( { key, format : 'jwk' } ) ;
894- } , { 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 / } ) ;
894+ } , { code : 'ERR_INVALID_ARG_TYPE' , message : / T h e " p r i v a t 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 / } ) ;
895895 }
896896}
897897
@@ -932,3 +932,66 @@ if (hasOpenSSL(3, 2)) {
932932 } , { code : 'ERR_OSSL_EVP_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE' , message : / o p e r a t i o n n o t s u p p o r t e d f o r t h i s k e y t y p e / } ) ;
933933 }
934934}
935+
936+ // Test that sign/verify error messages use correct property paths
937+ {
938+ // Sign with invalid format
939+ assert . throws ( ( ) => {
940+ crypto . createSign ( 'SHA256' ) . update ( 'test' ) . sign ( {
941+ key : Buffer . alloc ( 0 ) , format : 'banana' , type : 'pkcs8' ,
942+ } ) ;
943+ } , {
944+ code : 'ERR_INVALID_ARG_VALUE' ,
945+ message : / p r i v a t e K e y \. f o r m a t / ,
946+ } ) ;
947+
948+ // Sign with invalid type
949+ assert . throws ( ( ) => {
950+ crypto . createSign ( 'SHA256' ) . update ( 'test' ) . sign ( {
951+ key : Buffer . alloc ( 0 ) , format : 'der' , type : 'banana' ,
952+ } ) ;
953+ } , {
954+ code : 'ERR_INVALID_ARG_VALUE' ,
955+ message : / p r i v a t e K e y \. t y p e / ,
956+ } ) ;
957+
958+ // Verify with invalid format
959+ assert . throws ( ( ) => {
960+ crypto . createVerify ( 'SHA256' ) . update ( 'test' ) . verify ( {
961+ key : Buffer . alloc ( 0 ) , format : 'banana' , type : 'spki' ,
962+ } , Buffer . alloc ( 0 ) ) ;
963+ } , {
964+ code : 'ERR_INVALID_ARG_VALUE' ,
965+ message : / k e y \. f o r m a t / ,
966+ } ) ;
967+
968+ // Verify with invalid type
969+ assert . throws ( ( ) => {
970+ crypto . createVerify ( 'SHA256' ) . update ( 'test' ) . verify ( {
971+ key : Buffer . alloc ( 0 ) , format : 'der' , type : 'banana' ,
972+ } , Buffer . alloc ( 0 ) ) ;
973+ } , {
974+ code : 'ERR_INVALID_ARG_VALUE' ,
975+ message : / k e y \. t y p e / ,
976+ } ) ;
977+
978+ // crypto.sign with invalid format
979+ assert . throws ( ( ) => {
980+ crypto . sign ( 'SHA256' , Buffer . from ( 'test' ) , {
981+ key : Buffer . alloc ( 0 ) , format : 'banana' , type : 'pkcs8' ,
982+ } ) ;
983+ } , {
984+ code : 'ERR_INVALID_ARG_VALUE' ,
985+ message : / k e y \. f o r m a t / ,
986+ } ) ;
987+
988+ // crypto.verify with invalid format
989+ assert . throws ( ( ) => {
990+ crypto . verify ( 'SHA256' , Buffer . from ( 'test' ) , {
991+ key : Buffer . alloc ( 0 ) , format : 'banana' , type : 'spki' ,
992+ } , Buffer . alloc ( 0 ) ) ;
993+ } , {
994+ code : 'ERR_INVALID_ARG_VALUE' ,
995+ message : / k e y \. f o r m a t / ,
996+ } ) ;
997+ }
0 commit comments