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

Side by Side Diff: LayoutTests/crypto/subtle/rsa-oaep-wrap-unwrap-aes.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 wrapping and unwrapping AES keys with RSA-OAEP.");
13
14 jsTestIsAsync = true;
15
16 var publicKeyJSON = {
17 kty: "RSA",
18 alg: "RSA-OAEP",
19 n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLR racT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6 s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPS CnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq7 2KUp02mJDZiiyiglxML_i3-_CeecCw",
20 e: "AQAB"
21 };
22
23 var privateKeyJSON = {
24 kty: "RSA",
25 alg: "RSA-OAEP",
26 n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLR racT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0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GGk",
32 dq: "jmE2DiIPdhwDgLXAQpIaBqQ81bO3XfVT_LRULAwwwwlPuQV148H04zlh9TJ6Y2GZHYokV1U 0eOBpJxfkb7dLYtpJpuiBjRf4yIUEoGlkkI_QlJnFSFr-YjGRdfNHqWBkxlSMZL770R9mIATndGkH7z5 x-r9KwBZFC4FCG2hg_zE",
33 qi: "YCX_pLwbMBA1ThVH0WcwmnytqNcrMCEwTm7ByA2eU6nWbQrULvf7m9_kzfLUcjsnpAVlBQG 5JMXMy0Sq4ptwbywsa5-G8KAOOOR2L3v4hC-Eys9ftgFM_3i0o40eeQH4b3haPbntrIeMg8IzlOuVYKf 9-2QuKDoWeRdd7NsdxTk"
34 };
35 var wrapAlgorithm = {name: "RSA-OAEP", hash: "sha-1"};
36 var extractable = true;
37 var nonExtractable = false;
38
39 var importAlgorithm = {name: "rsa-oaep", hash: {name:"sha-1"}};
40
41 debug("Importing RSA keys...");
42 crypto.subtle.importKey("jwk", publicKeyJSON, importAlgorithm, extractable, ["wr apKey"]).then(function(result) {
43 publicKey = result;
44 return crypto.subtle.importKey("jwk", privateKeyJSON, importAlgorithm, extra ctable, ["unwrapKey"]);
45 }).then(function(result) {
46 privateKey = result;
47
48 debug("Importing an AES key...");
49 aesKeyData = hexStringToUint8Array("603deb1015ca71be2b73aef0857d77811f352c07 3b6108d72d9810a30914dff4");
50 return crypto.subtle.importKey("raw", aesKeyData, {name:"aes-cbc"}, extracta ble, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])
51 }).then(function(result) {
52 aesKey = result;
53 debug("Wrapping it...");
54
55 return crypto.subtle.wrapKey("raw", aesKey, publicKey, wrapAlgorithm);
56 }).then(function(result) {
57 wrappedKey = result;
58 shouldBe("wrappedKey.toString()", "'[object ArrayBuffer]'");
59
60 debug("Unwrapping it...");
61 return crypto.subtle.unwrapKey("raw", wrappedKey, privateKey, wrapAlgorithm, {name:"aes-cbc"}, extractable, ["encrypt", "decrypt"]);
62 }).then(function(result) {
63 unwrappedKey = result;
64 shouldBe("unwrappedKey.toString()", "'[object CryptoKey]'");
65 shouldBe("unwrappedKey.type", "'secret'");
66 shouldBe("unwrappedKey.extractable", "true");
67 shouldBe("unwrappedKey.algorithm.name", "'AES-CBC'");
68 shouldBe("unwrappedKey.algorithm.length", "256");
69 shouldBe("unwrappedKey.usages", "['encrypt', 'decrypt']");
70
71 debug("Exporting it...");
72 return crypto.subtle.exportKey("raw", unwrappedKey);
73 }).then(function(result) {
74 unwrappedKeyData = result;
75 shouldBe("bytesToHexString(unwrappedKeyData)", "bytesToHexString(aesKeyData) ");
76
77 debug("\nWrapping the same key as JWK...");
78 return crypto.subtle.wrapKey("jwk", aesKey, publicKey, wrapAlgorithm);
79 }).then(function(result) {
80 wrappedKey = result;
81 shouldBe("wrappedKey.toString()", "'[object ArrayBuffer]'");
82
83 debug("Unwrapping it...");
84 return crypto.subtle.unwrapKey("jwk", wrappedKey, privateKey, wrapAlgorithm, {name:"aes-cbc"}, extractable, ["encrypt", "decrypt"]);
85 }).then(function(result) {
86 unwrappedKey = result;
87 shouldBe("unwrappedKey.toString()", "'[object CryptoKey]'");
88 shouldBe("unwrappedKey.type", "'secret'");
89 shouldBe("unwrappedKey.extractable", "true");
90 shouldBe("unwrappedKey.algorithm.name", "'AES-CBC'");
91 shouldBe("unwrappedKey.algorithm.length", "256");
92 shouldBe("unwrappedKey.usages", "['encrypt', 'decrypt']");
93
94 debug("Exporting it...");
95 return crypto.subtle.exportKey("raw", unwrappedKey);
96 }).then(function(result) {
97 unwrappedKeyData = result;
98 shouldBe("bytesToHexString(unwrappedKeyData)", "bytesToHexString(aesKeyData) ");
99 }).then(finishJSTest, failAndFinishJSTest);
100 </script>
101
102 </body>
103 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698