Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Unified Diff: LayoutTests/crypto/rsa-export-key.html

Issue 298023002: [webcrypto] Import WebKit's webcrypto tests. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: remove FIXME for unrecognized jwk usages (supported now) Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/crypto/resources/common.js ('k') | LayoutTests/crypto/rsa-export-key-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/crypto/rsa-export-key.html
diff --git a/LayoutTests/crypto/rsa-export-key.html b/LayoutTests/crypto/rsa-export-key.html
new file mode 100644
index 0000000000000000000000000000000000000000..a4dd526a5df82be83506f4b3bacd864ca046eac3
--- /dev/null
+++ b/LayoutTests/crypto/rsa-export-key.html
@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../resources/js-test.js"></script>
+<script src="resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test exporting an RSA key.");
+
+jsTestIsAsync = true;
+
+var extractable = true;
+var nonExtractable = false;
+
+var publicKeyJSON = {
+ kty: "RSA",
+ alg: "RS256",
+ n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+ e: "AQAB"
+};
+
+var jwkKeyAsArrayBuffer = asciiToUint8Array(JSON.stringify(publicKeyJSON));
+
+debug("\nImporting a JWK key...");
+crypto.subtle.importKey("jwk", jwkKeyAsArrayBuffer, {name: "RSASSA-PKCS1-v1_5", hash: {name: "sha-256"}}, extractable, ['verify']).then(function(result) {
+ key = result;
+
+ return crypto.subtle.exportKey(null, key);
+}).then(failAndFinishJSTest, function(result) {
+ logError(result);
+ return crypto.subtle.exportKey(undefined, key);
+}).then(failAndFinishJSTest, function(result) {
+ logError(result);
+ return crypto.subtle.exportKey({}, key);
+}).then(failAndFinishJSTest, function(result) {
+ logError(result);
+ return crypto.subtle.exportKey("", key);
+}).then(failAndFinishJSTest, function(result) {
+ logError(result);
+ return crypto.subtle.exportKey("foobar", key);
+}).then(failAndFinishJSTest, function(result) {
+ logError(result);
+
+ debug("\nExporting the key as JWK...");
+ return crypto.subtle.exportKey("jwk", key);
+}).then(function(result) {
+ exportedJWK = JSON.parse(bytesToASCIIString(result));
+
+ shouldBe("exportedJWK.kty", "'RSA'");
+ shouldBe("exportedJWK.n", "publicKeyJSON.n");
+ shouldBe("exportedJWK.e", "publicKeyJSON.e");
+ shouldBe("exportedJWK.alg", "'RS256'");
+ shouldBe("exportedJWK.ext", "true");
+ shouldBe("exportedJWK.use", "undefined");
+ shouldBe("exportedJWK.key_ops", "['verify']");
+}).then(finishJSTest, failAndFinishJSTest);
+</script>
+
+</body>
+</html>
« no previous file with comments | « LayoutTests/crypto/resources/common.js ('k') | LayoutTests/crypto/rsa-export-key-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698