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 importing an RSA key for RSASSA-PKCS1-v1_5."); | |
13 | |
14 jsTestIsAsync = true; | |
15 | |
16 var extractable = true; | |
17 | |
18 var publicKeyJSON = { | |
19 kty: "RSA", | |
20 alg: "RS256", | |
21 n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLR
racT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6
s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPS
CnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq7
2KUp02mJDZiiyiglxML_i3-_CeecCw", | |
22 e: "AQAB" | |
23 }; | |
24 | |
25 var privateKeyJSON = { | |
26 kty: "RSA", | |
27 alg: "RS256", | |
28 n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLR
racT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6
s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPS
CnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq7
2KUp02mJDZiiyiglxML_i3-_CeecCw", | |
29 e: "AQAB", | |
30 d: "eNLS37aCz7RXSNPD_D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WcwmnytqNcrMCEwTm7ByA2eU6nWbQrULvf7m9_kzfLUcjsnpAVlBQG
5JMXMy0Sq4ptwbywsa5-G8KAOOOR2L3v4hC-Eys9ftgFM_3i0o40eeQH4b3haPbntrIeMg8IzlOuVYKf
9-2QuKDoWeRdd7NsdxTk" | |
36 }; | |
37 | |
38 debug("Importing a public key..."); | |
39 crypto.subtle.importKey("jwk", publicKeyJSON, {name: "RSASSA-PKCS1-v1_5", hash:
{name: "sha-256"}}, extractable, ["verify"]).then(function(result) { | |
40 publicKey = result; | |
41 shouldBe("publicKey.toString()", "'[object CryptoKey]'"); | |
42 shouldBe("publicKey.type", "'public'"); | |
43 shouldBe("publicKey.usages", "['verify']"); | |
44 shouldBe("publicKey.algorithm.name", "'RSASSA-PKCS1-v1_5'"); | |
45 shouldBe("publicKey.algorithm.modulusLength", "2048"); | |
46 shouldBe("bytesToHexString(publicKey.algorithm.publicExponent)", "'010001'")
; | |
47 shouldBe("publicKey.algorithm.hash.name", "'SHA-256'"); | |
48 debug("\nImporting a private key..."); | |
49 return crypto.subtle.importKey("jwk", privateKeyJSON, {name: "RSASSA-PKCS1-v
1_5", hash: {name: "sha-256"}}, extractable, ["sign"]); | |
50 }).then(function(result) { | |
51 privateKey = result; | |
52 shouldBe("privateKey.toString()", "'[object CryptoKey]'"); | |
53 shouldBe("privateKey.type", "'private'"); | |
54 shouldBe("privateKey.usages", "['sign']"); | |
55 shouldBe("privateKey.algorithm.name", "'RSASSA-PKCS1-v1_5'"); | |
56 shouldBe("privateKey.algorithm.modulusLength", "2048"); | |
57 shouldBe("bytesToHexString(privateKey.algorithm.publicExponent)", "'010001'"
); | |
58 shouldBe("privateKey.algorithm.hash.name", "'SHA-256'"); | |
59 }).then(finishJSTest, failAndFinishJSTest); | |
60 </script> | |
61 | |
62 </body> | |
63 </html> | |
OLD | NEW |