Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: LayoutTests/crypto/rsassa-pkcs1-v1_5-sign-verify.html

Issue 336173002: [webcrypto] Require importKey() for JWK to provide data as a Javascript object rather than a JSON a… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update additional tests Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../resources/js-test.js"></script> 4 <script src="../resources/js-test.js"></script>
5 <script src="resources/common.js"></script> 5 <script src="resources/common.js"></script>
6 </head> 6 </head>
7 <body> 7 <body>
8 <p id="description"></p> 8 <p id="description"></p>
9 <div id="console"></div> 9 <div id="console"></div>
10 10
(...skipping 20 matching lines...) Expand all
31 p: Base64URL.stringify(hexStringToUint8Array("E26893B808CA31E1F9B89E4A077F7B 414C216E46048126DC0369A27E64A4BC4DB4D7C81BE79AA40472B5795AF27F5FE6E372CD95CE8EFD A93A81FCDD64866F4B93421A33E5D2AD3DA65529BBCA85392B2907003AEEA187EFA9459592E7FDDE 328254BBC1F2EBBB8FF962CF2A2CBB3E0EA54BBE2C29A2C3A7CB25AAC0CE405E9D")), 31 p: Base64URL.stringify(hexStringToUint8Array("E26893B808CA31E1F9B89E4A077F7B 414C216E46048126DC0369A27E64A4BC4DB4D7C81BE79AA40472B5795AF27F5FE6E372CD95CE8EFD A93A81FCDD64866F4B93421A33E5D2AD3DA65529BBCA85392B2907003AEEA187EFA9459592E7FDDE 328254BBC1F2EBBB8FF962CF2A2CBB3E0EA54BBE2C29A2C3A7CB25AAC0CE405E9D")),
32 q: Base64URL.stringify(hexStringToUint8Array("C4762BCE48AFB669F3FEC19C867586 734ABEA433A42A2729B51A6FDA93052085F19C55F968C7845C866356E8D7B70532D5494520DD8664 94AFCB9289EFD9AEFD7C8D9C51CCCDE747F80DDE7B7BBC875514AD917EBD4BB5FDEE14FF1EBB34DD 5D79DCD448ACA737BA459773A4B9284C056195F9CC3338F75C5407D5B9997150C7")), 32 q: Base64URL.stringify(hexStringToUint8Array("C4762BCE48AFB669F3FEC19C867586 734ABEA433A42A2729B51A6FDA93052085F19C55F968C7845C866356E8D7B70532D5494520DD8664 94AFCB9289EFD9AEFD7C8D9C51CCCDE747F80DDE7B7BBC875514AD917EBD4BB5FDEE14FF1EBB34DD 5D79DCD448ACA737BA459773A4B9284C056195F9CC3338F75C5407D5B9997150C7")),
33 dp: Base64URL.stringify(hexStringToUint8Array("7C1CC3CD80D40660501A8A7B1E7D1 DBDFFD3DBB57A46AA5CB56A34EF809065C15B3F66AD155B4A4A3DEF8964F7C62776547CDC8220C77 5FA4CDE71159443B5C302289C6092BDD8C610E66288554E8EB640395C40F20B8E8F2C85BEA6D791E D3A5703C8215BDF29E494DB3BA16CFFFFD6DB7A17F7F1A30E0A6F6C689C64F41869")), 33 dp: Base64URL.stringify(hexStringToUint8Array("7C1CC3CD80D40660501A8A7B1E7D1 DBDFFD3DBB57A46AA5CB56A34EF809065C15B3F66AD155B4A4A3DEF8964F7C62776547CDC8220C77 5FA4CDE71159443B5C302289C6092BDD8C610E66288554E8EB640395C40F20B8E8F2C85BEA6D791E D3A5703C8215BDF29E494DB3BA16CFFFFD6DB7A17F7F1A30E0A6F6C689C64F41869")),
34 dq: Base64URL.stringify(hexStringToUint8Array("8E61360E220F761C0380B5C042921 A06A43CD5B3B75DF553FCB4542C0C30C3094FB90575E3C1F4E33961F5327A6361991D8A245755347 8E0692717E46FB74B62DA49A6E8818D17F8C88504A06964908FD09499C5485AFE62319175F347A96 064C6548C64BEFBD11F662004E7746907EF3E71FABF4AC016450B81421B6860FF31")), 34 dq: Base64URL.stringify(hexStringToUint8Array("8E61360E220F761C0380B5C042921 A06A43CD5B3B75DF553FCB4542C0C30C3094FB90575E3C1F4E33961F5327A6361991D8A245755347 8E0692717E46FB74B62DA49A6E8818D17F8C88504A06964908FD09499C5485AFE62319175F347A96 064C6548C64BEFBD11F662004E7746907EF3E71FABF4AC016450B81421B6860FF31")),
35 qi: Base64URL.stringify(hexStringToUint8Array("6025FFA4BC1B3010354E1547D1673 09A7CADA8D72B3021304E6EC1C80D9E53A9D66D0AD42EF7FB9BDFE4CDF2D4723B27A405650501B92 4C5CCCB44AAE29B706F2C2C6B9F86F0A00E38E4762F7BF8842F84CACF5FB6014CFF78B4A38D1E790 1F86F785A3DB9EDAC878C83C23394EB9560A7FDFB642E283A1679175DECDB1DC539")) 35 qi: Base64URL.stringify(hexStringToUint8Array("6025FFA4BC1B3010354E1547D1673 09A7CADA8D72B3021304E6EC1C80D9E53A9D66D0AD42EF7FB9BDFE4CDF2D4723B27A405650501B92 4C5CCCB44AAE29B706F2C2C6B9F86F0A00E38E4762F7BF8842F84CACF5FB6014CFF78B4A38D1E790 1F86F785A3DB9EDAC878C83C23394EB9560A7FDFB642E283A1679175DECDB1DC539"))
36 }; 36 };
37 37
38 var data = asciiToUint8Array("Hello, world!"); 38 var data = asciiToUint8Array("Hello, world!");
39 39
40 debug("Importing a public key..."); 40 debug("Importing a public key...");
41 crypto.subtle.importKey("jwk", asciiToUint8Array(JSON.stringify(publicKeyJSON)), { name: "RSASSA-PKCS1-v1_5", hash: {name: "SHA-256"} }, extractable, ["verify"] ).then(function(result) { 41 crypto.subtle.importKey("jwk", publicKeyJSON, { name: "RSASSA-PKCS1-v1_5", hash: {name: "SHA-256"} }, extractable, ["verify"]).then(function(result) {
42 publicKey = result; 42 publicKey = result;
43 debug("\nImporting a private key..."); 43 debug("\nImporting a private key...");
44 return crypto.subtle.importKey("jwk", asciiToUint8Array(JSON.stringify(priva teKeyJSON)), { name: "RSASSA-PKCS1-v1_5", hash: {name: "SHA-256"} }, extractable , ["sign"]); 44 return crypto.subtle.importKey("jwk", privateKeyJSON, { name: "RSASSA-PKCS1- v1_5", hash: {name: "SHA-256"} }, extractable, ["sign"]);
45 }).then(function(result) { 45 }).then(function(result) {
46 privateKey = result; 46 privateKey = result;
47 debug("\nSigning some text..."); 47 debug("\nSigning some text...");
48 return crypto.subtle.sign({ name: "RSASSA-PKCS1-v1_5"}, privateKey, data); 48 return crypto.subtle.sign({ name: "RSASSA-PKCS1-v1_5"}, privateKey, data);
49 }).then(function(result) { 49 }).then(function(result) {
50 signature = result; 50 signature = result;
51 shouldBe("bytesToHexString(new Uint8Array(signature))", "'0fd9a8aef4cc1876c0 b762545336c6d1fb315ae16ae4b5e4bf34d384d8585ea7a01e76ea09ee7f7ee8d1c122e7dd15b7c9 4a573b2aa07203e8d13bc6fd16156cd8e5f0c15a15dccb62d152127fca09882fb53bc3e60ab586d1 5b95cf411e3aab4a1c231a7e91aab09ee3d4b13d11e97505ddff77683470da510ee76e8bd530c56a 85f901626a5a710f716f113dfe9cf6c473ee16fa248aea3480a1033abe30f4c1243289a661e64d78 18b55698280688097135968c6d4b029496d85cab2a67e4696737781f70e4392c7df71bbd6c924659 47f029a1de48160aced11b5721b1cd25039fe2c16c2b38de73df3b9a83e3ea755fd0cfe51ca06b61 fadf6d84677f95'"); 51 shouldBe("bytesToHexString(new Uint8Array(signature))", "'0fd9a8aef4cc1876c0 b762545336c6d1fb315ae16ae4b5e4bf34d384d8585ea7a01e76ea09ee7f7ee8d1c122e7dd15b7c9 4a573b2aa07203e8d13bc6fd16156cd8e5f0c15a15dccb62d152127fca09882fb53bc3e60ab586d1 5b95cf411e3aab4a1c231a7e91aab09ee3d4b13d11e97505ddff77683470da510ee76e8bd530c56a 85f901626a5a710f716f113dfe9cf6c473ee16fa248aea3480a1033abe30f4c1243289a661e64d78 18b55698280688097135968c6d4b029496d85cab2a67e4696737781f70e4392c7df71bbd6c924659 47f029a1de48160aced11b5721b1cd25039fe2c16c2b38de73df3b9a83e3ea755fd0cfe51ca06b61 fadf6d84677f95'");
52 52
53 debug("\nVerifying the signature..."); 53 debug("\nVerifying the signature...");
54 return crypto.subtle.verify({ name: "RSASSA-PKCS1-v1_5" }, publicKey, signat ure, data); 54 return crypto.subtle.verify({ name: "RSASSA-PKCS1-v1_5" }, publicKey, signat ure, data);
55 }).then(function(result) { 55 }).then(function(result) {
56 verificationResult = result; 56 verificationResult = result;
57 shouldBe("verificationResult", "true"); 57 shouldBe("verificationResult", "true");
58 debug("\nVerifying a bad signature..."); 58 debug("\nVerifying a bad signature...");
59 return crypto.subtle.verify({ name: "RSASSA-PKCS1-v1_5" }, publicKey, new Ui nt8Array(256), data); 59 return crypto.subtle.verify({ name: "RSASSA-PKCS1-v1_5" }, publicKey, new Ui nt8Array(256), data);
60 }).then(function(result) { 60 }).then(function(result) {
61 verificationResult = result; 61 verificationResult = result;
62 shouldBe("verificationResult", "false"); 62 shouldBe("verificationResult", "false");
63 }).then(finishJSTest, failAndFinishJSTest); 63 }).then(finishJSTest, failAndFinishJSTest);
64 </script> 64 </script>
65 65
66 </body> 66 </body>
67 </html> 67 </html>
OLDNEW
« no previous file with comments | « LayoutTests/crypto/rsassa-pkcs1-v1_5-import-jwk-small-key.html ('k') | Source/modules/crypto/SubtleCrypto.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698