Index: qunit/tests/signatures.js |
=================================================================== |
--- a/qunit/tests/signatures.js |
+++ b/qunit/tests/signatures.js |
@@ -84,9 +84,47 @@ |
ok(verifySignature(publicKey, signature, data), "Correct signature"); |
ok(!verifySignature(publicKey, signature, data + "1"), "Wrong data"); |
ok(!verifySignature(publicKey, signature, data.substr(0, 3)), "Wrong data"); |
ok(!verifySignature(publicKey, signature.substr(0, 5) + "0" + signature.substr(6), data), "Wrong signature"); |
ok(!verifySignature(publicKey.substr(0, 5) + "R" + publicKey.substr(6), signature, data), "Wrong public key"); |
ok(!verifySignature(publicKey.substr(0, 70) + "8" + publicKey.substr(71), signature, data), "Wrong public key"); |
}); |
+ |
+ test("Very long data", 6, function() |
+ { |
+ /* |
+ -----BEGIN RSA PRIVATE KEY----- |
+ MIIBOQIBAAJBALZc50pEXnz9TSRozwM04rryuaXl/wgUFqV9FHq8HDlkdKvRU0hX |
+ hb/AKrSpCJ0NCxHtal1l/kHYlHG9e7Ev6+MCAwEAAQJBALRxYs5irhgAz2b6afOj |
+ TcFr0PRtipckwW/IPw5euZKyvswEJt/tWDv4OdmDnRe8FSy6FG2Got3zxvaxYdc3 |
+ AXkCIQDfFGcytIVq3sbdF3lmhzcXf29R4Hrxg/eoByAKabxknwIhANFGSNMOGPt6 |
+ JRajfB9XmsltQJzbkr2sfHgjMN2FLM49AiAH6tt2yz1o+5snQawHXYkxBk7XIxZ5 |
+ 9+sURZx3giUzlQIfXF+pxX9zh41i0ZtYLn181WxkGNjS7OY2CtF9wEoIfQIgcHuf |
+ shh1qrvuKiXnD9b72PF676laKdzxzX5rX6cZZLA= |
+ -----END RSA PRIVATE KEY----- |
+ */ |
+ |
+ var data = "foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar"; |
+ var publicKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALZc50pEXnz9TSRozwM04rryuaXl/wgUFqV9FHq8HDlkdKvRU0hXhb/AKrSpCJ0NCxHtal1l/kHYlHG9e7Ev6+MCAwEAAQ=="; |
+ var signature = "L1LtPxp9VwL/ij8tuIxJqtx6mD3qoFhcEmPl8A1RlNeOP34A25nzyzRWuP2wEbHcKKXnAQESdIXaTaEuymXviQ=="; |
+ ok(verifySignature(publicKey, signature, data), "Correct signature"); |
+ |
+ ok(!verifySignature(publicKey, signature, data + "1"), "Wrong data"); |
+ ok(!verifySignature(publicKey, signature, data.substr(0, 3)), "Wrong data"); |
+ ok(!verifySignature(publicKey, signature.substr(0, 5) + "0" + signature.substr(6), data), "Wrong signature"); |
+ ok(!verifySignature(publicKey.substr(0, 5) + "R" + publicKey.substr(6), signature, data), "Wrong public key"); |
+ ok(!verifySignature(publicKey.substr(0, 70) + "8" + publicKey.substr(71), signature, data), "Wrong public key"); |
+ }); |
+ |
+ test("Real-life signature", 1, function() |
+ { |
+ var data = [ |
+ "/info/Liquidit%C3%A4t.html?ses=Y3JlPTEzNTUyNDE2OTImdGNpZD13d3cuYWZmaWxpbmV0LXZlcnplaWNobmlzLmRlNTBjNjAwNzIyNTlkNjQuNDA2MjE2MTImZmtpPTcyOTU2NiZ0YXNrPXNlYXJjaCZkb21haW49YWZmaWxpbmV0LXZlcnplaWNobmlzLmRlJnM9ZGZmM2U5MTEzZGNhMWYyMWEwNDcmbGFuZ3VhZ2U9ZGUmYV9pZD0yJmtleXdvcmQ9TGlxdWlkaXQlQzMlQTR0JnBvcz0yJmt3cz03Jmt3c2k9OA==&token=AG06ipCV1LptGtY_9gFnr0vBTPy4O0YTvwoTCObJ3N3ckrQCFYIA3wod2TwAjxgAIABQv5WiAlCH8qgOUJGr9g9QmuuEG1CDnK0pUPbRrk5QhqDgkQNxP4Qqhz9xZe4", |
+ "www.affilinet-verzeichnis.de", |
+ "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.21 (KHTML, like Gecko) Chrome/25.0.1349.2 Safari/537.21" |
+ ]; |
+ var publicKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANnylWw2vLY4hUn9w06zQKbhKBfvjFUCsdFlb6TdQhxb9RXWXuI4t31c+o8fYOv/s8q1LGPga3DE1L/tHU4LENMCAwEAAQ=="; |
+ var signature = "nLH8Vbc1rzmy0Q+Xg+bvm43IEO42h8rq5D9C0WCn/Y3ykgAoV4npzm7eMlqBSwZBLA/0DuuVsfTJT9MOVaurcA=="; |
+ ok(verifySignature(publicKey, signature, data.join("\0")), "Correct signature"); |
+ }); |
})(); |