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/aes-kw-wrap-unwrap-aes.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 wrapping and unwrapping keys with AES-KW.");
13
14 jsTestIsAsync = true;
15
16 var kekData = hexStringToUint8Array("000102030405060708090A0B0C0D0E0F");
17 var keyData = hexStringToUint8Array("00112233445566778899AABBCCDDEEFF");
18 var extractable = true;
19
20 debug("Importing key encryption key...");
21 crypto.subtle.importKey("raw", kekData, {name: "aes-kw"}, extractable, ["wrapKey ", "unwrapKey"]).then(function(result) {
22 kek = result;
23
24 debug("Importing a key to be wrapped...");
25 return crypto.subtle.importKey("raw", keyData, {name: "aes-cbc"}, extractabl e, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]);
26 }).then(function(result) {
27 key = result;
28
29 debug("Wrapping it...");
30 return crypto.subtle.wrapKey("raw", key, kek, {name: "aes-kw"});
31 }).then(function(result) {
32 wrappedKey = result;
33 shouldBe("bytesToHexString(wrappedKey)", "'1fa68b0a8112b447aef34bd8fb5a7b829 d3e862371d2cfe5'"); // Result from RFC 3394.
34
35 debug("Unwrapping it...");
36 return crypto.subtle.unwrapKey("raw", wrappedKey, kek, {name: "aes-kw"}, {na me: "aes-cbc"}, extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]);
37 }).then(function(result) {
38 unwrappedKey = result;
39 shouldBe("unwrappedKey.toString()", "'[object CryptoKey]'");
40 shouldBe("unwrappedKey.type", "'secret'");
41 shouldBe("unwrappedKey.extractable", "true");
42 shouldBe("unwrappedKey.algorithm.name", "'AES-CBC'");
43 shouldBe("unwrappedKey.algorithm.length", "128");
44 shouldBe("unwrappedKey.usages", "['encrypt', 'decrypt', 'wrapKey', 'unwrapKe y']");
45
46 debug("Exporting it...");
47 return crypto.subtle.exportKey("raw", unwrappedKey);
48 }).then(function(result) {
49 unwrappedKeyData = result;
50 shouldBe("bytesToHexString(unwrappedKeyData)", "bytesToHexString(keyData)");
51
52 finishJSTest();
53 });
54 </script>
55
56 </body>
57 </html>
OLDNEW
« no previous file with comments | « LayoutTests/crypto/aes-kw-key-manipulation-expected.txt ('k') | LayoutTests/crypto/aes-kw-wrap-unwrap-aes-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698