OLD | NEW |
| (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 an RSA key with AES-CBC."); | |
13 | |
14 jsTestIsAsync = true; | |
15 | |
16 var extractable = true; | |
17 var nonExtractable = false; | |
18 | |
19 var publicKeyJSON = { | |
20 kty: "RSA", | |
21 alg: "RS256", | |
22 n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLR
racT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6
s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPS
CnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq7
2KUp02mJDZiiyiglxML_i3-_CeecCw", | |
23 e: "AQAB", | |
24 ext: true, | |
25 use: "sig" | |
26 }; | |
27 | |
28 var wrappingKeyOctets = hexStringToUint8Array("2a00e0e776e94e4dc89bf947cebdebe1"
); | |
29 | |
30 debug("Importing a key to wrap..."); | |
31 | |
32 crypto.subtle.importKey("jwk", publicKeyJSON, { name: "RSASSA-PKCS1-v1_5", hash:
{name: "Sha-256"} }, extractable, ["verify"]).then(function(result) { | |
33 key = result; | |
34 shouldBe("key.algorithm.name", "'RSASSA-PKCS1-v1_5'"); | |
35 debug("Importing a key encryption key..."); | |
36 return crypto.subtle.importKey("raw", wrappingKeyOctets, {name: "AES-CBC"},
nonExtractable, ["wrapKey"]); | |
37 }).then(function(result) { | |
38 wrappingKey = result; | |
39 shouldBe("wrappingKey.algorithm.name", "'AES-CBC'"); | |
40 var wrapAlgorithm = {name: "AES-CBC", iv: hexStringToUint8Array("00010203040
5060708090a0b0c0d0e0f")}; | |
41 return crypto.subtle.wrapKey("jwk", key, wrappingKey, wrapAlgorithm); | |
42 }).then(function(result) { | |
43 wrappedKey = result; | |
44 shouldBe("wrappedKey.toString()", "'[object ArrayBuffer]'"); | |
45 }).then(finishJSTest, failAndFinishJSTest); | |
46 | |
47 </script> | |
48 | |
49 </body> | |
50 </html> | |
OLD | NEW |