4 <script src=
"../../resources/js-test.js"></script>
5 <script src=
"resources/common.js"></script>
8 <p id=
"description"></p>
9 <div id=
"console"></div>
12 description("Test exporting an RSA key.");
16 var extractable
= true;
17 var nonExtractable
= false;
22 n
: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
26 debug("\nImporting a JWK key...");
27 crypto
.subtle
.importKey("jwk", publicKeyJSON
, {name
: "RSASSA-PKCS1-v1_5", hash
: {name
: "sha-256"}}, extractable
, ['verify']).then(function(result
) {
30 return crypto
.subtle
.exportKey(null, key
);
31 }).then(failAndFinishJSTest
, function(result
) {
33 return crypto
.subtle
.exportKey(undefined, key
);
34 }).then(failAndFinishJSTest
, function(result
) {
36 return crypto
.subtle
.exportKey({}, key
);
37 }).then(failAndFinishJSTest
, function(result
) {
39 return crypto
.subtle
.exportKey("", key
);
40 }).then(failAndFinishJSTest
, function(result
) {
42 return crypto
.subtle
.exportKey("foobar", key
);
43 }).then(failAndFinishJSTest
, function(result
) {
46 debug("\nExporting the key as JWK...");
47 return crypto
.subtle
.exportKey("jwk", key
);
48 }).then(function(result
) {
51 shouldBe("exportedJWK.kty", "'RSA'");
52 shouldBe("exportedJWK.n", "publicKeyJSON.n");
53 shouldBe("exportedJWK.e", "publicKeyJSON.e");
54 shouldBe("exportedJWK.alg", "'RS256'");
55 shouldBe("exportedJWK.ext", "true");
56 shouldBe("exportedJWK.use", "undefined");
57 shouldBe("exportedJWK.key_ops", "['verify']");
58 }).then(finishJSTest
, failAndFinishJSTest
);