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 exporting an RSA key."); |
| 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 }; |
| 25 |
| 26 var jwkKeyAsArrayBuffer = asciiToUint8Array(JSON.stringify(publicKeyJSON)); |
| 27 |
| 28 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) { |
| 30 key = result; |
| 31 |
| 32 return crypto.subtle.exportKey(null, key); |
| 33 }).then(failAndFinishJSTest, function(result) { |
| 34 logError(result); |
| 35 return crypto.subtle.exportKey(undefined, key); |
| 36 }).then(failAndFinishJSTest, function(result) { |
| 37 logError(result); |
| 38 return crypto.subtle.exportKey({}, key); |
| 39 }).then(failAndFinishJSTest, function(result) { |
| 40 logError(result); |
| 41 return crypto.subtle.exportKey("", key); |
| 42 }).then(failAndFinishJSTest, function(result) { |
| 43 logError(result); |
| 44 return crypto.subtle.exportKey("foobar", key); |
| 45 }).then(failAndFinishJSTest, function(result) { |
| 46 logError(result); |
| 47 |
| 48 debug("\nExporting the key as JWK..."); |
| 49 return crypto.subtle.exportKey("jwk", key); |
| 50 }).then(function(result) { |
| 51 exportedJWK = JSON.parse(bytesToASCIIString(result)); |
| 52 |
| 53 shouldBe("exportedJWK.kty", "'RSA'"); |
| 54 shouldBe("exportedJWK.n", "publicKeyJSON.n"); |
| 55 shouldBe("exportedJWK.e", "publicKeyJSON.e"); |
| 56 shouldBe("exportedJWK.alg", "'RS256'"); |
| 57 shouldBe("exportedJWK.ext", "true"); |
| 58 shouldBe("exportedJWK.use", "undefined"); |
| 59 shouldBe("exportedJWK.key_ops", "['verify']"); |
| 60 }).then(finishJSTest, failAndFinishJSTest); |
| 61 </script> |
| 62 |
| 63 </body> |
| 64 </html> |
OLD | NEW |