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

Unified Diff: third_party/WebKit/LayoutTests/crypto/subtle/ecdh/import-export-raw.html

Issue 2162303002: [webcrypto] Add support for import/export of "raw" formatted EC keys. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@usage_order
Patch Set: address feedback Created 4 years, 4 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
Index: third_party/WebKit/LayoutTests/crypto/subtle/ecdh/import-export-raw.html
diff --git a/third_party/WebKit/LayoutTests/crypto/subtle/ecdh/import-export-raw.html b/third_party/WebKit/LayoutTests/crypto/subtle/ecdh/import-export-raw.html
new file mode 100644
index 0000000000000000000000000000000000000000..005e91203eed6320e73cd864085b37b3e52b9421
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/crypto/subtle/ecdh/import-export-raw.html
@@ -0,0 +1,62 @@
+<!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 and exporting an EC public key in raw format.");
+
+jsTestIsAsync = true;
+
+// P-256 key in uncompressed form
+var kUncompressedHex = "044EA34391AA73885454BC45DF3FDCC4A70262FA4621FFE25B5790590C340A4BD9265EF2B3F9A86E2959A960D90323465D60CD4A90D314C5DE3F869AD0D4BF6C10";
+
+// The same key as above but in compressed form.
+var kCompressedHex = "024ea34391aa73885454bc45df3fdcc4a70262fa4621ffe25b5790590c340a4bd9";
+
+var algorithm = {name: "ECDH", namedCurve: "P-256"};
+var extractable = true;
+
+debug("Importing raw (uncompressed) public key...");
+crypto.subtle.importKey("raw", hexStringToUint8Array(kUncompressedHex), algorithm, extractable, []).then(function(result) {
+ publicKey = result;
+ shouldBe("publicKey.toString()", "'[object CryptoKey]'");
+ shouldBe("publicKey.type", "'public'");
+ shouldBe("publicKey.usages", "[]");
+ shouldBe("publicKey.algorithm.name", "'ECDH'");
+ shouldBe("publicKey.algorithm.namedCurve", "'P-256'");
+
+ debug("Exporting to raw...");
+ return crypto.subtle.exportKey("raw", publicKey);
+}).then(function(result) {
+ bytesShouldMatchHexString("Exported to raw", kUncompressedHex, result)
+
+ debug("Importing raw (compressed) public key...");
+ return crypto.subtle.importKey("raw", hexStringToUint8Array(kCompressedHex), algorithm, extractable, []);
+}).then(function(result) {
+ publicKey = result;
+ shouldBe("publicKey.toString()", "'[object CryptoKey]'");
+ shouldBe("publicKey.type", "'public'");
+ shouldBe("publicKey.usages", "[]");
+ shouldBe("publicKey.algorithm.name", "'ECDH'");
+ shouldBe("publicKey.algorithm.namedCurve", "'P-256'");
+
+ debug("Exporting to raw...");
+ return crypto.subtle.exportKey("raw", publicKey);
+}).then(function(result) {
+ bytesShouldMatchHexString("Exported to raw", kUncompressedHex, result)
+
+ debug("Importing invalid raw public key...");
+ return crypto.subtle.importKey("raw", hexStringToUint8Array("040708"), algorithm, extractable, []);
+}).then(failAndFinishJSTest, function(result) {
+ logError(result);
+}).then(finishJSTest, failAndFinishJSTest);
+</script>
+
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698