From 9caf740905107dcc87ad6022bd61d92a27e59d37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Mon, 2 Sep 2019 22:32:01 +0200 Subject: [PATCH] test: add dsaEncoding compatibility test This adds a test case for the dsaEncoding option using data generated in Chrome 76. --- test/parallel/test-crypto-sign-verify.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/parallel/test-crypto-sign-verify.js b/test/parallel/test-crypto-sign-verify.js index 8600e9a8c2f93d..a16d25f540e1a8 100644 --- a/test/parallel/test-crypto-sign-verify.js +++ b/test/parallel/test-crypto-sign-verify.js @@ -538,6 +538,22 @@ common.expectsError( } } + // Test verifying externally signed messages. + const extSig = Buffer.from('494c18ab5c8a62a72aea5041966902bcfa229821af2bf65' + + '0b5b4870d1fe6aebeaed9460c62210693b5b0a300033823' + + '33d9529c8abd8c5948940af944828be16c', 'hex'); + for (const ok of [true, false]) { + assert.strictEqual( + crypto.verify('sha256', data, { + key: fixtures.readKey('ec-key.pem'), + dsaEncoding: 'ieee-p1363' + }, extSig), + ok + ); + + extSig[Math.floor(Math.random() * extSig.length)] ^= 1; + } + // Non-(EC)DSA keys should ignore the option. const sig = crypto.sign('sha1', data, { key: keyPem,