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

Unified Diff: LayoutTests/crypto/ecdsa-import-jwk.html

Issue 707753002: WebCrypto: Add LayoutTests for ECDSA. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase onto master Created 6 years, 1 month 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
Index: LayoutTests/crypto/ecdsa-import-jwk.html
diff --git a/LayoutTests/crypto/ecdsa-import-jwk.html b/LayoutTests/crypto/ecdsa-import-jwk.html
new file mode 100644
index 0000000000000000000000000000000000000000..08ef5313a8b9c5e7ed54b78c82fae690cfc7cbc9
--- /dev/null
+++ b/LayoutTests/crypto/ecdsa-import-jwk.html
@@ -0,0 +1,54 @@
+<!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 importing an EC public and private key for ECDSA.");
+
+jsTestIsAsync = true;
+
+var extractable = true;
+
+var publicKeyJSON = {
+ "kty": "EC",
+ "crv": "P-256",
+ "x": "nLDPaTA9r8dh1ORoe07PA55tNKuWSvgIENjVWKSo1vc",
+ "y": "LVEjOheIkgqG7gihlix576MX+3h54pfa0hRtuZX6HHg"
+};
+
+var privateKeyJSON = {
+ "kty": "EC",
+ "crv": "P-384",
+ "d": "pJLOj6kAhMIn4aMveXTTnp/2en6HBew0GbNftgdYK+vUYeCxUgrHbsLdTptj665x",
+ "x": "5V_ubEnY1SP1znv5wEJc5P9lBwi33lz7CVkBUjl5p_BCYC2zCFRzU2mBO1w_Xvho",
+ "y": "KPWcxdxQmJKpiNOKjiUZ3j0MT9D72wmT448YUGwXYGxeJCSSRvHOlJg6U2HFvpg-"
+};
+
+debug("Importing a public key...");
+crypto.subtle.importKey("jwk", publicKeyJSON, {name: "ECDSA", namedCurve: "P-256"}, extractable, ["verify"]).then(function(result) {
+ publicKey = result;
+ shouldBe("publicKey.toString()", "'[object CryptoKey]'");
+ shouldBe("publicKey.type", "'public'");
+ shouldBe("publicKey.usages", "['verify']");
+ shouldBe("publicKey.algorithm.name", "'ECDSA'");
+ shouldBe("publicKey.algorithm.namedCurve", "'P-256'");
+ debug("\nImporting a private key...");
+ return crypto.subtle.importKey("jwk", privateKeyJSON, {name: "ECDSA", namedCurve: "P-384"}, extractable, ["sign"]);
+}).then(function(result) {
+ privateKey = result;
+ shouldBe("privateKey.toString()", "'[object CryptoKey]'");
+ shouldBe("privateKey.type", "'private'");
+ shouldBe("privateKey.usages", "['sign']");
+ shouldBe("privateKey.algorithm.name", "'ECDSA'");
+ shouldBe("privateKey.algorithm.namedCurve", "'P-384'");
+}).then(finishJSTest, failAndFinishJSTest);
+</script>
+
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698