OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../resources/js-test.js"></script> | 4 <script src="../resources/js-test.js"></script> |
5 <script src="resources/common.js"></script> | 5 <script src="resources/common.js"></script> |
6 </head> | 6 </head> |
7 <body> | 7 <body> |
8 <p id="description"></p> | 8 <p id="description"></p> |
9 <div id="console"></div> | 9 <div id="console"></div> |
10 | 10 |
11 <script> | 11 <script> |
12 description("Test exporting an RSA key."); | 12 description("Test exporting an RSA key."); |
13 | 13 |
14 jsTestIsAsync = true; | 14 jsTestIsAsync = true; |
15 | 15 |
16 var extractable = true; | 16 var extractable = true; |
17 var nonExtractable = false; | 17 var nonExtractable = false; |
18 | 18 |
19 var publicKeyJSON = { | 19 var publicKeyJSON = { |
20 kty: "RSA", | 20 kty: "RSA", |
21 alg: "RS256", | 21 alg: "RS256", |
22 n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLR
racT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6
s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPS
CnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq7
2KUp02mJDZiiyiglxML_i3-_CeecCw", | 22 n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLR
racT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6
s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPS
CnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq7
2KUp02mJDZiiyiglxML_i3-_CeecCw", |
23 e: "AQAB" | 23 e: "AQAB" |
24 }; | 24 }; |
25 | 25 |
26 var jwkKeyAsArrayBuffer = asciiToUint8Array(JSON.stringify(publicKeyJSON)); | |
27 | |
28 debug("\nImporting a JWK key..."); | 26 debug("\nImporting a JWK key..."); |
29 crypto.subtle.importKey("jwk", jwkKeyAsArrayBuffer, {name: "RSASSA-PKCS1-v1_5",
hash: {name: "sha-256"}}, extractable, ['verify']).then(function(result) { | 27 crypto.subtle.importKey("jwk", publicKeyJSON, {name: "RSASSA-PKCS1-v1_5", hash:
{name: "sha-256"}}, extractable, ['verify']).then(function(result) { |
30 key = result; | 28 key = result; |
31 | 29 |
32 return crypto.subtle.exportKey(null, key); | 30 return crypto.subtle.exportKey(null, key); |
33 }).then(failAndFinishJSTest, function(result) { | 31 }).then(failAndFinishJSTest, function(result) { |
34 logError(result); | 32 logError(result); |
35 return crypto.subtle.exportKey(undefined, key); | 33 return crypto.subtle.exportKey(undefined, key); |
36 }).then(failAndFinishJSTest, function(result) { | 34 }).then(failAndFinishJSTest, function(result) { |
37 logError(result); | 35 logError(result); |
38 return crypto.subtle.exportKey({}, key); | 36 return crypto.subtle.exportKey({}, key); |
39 }).then(failAndFinishJSTest, function(result) { | 37 }).then(failAndFinishJSTest, function(result) { |
(...skipping 15 matching lines...) Expand all Loading... |
55 shouldBe("exportedJWK.e", "publicKeyJSON.e"); | 53 shouldBe("exportedJWK.e", "publicKeyJSON.e"); |
56 shouldBe("exportedJWK.alg", "'RS256'"); | 54 shouldBe("exportedJWK.alg", "'RS256'"); |
57 shouldBe("exportedJWK.ext", "true"); | 55 shouldBe("exportedJWK.ext", "true"); |
58 shouldBe("exportedJWK.use", "undefined"); | 56 shouldBe("exportedJWK.use", "undefined"); |
59 shouldBe("exportedJWK.key_ops", "['verify']"); | 57 shouldBe("exportedJWK.key_ops", "['verify']"); |
60 }).then(finishJSTest, failAndFinishJSTest); | 58 }).then(finishJSTest, failAndFinishJSTest); |
61 </script> | 59 </script> |
62 | 60 |
63 </body> | 61 </body> |
64 </html> | 62 </html> |
OLD | NEW |