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

Side by Side Diff: LayoutTests/crypto/jwk-export-use-values.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 keys with various usages to JWK.");
13
14 jsTestIsAsync = true;
15
16 var extractable = true;
17
18 var aesKeyAsArrayBuffer = Base64URL.parse("jnOw99oOZFLIEPMrgJB55Q");
19 var hmacKeyAsArrayBuffer = Base64URL.parse("ahjkn-_387fgnsibf23qsvahjkn-_387fgns ibf23qs");
20
21 function testWithAESCBC(usages, expectedKeyOps)
22 {
23 return crypto.subtle.importKey("raw", aesKeyAsArrayBuffer, {name: "AES-CBC"}, extractable, usages).then(function(result) {
24 return crypto.subtle.exportKey("jwk", result);
25 }).then(function(result) {
26 jwk = result;
27 debug(usages + ":");
28 shouldBe("jwk.use", "undefined");
29 shouldBe("jwk.key_ops", JSON.stringify(expectedKeyOps));
30 debug("");
31 });
32 }
33
34 function testWithHMAC(usages, expectedKeyOps)
35 {
36 return crypto.subtle.importKey("raw", hmacKeyAsArrayBuffer, {name: 'hmac', h ash: {name: 'sha-256'}}, extractable, usages).then(function(result) {
37 return crypto.subtle.exportKey("jwk", result);
38 }).then(function(result) {
39 jwk = result;
40 debug(usages + ":");
41 shouldBe("jwk.use", "undefined");
42 shouldBe("jwk.key_ops", JSON.stringify(expectedKeyOps));
43 debug("");
44 });
45 }
46
47 Promise.all([
48 testWithAESCBC(["encrypt"], ["encrypt"]),
49 testWithAESCBC(["decrypt"], ["decrypt"]),
50 testWithAESCBC(["encrypt", "decrypt"], ["encrypt", "decrypt"]),
51 testWithAESCBC(["wrapKey"], ["wrapKey"]),
52 testWithAESCBC(["unwrapKey"], ["unwrapKey"]),
53 testWithAESCBC(["wrapKey", "unwrapKey"], ["wrapKey", "unwrapKey"]),
54 testWithAESCBC(["encrypt", "decrypt", "wrapKey"], ["encrypt", "decrypt", "wr apKey"]),
55 testWithAESCBC(["encrypt", "decrypt", "wrapKey", "unwrapKey"], ["encrypt", " decrypt", "wrapKey", "unwrapKey"]),
56 testWithHMAC(["sign"], ["sign"]),
57 testWithHMAC(["verify"], ["verify"]),
58 testWithHMAC(["sign", "verify"], ["sign", "verify"]),
59 ]).then(finishJSTest, failAndFinishJSTest);
60 </script>
61
62 </body>
63 </html>
OLDNEW
« no previous file with comments | « LayoutTests/crypto/importKey-normalize-usages-expected.txt ('k') | LayoutTests/crypto/jwk-export-use-values-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698