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

Side by Side Diff: LayoutTests/crypto/hmac-export-key.html

Issue 806913006: [WebCrypto] Move LayoutTests from crypto to crypto/subtle (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update path for deserialize legacy tests Created 6 years 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 exporting an AES key.");
13
14 jsTestIsAsync = true;
15
16 var extractable = true;
17 var nonExtractable = false;
18
19 var jwkKey = {
20 "kty": "oct",
21 "k": "ahjkn-_387fgnsibf23qsvahjkn-_387fgnsibf23qs"
22 };
23
24 debug("Importing a JWK key...");
25 crypto.subtle.importKey("jwk", jwkKey, { name: "HMAC", hash: {name: "SHA-256"} } , extractable, ["sign", "verify"]).then(function(result) {
26 key = result;
27
28 return crypto.subtle.exportKey(null, key);
29 }).then(failAndFinishJSTest, function(result) {
30 logError(result);
31 return crypto.subtle.exportKey(undefined, key);
32 }).then(failAndFinishJSTest, function(result) {
33 logError(result);
34 return crypto.subtle.exportKey({}, key);
35 }).then(failAndFinishJSTest, function(result) {
36 logError(result);
37 return crypto.subtle.exportKey("", key);
38 }).then(failAndFinishJSTest, function(result) {
39 logError(result);
40 return crypto.subtle.exportKey("foobar", key);
41 }).then(failAndFinishJSTest, function(result) {
42 logError(result);
43
44 debug("Exporting the key as raw data...");
45 return crypto.subtle.exportKey("raw", key);
46 }, failAndFinishJSTest).then(function(result) {
47 exportedData = result;
48 shouldBe("bytesToHexString(new Uint8Array(exportedData))", "'6a18e49feff7f3b 7e09ec89b7f6deab2f6a18e49feff7f3b7e09ec89b7f6deab'");
49
50 debug("Exporting the key as JWK...");
51 return crypto.subtle.exportKey("jwk", key);
52 }).then(function(result) {
53 exportedJWK = result;
54 shouldBe("exportedJWK.kty", "'oct'");
55 shouldBe("exportedJWK.k", "'ahjkn-_387fgnsibf23qsvahjkn-_387fgnsibf23qs'");
56 shouldBe("exportedJWK.alg", "'HS256'");
57 shouldBe("exportedJWK.ext", "true");
58 shouldBe("exportedJWK.use", "undefined");
59 shouldBe("exportedJWK.key_ops", "['sign', 'verify']");
60
61 debug("\nImporting a key that's not extractable...");
62 return crypto.subtle.importKey("jwk", jwkKey, { name: "HMAC", hash: {name: " SHA-256"} }, nonExtractable, ["sign", "verify"]);
63 }, failAndFinishJSTest).then(function(result) {
64 key = result;
65
66 debug("\nTrying to export as raw...");
67 return crypto.subtle.exportKey("raw", key);
68 }).then(function(result) {
69 testFailed("Promise wasn't rejected");
70 finishJSTest();
71 }, function(result) {
72 logError(result);
73 testPassed("Rejected, as expected");
74
75 debug("Trying to export as jwk...");
76 return crypto.subtle.exportKey("jwk", key);
77 }).then(function(result) {
78 testFailed("Promise wasn't rejected");
79 finishJSTest();
80 }, function(result) {
81 logError(result);
82 testPassed("Rejected, as expected");
83
84 finishJSTest();
85 });
86 </script>
87
88 </body>
89 </html>
OLDNEW
« no previous file with comments | « LayoutTests/crypto/exportKey-unextractable-expected.txt ('k') | LayoutTests/crypto/hmac-export-key-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698