Browse Source

test: add DSA sign/verify crypto tests

v0.7.4-release
Ben Noordhuis 13 years ago
parent
commit
7defbd27ef
  1. 14
      test/fixtures/test_dsa_params.pem
  2. 20
      test/fixtures/test_dsa_privkey.pem
  3. 20
      test/fixtures/test_dsa_pubkey.pem
  4. 33
      test/simple/test-crypto.js

14
test/fixtures/test_dsa_params.pem

@ -0,0 +1,14 @@
-----BEGIN DSA PARAMETERS-----
MIICIAKCAQEAiJCR40HCtA6pk864XhKceke8N4chlrpwcphAXpHwSQGHlv1JJFyj
aPqugWtzwZH55g7qpIiT3fmg6V6PfzNfx4sQGlSjckZaN02WRUAacn0va6UbwyYV
7LZzuHlHzayHLl/btGeTF+zL+9eMLKfll+r+5bJXDMWh3xUD1Nldf+fsIsbVZI9Q
Nzf3L1/07XVTLedQYaE77OqVuu+cfoBtb+K5MsQdHMMN20BGjKIvGkJICuC448Gk
Dx1wpxz2vSJEi6FqXruM6c9yrPvhJKSfbVFYK2n82MMXMNNu9Dwqwsv6Ig6dIVyw
dKDrSw1Nz9j9TWA5BolNta3yMPHrEjCuIQIVAKq0ZZ0/36sZE1cqt6j0hZTisWUV
AoIBAFbI9MKn9DBJ7lo7+LRblgNKg9lk4D/6NBBRgOeCN4WnOxHQrqpSTUBG+VcA
BDKEfoHfEPI9KZKpEgpzGTpr7mGxDPLHfGL+vvf1EYbmcTDrUWlf9B/3+L3uwIdd
v3NYLepyEZ8L8g6eRGSQ4Svg1oSR/GAUTeGJczPg6qW0b/LTpf4eeDNWYGF6aogJ
UphnPcZ0Xqw+yvq/i1uzAVirUxp9Crb7km0dfA0G/HBiSdcEt6l8LdQd6qmcL0nx
cm9x6L+tSol5hXNynV0wcxdCQz4Xj5na+NoRGb9jPYxgLkoq07hwAkqkQDyF61tx
fWgGc7zmh/x6JMGe/Xhg1TvgxLs=
-----END DSA PARAMETERS-----

20
test/fixtures/test_dsa_privkey.pem

@ -0,0 +1,20 @@
-----BEGIN DSA PRIVATE KEY-----
MIIDPwIBAAKCA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ixO/eqzgF5rcfBdeDJ/iELXhAJonxddeNAtGxcx+u
0UmVNd6UQge0ym67k3r54XUHLSzs4YKTLqBFgI0lp4uflpJToPy8azGezBc/iqqY
dT8Ul+5IP0vMgozRbWr4mOx6yRO8FKot2f1T1eByhnh819ZNWfURP6CU7Edsk9q7
Sb0hjvZQ5OhY+bSL9Xwv
-----END PUBLIC KEY-----

33
test/simple/test-crypto.js

@ -394,6 +394,10 @@ assert.equal(rsaSignature, '5c50e3145c4e2497aadb0eabc83b342d0b0021ece0d4c4a064b7
rsaVerify.update(rsaPubPem);
assert.strictEqual(rsaVerify.verify(rsaPubPem, rsaSignature, 'hex'), true);
//
// Test RSA signing and verification
//
(function() {
var privateKey = fs.readFileSync(
common.fixturesDir + '/test_rsa_privkey_2.pem');
@ -417,8 +421,35 @@ assert.strictEqual(rsaVerify.verify(rsaPubPem, rsaSignature, 'hex'), true);
assert.strictEqual(verify.verify(publicKey, signature, 'hex'), true);
})();
// Test PBKDF2 with RFC 6070 test vectors (except #4)
//
// Test DSA signing and verification
//
(function() {
var privateKey = fs.readFileSync(
common.fixturesDir + '/test_dsa_privkey.pem');
var publicKey = fs.readFileSync(
common.fixturesDir + '/test_dsa_pubkey.pem');
var input = 'I AM THE WALRUS';
// DSA signatures vary across runs so there is no static string to verify
// against
var sign = crypto.createSign('DSS1');
sign.update(input);
var signature = sign.sign(privateKey, 'hex');
var verify = crypto.createVerify('DSS1');
verify.update(input);
assert.strictEqual(verify.verify(publicKey, signature, 'hex'), true);
})();
//
// Test PBKDF2 with RFC 6070 test vectors (except #4)
//
crypto.pbkdf2('password', 'salt', 1, 20, function(err, result) {
assert.equal(result, '\x0c\x60\xc8\x0f\x96\x1f\x0e\x71\xf3\xa9\xb5\x24\xaf\x60\x12\x06\x2f\xe0\x37\xa6', 'pbkdf1 test vector 1');
});

Loading…
Cancel
Save