Index: test/signatures.js |
=================================================================== |
--- a/test/signatures.js |
+++ b/test/signatures.js |
@@ -46,20 +46,20 @@ |
*/ |
let data = "test"; |
let publicKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALZc50pEXnz9TSRozwM04rryuaXl/wgUFqV9FHq8HDlkdKvRU0hXhb/AKrSpCJ0NCxHtal1l/kHYlHG9e7Ev6+MCAwEAAQ=="; |
let signature = "LzKJE1BOsZDfwD/hncHq+MN5ZygIemb1Pyzx40rm3CoTL4CVPAicS1mOiTv6s9Li9Vw1ds9HwFWVMFVEwHwfIw=="; |
test.ok(verifySignature(publicKey, signature, data), "Correct signature"); |
test.ok(!verifySignature(publicKey, signature, data + "1"), "Wrong data"); |
- test.ok(!verifySignature(publicKey, signature, data.substr(0, 3)), "Wrong data"); |
- test.ok(!verifySignature(publicKey, signature.substr(0, 5) + "0" + signature.substr(6), data), "Wrong signature"); |
- test.ok(!verifySignature(publicKey.substr(0, 5) + "R" + publicKey.substr(6), signature, data), "Wrong public key"); |
- test.ok(!verifySignature(publicKey.substr(0, 70) + "8" + publicKey.substr(71), signature, data), "Wrong public key"); |
+ test.ok(!verifySignature(publicKey, signature, data.substring(0, 3)), "Wrong data"); |
+ test.ok(!verifySignature(publicKey, signature.substring(0, 5) + "0" + signature.substring(6), data), "Wrong signature"); |
+ test.ok(!verifySignature(publicKey.substring(0, 5) + "R" + publicKey.substring(6), signature, data), "Wrong public key"); |
+ test.ok(!verifySignature(publicKey.substring(0, 70) + "8" + publicKey.substring(71), signature, data), "Wrong public key"); |
test.done(); |
}; |
exports.test2048bitSigningKey = function(test) |
{ |
/* |
-----BEGIN RSA PRIVATE KEY----- |
@@ -92,20 +92,20 @@ |
*/ |
let data = "test"; |
let publicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAy45IKQw0R5YBiIFyfKftx3F/6WsvtdNMnCKodkDemXuJOcFuOf/KeIjED/wW2DFG8qq72FAByUUFoTLcmawQZPd2htmHIk8ZkBRsaQ8HzNoK+vg4wnI6yN/2lhSP27D4XpedG3mtbG8aYtMuqyQaxWHInSqiM4tqW/8coAPXrRTKYmsFfAwPB1LCg5QI3vCy7Vdbbp907xOXON1+2seF9j8m9rh0sufXgGNWcvTNUvlf/TidSVjqxe6O3hG9jTOswC8/hez7rbiLroVNnCtIDrdX6OSM/je/XSMMnS5xpZBuqZGZtZm1Mr42omgst+KE+5dE6kyx76ra8LwsCEShawIDAQAB"; |
let signature = "UYTQmygOICKi4ozlMbLSYFZ1olovZZFYT0nZygPrGoA+6+ta+wzKnPnghK4j35QSucrf3yN8DSXa/kXBX0LcTmEaSwoNRuM7QPjT6v9hNsVjwNexOUk6pR3DotYuD1yV36sITNjx59McG8/q6qLyj2A8KVlUbtnz/IiLzzw+wgy6WRjU1meYP8oiQGVIkB21ICqqaJ5kCvM0YrAqzQKAya513O51ADA6aC/EMz6B62XGgZ+AywUMcH2Wvx7cyCvPVLfAbXcgex1JtpPS6vGcdpigaVQkoyl4cIQmX1ppasgJj2MiYl2htXvFXjYoWniEmspteNu3UybB0nMHnYjKdQ=="; |
test.ok(verifySignature(publicKey, signature, data), "Correct signature"); |
test.ok(!verifySignature(publicKey, signature, data + "1"), "Wrong data"); |
- test.ok(!verifySignature(publicKey, signature, data.substr(0, 3)), "Wrong data"); |
- test.ok(!verifySignature(publicKey, signature.substr(0, 5) + "0" + signature.substr(6), data), "Wrong signature"); |
- test.ok(!verifySignature(publicKey.substr(0, 5) + "R" + publicKey.substr(6), signature, data), "Wrong public key"); |
- test.ok(!verifySignature(publicKey.substr(0, 70) + "8" + publicKey.substr(71), signature, data), "Wrong public key"); |
+ test.ok(!verifySignature(publicKey, signature, data.substring(0, 3)), "Wrong data"); |
+ test.ok(!verifySignature(publicKey, signature.substring(0, 5) + "0" + signature.substring(6), data), "Wrong signature"); |
+ test.ok(!verifySignature(publicKey.substring(0, 5) + "R" + publicKey.substring(6), signature, data), "Wrong public key"); |
+ test.ok(!verifySignature(publicKey.substring(0, 70) + "8" + publicKey.substring(71), signature, data), "Wrong public key"); |
test.done(); |
}; |
exports.testVeryLongData = function(test) |
{ |
/* |
-----BEGIN RSA PRIVATE KEY----- |
@@ -120,20 +120,20 @@ |
*/ |
let data = "foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar"; |
let publicKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALZc50pEXnz9TSRozwM04rryuaXl/wgUFqV9FHq8HDlkdKvRU0hXhb/AKrSpCJ0NCxHtal1l/kHYlHG9e7Ev6+MCAwEAAQ=="; |
let signature = "L1LtPxp9VwL/ij8tuIxJqtx6mD3qoFhcEmPl8A1RlNeOP34A25nzyzRWuP2wEbHcKKXnAQESdIXaTaEuymXviQ=="; |
test.ok(verifySignature(publicKey, signature, data), "Correct signature"); |
test.ok(!verifySignature(publicKey, signature, data + "1"), "Wrong data"); |
- test.ok(!verifySignature(publicKey, signature, data.substr(0, 3)), "Wrong data"); |
- test.ok(!verifySignature(publicKey, signature.substr(0, 5) + "0" + signature.substr(6), data), "Wrong signature"); |
- test.ok(!verifySignature(publicKey.substr(0, 5) + "R" + publicKey.substr(6), signature, data), "Wrong public key"); |
- test.ok(!verifySignature(publicKey.substr(0, 70) + "8" + publicKey.substr(71), signature, data), "Wrong public key"); |
+ test.ok(!verifySignature(publicKey, signature, data.substring(0, 3)), "Wrong data"); |
+ test.ok(!verifySignature(publicKey, signature.substring(0, 5) + "0" + signature.substring(6), data), "Wrong signature"); |
+ test.ok(!verifySignature(publicKey.substring(0, 5) + "R" + publicKey.substring(6), signature, data), "Wrong public key"); |
+ test.ok(!verifySignature(publicKey.substring(0, 70) + "8" + publicKey.substring(71), signature, data), "Wrong public key"); |
test.done(); |
}; |
exports.testRealLifeSignature = function(test) |
{ |
let data = [ |
"/info/Liquidit%C3%A4t.html?ses=Y3JlPTEzNTUyNDE2OTImdGNpZD13d3cuYWZmaWxpbmV0LXZlcnplaWNobmlzLmRlNTBjNjAwNzIyNTlkNjQuNDA2MjE2MTImZmtpPTcyOTU2NiZ0YXNrPXNlYXJjaCZkb21haW49YWZmaWxpbmV0LXZlcnplaWNobmlzLmRlJnM9ZGZmM2U5MTEzZGNhMWYyMWEwNDcmbGFuZ3VhZ2U9ZGUmYV9pZD0yJmtleXdvcmQ9TGlxdWlkaXQlQzMlQTR0JnBvcz0yJmt3cz03Jmt3c2k9OA==&token=AG06ipCV1LptGtY_9gFnr0vBTPy4O0YTvwoTCObJ3N3ckrQCFYIA3wod2TwAjxgAIABQv5WiAlCH8qgOUJGr9g9QmuuEG1CDnK0pUPbRrk5QhqDgkQNxP4Qqhz9xZe4", |