@@ -22,6 +22,7 @@ const dsaKeyPem = fixtures.readSync('test_dsa_privkey.pem', 'ascii');
22
22
const dsaKeyPemEncrypted = fixtures . readSync ( 'test_dsa_privkey_encrypted.pem' ,
23
23
'ascii' ) ;
24
24
const rsaPkcs8KeyPem = fixtures . readSync ( 'test_rsa_pkcs8_privkey.pem' ) ;
25
+ const dsaPkcs8KeyPem = fixtures . readSync ( 'test_dsa_pkcs8_privkey.pem' ) ;
25
26
26
27
const decryptError =
27
28
/ ^ E r r o r : e r r o r : 0 6 0 6 5 0 6 4 : d i g i t a l e n v e l o p e r o u t i n e s : E V P _ D e c r y p t F i n a l _ e x : b a d d e c r y p t $ / ;
@@ -258,6 +259,35 @@ assert.throws(() => {
258
259
}
259
260
260
261
262
+ //
263
+ // Test DSA signing and verification with PKCS#8 private key
264
+ //
265
+ {
266
+ const input = 'I AM THE WALRUS' ;
267
+
268
+ // DSA signatures vary across runs so there is no static string to verify
269
+ // against
270
+ const sign = crypto . createSign ( 'SHA1' ) ;
271
+ sign . update ( input ) ;
272
+ const signature = sign . sign ( dsaPkcs8KeyPem , 'hex' ) ;
273
+
274
+ const verify = crypto . createVerify ( 'SHA1' ) ;
275
+ verify . update ( input ) ;
276
+
277
+ assert . strictEqual ( verify . verify ( dsaPubPem , signature , 'hex' ) , true ) ;
278
+
279
+ // Test the legacy 'DSS1' name.
280
+ const sign2 = crypto . createSign ( 'DSS1' ) ;
281
+ sign2 . update ( input ) ;
282
+ const signature2 = sign2 . sign ( dsaPkcs8KeyPem , 'hex' ) ;
283
+
284
+ const verify2 = crypto . createVerify ( 'DSS1' ) ;
285
+ verify2 . update ( input ) ;
286
+
287
+ assert . strictEqual ( verify2 . verify ( dsaPubPem , signature2 , 'hex' ) , true ) ;
288
+ }
289
+
290
+
261
291
//
262
292
// Test DSA signing and verification with encrypted key
263
293
//
0 commit comments