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

Side by Side Diff: LayoutTests/crypto/subtle/ecdsa-sign-verify.html

Issue 957713004: [WebCrypto] Split LayoutTests/crypto/subtle into per-algorithm directories (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated to latest master Created 5 years, 10 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
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 <script src="resources/common.js"></script>
6 </head>
7 <body>
8 <p id="description"></p>
9 <div id="console"></div>
10
11 <script>
12 description("Test importing an EC key for ECDSA.");
13
14 jsTestIsAsync = true;
15
16 var extractable = true;
17
18 var publicKeyJSON = {
19 "kty": "EC",
20 "crv": "P-256",
21 "x": "fBEMZtz9qAf25p5F3bPHT2mhSE0gPo3Frajpqd18s8c",
22 "y": "DfRImG5RveXRV2-ZkB-cLGqAakf9kHZDpyuDVZfvyMY"
23 };
24
25 var privateKeyJSON = {
26 "kty": "EC",
27 "crv": "P-256",
28 "d": "H-M5UMX0YRJK6ZLCvf3xxzsWFfVxvVZ-YNGaofSM30I",
29 "x": "fBEMZtz9qAf25p5F3bPHT2mhSE0gPo3Frajpqd18s8c",
30 "y": "DfRImG5RveXRV2-ZkB-cLGqAakf9kHZDpyuDVZfvyMY"
31 };
32
33 var data = asciiToUint8Array("Hello, world!");
34
35 debug("Importing a public key...");
36 crypto.subtle.importKey("jwk", publicKeyJSON, { name: "ECDSA", namedCurve: "P-25 6" }, extractable, ["verify"]).then(function(result) {
37 publicKey = result;
38 debug("\nImporting a private key...");
39 return crypto.subtle.importKey("jwk", privateKeyJSON, { name: "ECDSA", named Curve: "P-256" }, extractable, ["sign"]);
40 }).then(function(result) {
41 privateKey = result;
42 debug("\nSigning some text...");
43 return crypto.subtle.sign({ name: "ECDSA", hash: { name: "SHA-1" } }, privat eKey, data);
44 }).then(function(result) {
45 signature = result;
46
47 debug("\nVerifying the signature...");
48 return crypto.subtle.verify({ name: "ECDSA", hash: { name: "SHA-1" } }, publ icKey, signature, data);
49 }).then(function(result) {
50 verificationResult = result;
51 shouldBe("verificationResult", "true");
52 debug("\nVerifying a bad signature...");
53 return crypto.subtle.verify({ name: "ECDSA", hash: { name: "SHA-1" } }, publ icKey, new Uint8Array(256), data);
54 }).then(function(result) {
55 verificationResult = result;
56 shouldBe("verificationResult", "false");
57 }).then(finishJSTest, failAndFinishJSTest);
58 </script>
59
60 </body>
61 </html>
OLDNEW
« no previous file with comments | « LayoutTests/crypto/subtle/ecdsa-import-jwk-expected.txt ('k') | LayoutTests/crypto/subtle/ecdsa-sign-verify-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698