Title: [221345] trunk/LayoutTests
Revision
221345
Author
zandober...@gmail.com
Date
2017-08-30 00:31:32 -0700 (Wed, 30 Aug 2017)

Log Message

[WebCrypto] Add layout tests covering EC P-521
https://bugs.webkit.org/show_bug.cgi?id=175659

Reviewed by Jiewen Tan.

Add layout tests that cover operations with 521-bit elliptic curves.
The newly-introduced tests are skipped on all platforms for now since
no implementation provides support just yet. The already-existing tests
are modified in a way that only tests the EC P-521 capability optionally,
if e.g. P-521 key imports are successful, without affecting the tests for
P-256 and P-384 operations.

The newly-introduced tests are mirros of existing P-256 and P-384 tests,
but they specifically test the P-521 capabilities and use appropriate
curve information (X and Y coordinates for the EC public key, D for the
EC private key) for that type of elliptic curve.

* crypto/subtle/ec-import-pkcs8-key-export-pkcs8-key-p521-expected.txt: Added.
* crypto/subtle/ec-import-pkcs8-key-export-pkcs8-key-p521.html: Added.
* crypto/subtle/ec-import-spki-key-export-spki-key-p521-expected.txt: Added.
* crypto/subtle/ec-import-spki-key-export-spki-key-p521.html: Added.
* crypto/subtle/ecdh-derive-bits-length-limits-expected.txt:
* crypto/subtle/ecdh-derive-bits-length-limits.html:
* crypto/subtle/ecdh-generate-export-jwk-key-p521-expected.txt: Added.
* crypto/subtle/ecdh-generate-export-jwk-key-p521.html: Added.
* crypto/subtle/ecdh-generate-export-key-pkcs8-p521-expected.txt: Added.
* crypto/subtle/ecdh-generate-export-key-pkcs8-p521.html: Added.
* crypto/subtle/ecdh-generate-export-key-raw-p521-expected.txt: Added.
* crypto/subtle/ecdh-generate-export-key-raw-p521.html: Added.
* crypto/subtle/ecdh-generate-export-key-spki-p521-expected.txt: Added.
* crypto/subtle/ecdh-generate-export-key-spki-p521.html: Added.
* crypto/subtle/ecdh-generate-key-p521-expected.txt: Added.
* crypto/subtle/ecdh-generate-key-p521.html: Added.
* crypto/subtle/ecdh-import-jwk-private-key-p521-expected.txt: Added.
* crypto/subtle/ecdh-import-jwk-private-key-p521.html: Added.
* crypto/subtle/ecdh-import-jwk-public-key-p521-expected.txt: Added.
* crypto/subtle/ecdh-import-jwk-public-key-p521.html: Added.
* crypto/subtle/ecdh-import-pkcs8-key-p521-expected.txt: Added.
* crypto/subtle/ecdh-import-pkcs8-key-p521-validate-ecprivatekey-parameters-publickey-expected.txt: Added.
* crypto/subtle/ecdh-import-pkcs8-key-p521-validate-ecprivatekey-parameters-publickey.html: Added.
* crypto/subtle/ecdh-import-pkcs8-key-p521.html: Added.
* crypto/subtle/ecdh-import-raw-key-p521-expected.txt: Added.
* crypto/subtle/ecdh-import-raw-key-p521.html: Added.
* crypto/subtle/ecdh-import-spki-key-ecdh-identifier-expected.txt:
* crypto/subtle/ecdh-import-spki-key-ecdh-identifier.html:
* crypto/subtle/ecdh-import-spki-key-p521-expected.txt: Added.
* crypto/subtle/ecdh-import-spki-key-p521.html: Added.
* crypto/subtle/ecdsa-generate-key-sign-verify-p521-expected.txt: Added.
* crypto/subtle/ecdsa-generate-key-sign-verify-p521.html: Added.
* crypto/subtle/ecdsa-import-jwk-public-key-alg-521-expected.txt: Added.
* crypto/subtle/ecdsa-import-jwk-public-key-alg-521.html: Added.
* crypto/subtle/ecdsa-import-key-sign-p521-expected.txt: Added.
* crypto/subtle/ecdsa-import-key-sign-p521.html: Added.
* crypto/subtle/ecdsa-import-key-verify-p521-expected.txt: Added.
* crypto/subtle/ecdsa-import-key-verify-p521.html: Added.
* crypto/subtle/ecdsa-import-pkcs8-key-p521-validate-ecprivatekey-parameters-publickey-expected.txt: Added.
* crypto/subtle/ecdsa-import-pkcs8-key-p521-validate-ecprivatekey-parameters-publickey.html: Added.
* platform/gtk/TestExpectations:
* platform/ios/TestExpectations:
* platform/mac/TestExpectations:
* platform/wpe/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (221344 => 221345)


--- trunk/LayoutTests/ChangeLog	2017-08-30 06:59:57 UTC (rev 221344)
+++ trunk/LayoutTests/ChangeLog	2017-08-30 07:31:32 UTC (rev 221345)
@@ -1,3 +1,67 @@
+2017-08-30  Zan Dobersek  <zdober...@igalia.com>
+
+        [WebCrypto] Add layout tests covering EC P-521
+        https://bugs.webkit.org/show_bug.cgi?id=175659
+
+        Reviewed by Jiewen Tan.
+
+        Add layout tests that cover operations with 521-bit elliptic curves.
+        The newly-introduced tests are skipped on all platforms for now since
+        no implementation provides support just yet. The already-existing tests
+        are modified in a way that only tests the EC P-521 capability optionally,
+        if e.g. P-521 key imports are successful, without affecting the tests for
+        P-256 and P-384 operations.
+
+        The newly-introduced tests are mirros of existing P-256 and P-384 tests,
+        but they specifically test the P-521 capabilities and use appropriate
+        curve information (X and Y coordinates for the EC public key, D for the
+        EC private key) for that type of elliptic curve.
+
+        * crypto/subtle/ec-import-pkcs8-key-export-pkcs8-key-p521-expected.txt: Added.
+        * crypto/subtle/ec-import-pkcs8-key-export-pkcs8-key-p521.html: Added.
+        * crypto/subtle/ec-import-spki-key-export-spki-key-p521-expected.txt: Added.
+        * crypto/subtle/ec-import-spki-key-export-spki-key-p521.html: Added.
+        * crypto/subtle/ecdh-derive-bits-length-limits-expected.txt:
+        * crypto/subtle/ecdh-derive-bits-length-limits.html:
+        * crypto/subtle/ecdh-generate-export-jwk-key-p521-expected.txt: Added.
+        * crypto/subtle/ecdh-generate-export-jwk-key-p521.html: Added.
+        * crypto/subtle/ecdh-generate-export-key-pkcs8-p521-expected.txt: Added.
+        * crypto/subtle/ecdh-generate-export-key-pkcs8-p521.html: Added.
+        * crypto/subtle/ecdh-generate-export-key-raw-p521-expected.txt: Added.
+        * crypto/subtle/ecdh-generate-export-key-raw-p521.html: Added.
+        * crypto/subtle/ecdh-generate-export-key-spki-p521-expected.txt: Added.
+        * crypto/subtle/ecdh-generate-export-key-spki-p521.html: Added.
+        * crypto/subtle/ecdh-generate-key-p521-expected.txt: Added.
+        * crypto/subtle/ecdh-generate-key-p521.html: Added.
+        * crypto/subtle/ecdh-import-jwk-private-key-p521-expected.txt: Added.
+        * crypto/subtle/ecdh-import-jwk-private-key-p521.html: Added.
+        * crypto/subtle/ecdh-import-jwk-public-key-p521-expected.txt: Added.
+        * crypto/subtle/ecdh-import-jwk-public-key-p521.html: Added.
+        * crypto/subtle/ecdh-import-pkcs8-key-p521-expected.txt: Added.
+        * crypto/subtle/ecdh-import-pkcs8-key-p521-validate-ecprivatekey-parameters-publickey-expected.txt: Added.
+        * crypto/subtle/ecdh-import-pkcs8-key-p521-validate-ecprivatekey-parameters-publickey.html: Added.
+        * crypto/subtle/ecdh-import-pkcs8-key-p521.html: Added.
+        * crypto/subtle/ecdh-import-raw-key-p521-expected.txt: Added.
+        * crypto/subtle/ecdh-import-raw-key-p521.html: Added.
+        * crypto/subtle/ecdh-import-spki-key-ecdh-identifier-expected.txt:
+        * crypto/subtle/ecdh-import-spki-key-ecdh-identifier.html:
+        * crypto/subtle/ecdh-import-spki-key-p521-expected.txt: Added.
+        * crypto/subtle/ecdh-import-spki-key-p521.html: Added.
+        * crypto/subtle/ecdsa-generate-key-sign-verify-p521-expected.txt: Added.
+        * crypto/subtle/ecdsa-generate-key-sign-verify-p521.html: Added.
+        * crypto/subtle/ecdsa-import-jwk-public-key-alg-521-expected.txt: Added.
+        * crypto/subtle/ecdsa-import-jwk-public-key-alg-521.html: Added.
+        * crypto/subtle/ecdsa-import-key-sign-p521-expected.txt: Added.
+        * crypto/subtle/ecdsa-import-key-sign-p521.html: Added.
+        * crypto/subtle/ecdsa-import-key-verify-p521-expected.txt: Added.
+        * crypto/subtle/ecdsa-import-key-verify-p521.html: Added.
+        * crypto/subtle/ecdsa-import-pkcs8-key-p521-validate-ecprivatekey-parameters-publickey-expected.txt: Added.
+        * crypto/subtle/ecdsa-import-pkcs8-key-p521-validate-ecprivatekey-parameters-publickey.html: Added.
+        * platform/gtk/TestExpectations:
+        * platform/ios/TestExpectations:
+        * platform/mac/TestExpectations:
+        * platform/wpe/TestExpectations:
+
 2017-08-29  Wenson Hsieh  <wenson_hs...@apple.com>
 
         REGRESSION(r210287) On drop, event.dataTransfer.getData("text") returns an empty string when dragging an image

Added: trunk/LayoutTests/crypto/subtle/ec-import-pkcs8-key-export-pkcs8-key-p521-expected.txt (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ec-import-pkcs8-key-export-pkcs8-key-p521-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ec-import-pkcs8-key-export-pkcs8-key-p521-expected.txt	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,11 @@
+Test importing a P-521 PKCS8 ECDH key and exporting it in PKCS8 format
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS bytesToHexString(privateKey) is pkcs8KeyHex
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/crypto/subtle/ec-import-pkcs8-key-export-pkcs8-key-p521.html (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ec-import-pkcs8-key-export-pkcs8-key-p521.html	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ec-import-pkcs8-key-export-pkcs8-key-p521.html	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a P-521 PKCS8 ECDH key and exporting it in PKCS8 format");
+
+jsTestIsAsync = true;
+
+var pkcs8KeyHex = "3081ee020100301006072a8648ce3d020106052b810400230481d63081d302010104420160ccf72d28b6df9768c30f67e77a000ecdb6e20381d8ee6f5474d6a612c39b7f3d361e1e9901f4cc573dcfc7da3eeadcb3e10532ca12d39df5ed39a5156c3e3ceba18189038186000400e9a76aed2acda29ba2a5dbdc1f04c6160bc16c6d16b737a557f9dcbc8efb79dd1b9eabfc0a911ea3fd574176e2cbf32caa9babb505b04f30ecf369e6bec91d1ac201a8aa718c0c293b085d7902a314cab6e8048e458cc28c7da4fff2fcbf3da6d42fee94de5e0a3fb34342780e3f9df7b424911d6efb8628079566b50efe6971271eea";
+var pkcs8Key = hexStringToUint8Array(pkcs8KeyHex);
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("pkcs8", pkcs8Key, {name: "ECDH", namedCurve: "P-521"}, extractable, ["deriveKey", "deriveBits"]).then(function(key) {
+    return crypto.subtle.exportKey("pkcs8", key);
+}).then(function(result) {
+    privateKey = result;
+
+    shouldBe("bytesToHexString(privateKey)", "pkcs8KeyHex");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/crypto/subtle/ec-import-spki-key-export-spki-key-p521-expected.txt (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ec-import-spki-key-export-spki-key-p521-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ec-import-spki-key-export-spki-key-p521-expected.txt	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,11 @@
+Test importing a P-521 SPKI ECDH key and exporting it in SPKI format
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS bytesToHexString(publicKey) is spkiKeyHex
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/crypto/subtle/ec-import-spki-key-export-spki-key-p521.html (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ec-import-spki-key-export-spki-key-p521.html	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ec-import-spki-key-export-spki-key-p521.html	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a P-521 SPKI ECDH key and exporting it in SPKI format");
+
+jsTestIsAsync = true;
+
+var spkiKeyHex = "30819b301006072a8648ce3d020106052b81040023038186000400e9a76aed2acda29ba2a5dbdc1f04c6160bc16c6d16b737a557f9dcbc8efb79dd1b9eabfc0a911ea3fd574176e2cbf32caa9babb505b04f30ecf369e6bec91d1ac201a8aa718c0c293b085d7902a314cab6e8048e458cc28c7da4fff2fcbf3da6d42fee94de5e0a3fb34342780e3f9df7b424911d6efb8628079566b50efe6971271eea";
+var spkiKey = hexStringToUint8Array(spkiKeyHex);
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("spki", spkiKey, {name: "ECDH", namedCurve: "P-521"}, extractable, [ ]).then(function(key) {
+    return crypto.subtle.exportKey("spki", key);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe("bytesToHexString(publicKey)", "spkiKeyHex");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/crypto/subtle/ecdh-derive-bits-length-limits-expected.txt (221344 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdh-derive-bits-length-limits-expected.txt	2017-08-30 06:59:57 UTC (rev 221344)
+++ trunk/LayoutTests/crypto/subtle/ecdh-derive-bits-length-limits-expected.txt	2017-08-30 07:31:32 UTC (rev 221345)
@@ -13,6 +13,7 @@
 PASS deriveBits(..., 384) successfully derived 384 bits for a P-384 curve
 PASS Bit derivations for EC P-384 with minimum and maximum lengths succeeded
 PASS deriveBits(P384, 384 + 8) rejected promise  with OperationError: The operation failed for an operation-specific reason.
+Bit derivations for EC P-521 skipped, likely due to missing P-521 supprot.
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/crypto/subtle/ecdh-derive-bits-length-limits.html (221344 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdh-derive-bits-length-limits.html	2017-08-30 06:59:57 UTC (rev 221344)
+++ trunk/LayoutTests/crypto/subtle/ecdh-derive-bits-length-limits.html	2017-08-30 07:31:32 UTC (rev 221345)
@@ -40,9 +40,23 @@
     x: "H9zo2G4WwHFSUqdN7jaChKg5fdmBxRLMP-_xWbcGDd4GzQBZBS72qKU_W-NLMoh_",
     y: "-VBlr88R42IGLDBvzFeUvH1cjPOlIxWgnfa6NzhKcYZQXFi9vFq4sdJX5cQfnc6H",
 };
+var jwkPrivateKeyP521 = {
+    kty: "EC",
+    crv: "P-521",
+    x: "AS3DmGl2O2u7YZbWpvIs7ab1tbAeQ_8PiYeB5Z7wgUulyVu4UHx15WU2SSKfqYvA8acaeiyK9zJ8gmXLZaKtwbFT",
+    y: "AEZSN9F_AQY_2Hk_DJhoVStuno4av3HkVaNcBAfPj-oodz9vcNSnxHfvO2C6NqszPnrJArY-xXmHfNDAYm7PARcR",
+    d: "AW4mYMpythEq-e7zcVH4c_kEV5q2Qnlg854I9rKTkudG_35NqHixOh8Y1GhMsXzHhlpa-QMPo34Zd5OcT9XkTB-s",
+};
+var jwkPublicKeyP521 = {
+    kty: "EC",
+    crv: "P-521",
+    x: "AS3DmGl2O2u7YZbWpvIs7ab1tbAeQ_8PiYeB5Z7wgUulyVu4UHx15WU2SSKfqYvA8acaeiyK9zJ8gmXLZaKtwbFT",
+    y: "AEZSN9F_AQY_2Hk_DJhoVStuno4av3HkVaNcBAfPj-oodz9vcNSnxHfvO2C6NqszPnrJArY-xXmHfNDAYm7PARcR",
+};
 
 var P256 = { curveName: "P-256" };
 var P384 = { curveName: "P-384" };
+var P521 = { curveName: "P-521" };
 
 crypto.subtle.importKey("jwk", jwkPrivateKeyP256, { name: "ECDH", namedCurve: "P-256" }, extractable, ["deriveBits"]).then(function(result) {
     P256.privateKey = result;
@@ -88,6 +102,25 @@
             testPassed("Bit derivations for EC P-384 with minimum and maximum lengths succeeded");
             return shouldReject('deriveBits(P384, 384 + 8)');
         });
+    }).then(function(result) {
+        return crypto.subtle.importKey("jwk", jwkPrivateKeyP521, { name: "ECDH", namedCurve: "P-521" }, extractable, ["deriveBits"]).then(function(result) {
+            P521.privateKey = result;
+            return crypto.subtle.importKey("jwk", jwkPublicKeyP521, { name: "ECDH", namedCurve: "P-521" }, extractable, [ ]);
+        }).then(function(result) {
+            P521.publicKey = result;
+
+            // P-521
+            return Promise.all([
+                deriveBits(P521, 0, 528),
+                deriveBits(P521, 8, 8),
+                deriveBits(P521, 528, 528),
+            ]).then(function(result) {
+                testPassed("Bit derivations for EC P-521 with minimum and maximum lengths succeeded");
+                return shouldReject('deriveBits(P521, 528 + 8)');
+            });
+        }, function(result) {
+            debug("Bit derivations for EC P-521 skipped, likely due to missing P-521 supprot.");
+        });
     });
 }).then(finishJSTest, finishJSTest);
 

Added: trunk/LayoutTests/crypto/subtle/ecdh-generate-export-jwk-key-p521-expected.txt (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdh-generate-export-jwk-key-p521-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-generate-export-jwk-key-p521-expected.txt	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,26 @@
+Test exporting a P-521 ECDH key pair with JWK format.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Generating a key pair...
+Exporting the public key...
+PASS publicKey.kty is 'EC'
+PASS publicKey.crv is 'P-521'
+PASS Base64URL.parse(publicKey.x).byteLength is 66
+PASS Base64URL.parse(publicKey.y).byteLength is 66
+PASS publicKey.d is undefined.
+PASS publicKey.key_ops is [ ]
+PASS publicKey.ext is true
+Exporting the private key...
+PASS privateKey.kty is 'EC'
+PASS privateKey.crv is 'P-521'
+PASS Base64URL.parse(privateKey.x).byteLength is 66
+PASS Base64URL.parse(privateKey.y).byteLength is 66
+PASS Base64URL.parse(privateKey.d).byteLength is 66
+PASS privateKey.key_ops is ['deriveBits', 'deriveKey']
+PASS privateKey.ext is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/crypto/subtle/ecdh-generate-export-jwk-key-p521.html (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdh-generate-export-jwk-key-p521.html	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-generate-export-jwk-key-p521.html	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test exporting a P-521 ECDH key pair with JWK format.");
+
+jsTestIsAsync = true;
+
+var algorithmKeyGen = {
+    name: "ECDH",
+    namedCurve: "P-521"
+};
+var extractable = true;
+
+var keyPair;
+debug("Generating a key pair...");
+crypto.subtle.generateKey(algorithmKeyGen, extractable, ["deriveKey", "deriveBits"]).then(function(result) {
+    keyPair = result;
+    debug("Exporting the public key...");
+    return crypto.subtle.exportKey("jwk", keyPair.publicKey);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe("publicKey.kty", "'EC'");
+    shouldBe("publicKey.crv", "'P-521'");
+    shouldBe("Base64URL.parse(publicKey.x).byteLength", "66");
+    shouldBe("Base64URL.parse(publicKey.y).byteLength", "66");
+    shouldBeUndefined("publicKey.d");
+    shouldBe("publicKey.key_ops", "[ ]");
+    shouldBe("publicKey.ext", "true");
+
+    debug("Exporting the private key...");
+    return crypto.subtle.exportKey("jwk", keyPair.privateKey);
+}).then(function(result) {
+    privateKey = result;
+
+    shouldBe("privateKey.kty", "'EC'");
+    shouldBe("privateKey.crv", "'P-521'");
+    shouldBe("Base64URL.parse(privateKey.x).byteLength", "66");
+    shouldBe("Base64URL.parse(privateKey.y).byteLength", "66");
+    shouldBe("Base64URL.parse(privateKey.d).byteLength", "66");
+    shouldBe("privateKey.key_ops", "['deriveBits', 'deriveKey']");
+    shouldBe("privateKey.ext", "true");
+
+    finishJSTest();
+});
+</script>
+
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-pkcs8-p521-expected.txt (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-pkcs8-p521-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-pkcs8-p521-expected.txt	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,12 @@
+Test exporting a P-521 ECDH private key with PKCS8 format.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Generating a key pair...
+Exporting the public key...
+PASS privateKey.byteLength is 241
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-pkcs8-p521.html (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-pkcs8-p521.html	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-pkcs8-p521.html	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test exporting a P-521 ECDH private key with PKCS8 format.");
+
+jsTestIsAsync = true;
+
+var algorithmKeyGen = {
+    name: "ECDH",
+    namedCurve: "P-521"
+};
+var extractable = true;
+
+var keyPair;
+debug("Generating a key pair...");
+crypto.subtle.generateKey(algorithmKeyGen, extractable, ["deriveKey", "deriveBits"]).then(function(result) {
+    keyPair = result;
+    debug("Exporting the public key...");
+    return crypto.subtle.exportKey("pkcs8", keyPair.privateKey);
+}).then(function(result) {
+    privateKey = result;
+
+    shouldBe("privateKey.byteLength", "241");
+
+    finishJSTest();
+});
+</script>
+
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-raw-p521-expected.txt (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-raw-p521-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-raw-p521-expected.txt	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,12 @@
+Test exporting a P-521 ECDH public key with raw format.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Generating a key pair...
+Exporting the public key...
+PASS publicKey.byteLength is 133
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-raw-p521.html (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-raw-p521.html	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-raw-p521.html	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test exporting a P-521 ECDH public key with raw format.");
+
+jsTestIsAsync = true;
+
+var algorithmKeyGen = {
+    name: "ECDH",
+    namedCurve: "P-521"
+};
+var extractable = true;
+
+var keyPair;
+debug("Generating a key pair...");
+crypto.subtle.generateKey(algorithmKeyGen, extractable, ["deriveKey", "deriveBits"]).then(function(result) {
+    keyPair = result;
+    debug("Exporting the public key...");
+    return crypto.subtle.exportKey("raw", keyPair.publicKey);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe("publicKey.byteLength", "133");
+
+    finishJSTest();
+});
+</script>
+
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-spki-p521-expected.txt (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-spki-p521-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-spki-p521-expected.txt	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,12 @@
+Test exporting a P-521 ECDH public key with SPKI format.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Generating a key pair...
+Exporting the public key...
+PASS publicKey.byteLength is 158
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-spki-p521.html (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-spki-p521.html	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-spki-p521.html	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test exporting a P-521 ECDH public key with SPKI format.");
+
+jsTestIsAsync = true;
+
+var algorithmKeyGen = {
+    name: "ECDH",
+    namedCurve: "P-521"
+};
+var extractable = true;
+
+var keyPair;
+debug("Generating a key pair...");
+crypto.subtle.generateKey(algorithmKeyGen, extractable, ["deriveKey", "deriveBits"]).then(function(result) {
+    keyPair = result;
+    debug("Exporting the public key...");
+    return crypto.subtle.exportKey("spki", keyPair.publicKey);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe("publicKey.byteLength", "158");
+
+    finishJSTest();
+});
+</script>
+
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/crypto/subtle/ecdh-generate-key-p521-expected.txt (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdh-generate-key-p521-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-generate-key-p521-expected.txt	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,21 @@
+Test generating an EC key pair with P-521 using ECDH algorithm.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Generating a key pair...
+PASS keyPair.toString() is '[object Object]'
+PASS keyPair.publicKey.type is 'public'
+PASS keyPair.publicKey.extractable is true
+PASS keyPair.publicKey.algorithm.name is 'ECDH'
+PASS keyPair.publicKey.algorithm.namedCurve is 'P-521'
+PASS keyPair.publicKey.usages is [ ]
+PASS keyPair.privateKey.type is 'private'
+PASS keyPair.privateKey.extractable is false
+PASS keyPair.privateKey.algorithm.name is 'ECDH'
+PASS keyPair.privateKey.algorithm.namedCurve is 'P-521'
+PASS keyPair.privateKey.usages is ['deriveBits', 'deriveKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/crypto/subtle/ecdh-generate-key-p521.html (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdh-generate-key-p521.html	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-generate-key-p521.html	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test generating an EC key pair with P-521 using ECDH algorithm.");
+
+jsTestIsAsync = true;
+
+var nonExtractable = false;
+
+debug("Generating a key pair...");
+crypto.subtle.generateKey({ name: "ECDH", namedCurve: "P-521"}, nonExtractable, ["deriveKey", "deriveBits"]).then(function(result) {
+    keyPair = result;
+    shouldBe("keyPair.toString()", "'[object Object]'");
+    shouldBe("keyPair.publicKey.type", "'public'");
+    shouldBe("keyPair.publicKey.extractable", "true");
+    shouldBe("keyPair.publicKey.algorithm.name", "'ECDH'");
+    shouldBe("keyPair.publicKey.algorithm.namedCurve", "'P-521'");
+    shouldBe("keyPair.publicKey.usages", "[ ]");
+    shouldBe("keyPair.privateKey.type", "'private'");
+    shouldBe("keyPair.privateKey.extractable", "false");
+    shouldBe("keyPair.privateKey.algorithm.name", "'ECDH'");
+    shouldBe("keyPair.privateKey.algorithm.namedCurve", "'P-521'");
+    shouldBe("keyPair.privateKey.usages", "['deriveBits', 'deriveKey']");
+
+    finishJSTest();
+});
+</script>
+
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-private-key-p521-expected.txt (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-private-key-p521-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-private-key-p521-expected.txt	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,16 @@
+Test importing a JWK ECDH private key with P-521
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS privateKey.toString() is '[object CryptoKey]'
+PASS privateKey.type is 'private'
+PASS privateKey.extractable is false
+PASS privateKey.algorithm.name is 'ECDH'
+PASS privateKey.algorithm.namedCurve is 'P-521'
+PASS privateKey.usages is ['deriveBits', 'deriveKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-private-key-p521.html (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-private-key-p521.html	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-private-key-p521.html	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK ECDH private key with P-521");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "EC",
+    use: "enc",
+    ext: false,
+    key_ops: ["deriveKey", "deriveBits"],
+    crv: "P-521",
+    x: "ATyYJNg6KbLelgL09FGKksW7qfIEPf4OPCHB7PuoUq4AyiJQaMqWD7TagGc4gwY5lJ7rDRLKGdxGmf19inAT_X1a",
+    y: "AAF1xys7jFj4QkHBC3uF_Kodak7rOkbmpAPKrqzR_akXaCwNfdsjX12_uVkDhyUqF-C5oUYsKLqET8RMm8kg8cX9",
+    d: "APLcP3zg0beau_cHUhnqmoeduWOKTh3Ki7shV0NxvrXTIp4pCUv3RX6do19RD7c4Goh3EGO3UJ9FdhzbeNLzYmmH",
+};
+var nonExtractable = false;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, { name: "ECDH", namedCurve: "P-521" }, nonExtractable, ["deriveKey", "deriveBits"]).then(function(result) {
+    privateKey = result;
+
+    shouldBe("privateKey.toString()", "'[object CryptoKey]'");
+    shouldBe("privateKey.type", "'private'");
+    shouldBe("privateKey.extractable", "false");
+    shouldBe("privateKey.algorithm.name", "'ECDH'");
+    shouldBe("privateKey.algorithm.namedCurve", "'P-521'");
+    shouldBe("privateKey.usages", "['deriveBits', 'deriveKey']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-public-key-p521-expected.txt (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-public-key-p521-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-public-key-p521-expected.txt	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,16 @@
+Test importing a JWK ECDH public key with P-521
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS publicKey.toString() is '[object CryptoKey]'
+PASS publicKey.type is 'public'
+PASS publicKey.extractable is true
+PASS publicKey.algorithm.name is 'ECDH'
+PASS publicKey.algorithm.namedCurve is 'P-521'
+PASS publicKey.usages is [ ]
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-public-key-p521.html (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-public-key-p521.html	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-public-key-p521.html	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a JWK ECDH public key with P-521");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "EC",
+    use: "enc",
+    ext: true,
+    crv: "P-521",
+    x: "ATyYJNg6KbLelgL09FGKksW7qfIEPf4OPCHB7PuoUq4AyiJQaMqWD7TagGc4gwY5lJ7rDRLKGdxGmf19inAT_X1a",
+    y: "AAF1xys7jFj4QkHBC3uF_Kodak7rOkbmpAPKrqzR_akXaCwNfdsjX12_uVkDhyUqF-C5oUYsKLqET8RMm8kg8cX9",
+};
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, { name: "ECDH", namedCurve: "P-521" }, extractable, [ ]).then(function(result) {
+    publicKey = result;
+
+    shouldBe("publicKey.toString()", "'[object CryptoKey]'");
+    shouldBe("publicKey.type", "'public'");
+    shouldBe("publicKey.extractable", "true");
+    shouldBe("publicKey.algorithm.name", "'ECDH'");
+    shouldBe("publicKey.algorithm.namedCurve", "'P-521'");
+    shouldBe("publicKey.usages", "[ ]");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/crypto/subtle/ecdh-import-pkcs8-key-p521-expected.txt (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdh-import-pkcs8-key-p521-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-pkcs8-key-p521-expected.txt	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,16 @@
+Test importing a P-521 PKCS8 ECDH key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS publicKey.toString() is '[object CryptoKey]'
+PASS publicKey.type is 'private'
+PASS publicKey.extractable is true
+PASS publicKey.algorithm.name is 'ECDH'
+PASS publicKey.algorithm.namedCurve is 'P-521'
+PASS publicKey.usages is [ 'deriveBits', 'deriveKey' ]
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/crypto/subtle/ecdh-import-pkcs8-key-p521-validate-ecprivatekey-parameters-publickey-expected.txt (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdh-import-pkcs8-key-p521-validate-ecprivatekey-parameters-publickey-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-pkcs8-key-p521-validate-ecprivatekey-parameters-publickey-expected.txt	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,19 @@
+Test that importing P-521 EC keys for the ECDH algorithm through PKCS#8 fails in case of incorrect curve identifier or public key used in the ECPrivateKey structure
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+ECDH: importing P-521 key that uses matching curve identifiers and valid public key in ECParameters structures in PKCS#8 ...
+PASS Successfully imported a P-521 key.
+ECDH: importing P-521 key whose curve identifiers in ECParameters structures in PKCS#8 don't match ...
+PASS importKey(pkcs8P521KeyMismatchedCurveIdentifiers) rejected promise  with DataError: Data provided to an operation does not meet requirements.
+ECDH: importing P-521 key that has a public key in PKCS#8 of invalid length ...
+PASS importKey(pkcs8P521KeyInvalidPublicKeyLength) rejected promise  with DataError: Data provided to an operation does not meet requirements.
+ECDH: importing P-521 key that has a public key in PKCS#8 of invalid EC point format ...
+PASS importKey(pkcs8P521KeyInvalidPublicKeyECPointFormat) rejected promise  with DataError: Data provided to an operation does not meet requirements.
+ECDH: importing P-521 key that has an invalid public key in PKCS#8 ...
+PASS importKey(pkcs8P521KeyInvalidPublicKey) rejected promise  with DataError: Data provided to an operation does not meet requirements.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/crypto/subtle/ecdh-import-pkcs8-key-p521-validate-ecprivatekey-parameters-publickey.html (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdh-import-pkcs8-key-p521-validate-ecprivatekey-parameters-publickey.html	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-pkcs8-key-p521-validate-ecprivatekey-parameters-publickey.html	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test that importing P-521 EC keys for the ECDH algorithm through PKCS#8 fails in case of incorrect curve identifier or public key used in the ECPrivateKey structure");
+
+jsTestIsAsync = true;
+
+// Valid P-521 key that has matching named curve identifiers in ECParameters structures under
+// both AlgorithmIdentifier parameters and under ECPrivateKey parameters in the PKCS#8 structure,
+// as well as a valid public key under ECPrivateKey.
+var pkcs8P521ValidKey = hexStringToUint8Array("3081f7020100301006072a8648ce3d020106052b810400230481df3081dc02010104420160ccf72d28b6df9768c30f67e77a000ecdb6e20381d8ee6f5474d6a612c39b7f3d361e1e9901f4cc573dcfc7da3eeadcb3e10532ca12d39df5ed39a5156c3e3ceba00706052b81040023a18189038186000400e9a76aed2acda29ba2a5dbdc1f04c6160bc16c6d16b737a557f9dcbc8efb79dd1b9eabfc0a911ea3fd574176e2cbf32caa9babb505b04f30ecf369e6bec91d1ac201a8aa718c0c293b085d7902a314cab6e8048e458cc28c7da4fff2fcbf3da6d42fee94de5e0a3fb34342780e3f9df7b424911d6efb8628079566b50efe6971271eea");
+
+// Invalid P-521 key that has mismatched named curve identifiers in the mentioned ECParameters structures.
+var pkcs8P521KeyMismatchedCurveIdentifiers = hexStringToUint8Array("3081f7020100301006072a8648ce3d020106052b810400230481df3081dc02010104420160ccf72d28b6df9768c30f67e77a000ecdb6e20381d8ee6f5474d6a612c39b7f3d361e1e9901f4cc573dcfc7da3eeadcb3e10532ca12d39df5ed39a5156c3e3ceba00706052b81040022a18189038186000400e9a76aed2acda29ba2a5dbdc1f04c6160bc16c6d16b737a557f9dcbc8efb79dd1b9eabfc0a911ea3fd574176e2cbf32caa9babb505b04f30ecf369e6bec91d1ac201a8aa718c0c293b085d7902a314cab6e8048e458cc28c7da4fff2fcbf3da6d42fee94de5e0a3fb34342780e3f9df7b424911d6efb8628079566b50efe6971271eea");
+
+// Invalid P-521 key that has a public key of invalid length (its last byte is clipped).
+var pkcs8P521KeyInvalidPublicKeyLength = hexStringToUint8Array("3081f6020100301006072a8648ce3d020106052b810400230481de3081db02010104420160ccf72d28b6df9768c30f67e77a000ecdb6e20381d8ee6f5474d6a612c39b7f3d361e1e9901f4cc573dcfc7da3eeadcb3e10532ca12d39df5ed39a5156c3e3ceba00706052b81040023a18188038185000400e9a76aed2acda29ba2a5dbdc1f04c6160bc16c6d16b737a557f9dcbc8efb79dd1b9eabfc0a911ea3fd574176e2cbf32caa9babb505b04f30ecf369e6bec91d1ac201a8aa718c0c293b085d7902a314cab6e8048e458cc28c7da4fff2fcbf3da6d42fee94de5e0a3fb34342780e3f9df7b424911d6efb8628079566b50efe6971271eea");
+
+// Invalid P-521 key that has a public key of invalid EC point format (leading 0x05 byte instead of 0x04).
+var pkcs8P521KeyInvalidPublicKeyECPointFormat= hexStringToUint8Array("3081f7020100301006072a8648ce3d020106052b810400230481df3081dc02010104420160ccf72d28b6df9768c30f67e77a000ecdb6e20381d8ee6f5474d6a612c39b7f3d361e1e9901f4cc573dcfc7da3eeadcb3e10532ca12d39df5ed39a5156c3e3ceba00706052b81040023a18189038186000500e9a76aed2acda29ba2a5dbdc1f04c6160bc16c6d16b737a557f9dcbc8efb79dd1b9eabfc0a911ea3fd574176e2cbf32caa9babb505b04f30ecf369e6bec91d1ac201a8aa718c0c293b085d7902a314cab6e8048e458cc28c7da4fff2fcbf3da6d42fee94de5e0a3fb34342780e3f9df7b424911d6efb8628079566b50efe6971271eea");
+
+// Invalid P-521 key that has a public key of invalid value (0xabad1dea).
+var pkcs8P521KeyInvalidPublicKey = hexStringToUint8Array("3081f7020100301006072a8648ce3d020106052b810400230481df3081dc02010104420160ccf72d28b6df9768c30f67e77a000ecdb6e20381d8ee6f5474d6a612c39b7f3d361e1e9901f4cc573dcfc7da3eeadcb3e10532ca12d39df5ed39a5156c3e3ceba00706052b81040023a1818903818600040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000abad1dea");
+
+function importKey(keyData)
+{
+    return crypto.subtle.importKey("pkcs8", keyData, { name: "ECDH", namedCurve: "P-521" }, true, [ "deriveKey", "deriveBits" ]);
+}
+
+Promise.resolve().then(function(result) {
+    debug("ECDH: importing P-521 key that uses matching curve identifiers and valid public key in ECParameters structures in PKCS#8 ...");
+    return importKey(pkcs8P521ValidKey);
+}).then(function(result) {
+    testPassed("Successfully imported a P-521 key.");
+
+    debug("ECDH: importing P-521 key whose curve identifiers in ECParameters structures in PKCS#8 don't match ...");
+    return shouldReject('importKey(pkcs8P521KeyMismatchedCurveIdentifiers)');
+}).then(function(result) {
+    debug("ECDH: importing P-521 key that has a public key in PKCS#8 of invalid length ...");
+    return shouldReject('importKey(pkcs8P521KeyInvalidPublicKeyLength)');
+}).then(function(result) {
+    debug("ECDH: importing P-521 key that has a public key in PKCS#8 of invalid EC point format ...");
+    return shouldReject('importKey(pkcs8P521KeyInvalidPublicKeyECPointFormat)');
+}).then(function(result) {
+    debug("ECDH: importing P-521 key that has an invalid public key in PKCS#8 ...");
+    return shouldReject('importKey(pkcs8P521KeyInvalidPublicKey)');
+}).then(function(result) {
+    finishJSTest();
+});;
+
+</script>
+
+</body>
+</html>

Added: trunk/LayoutTests/crypto/subtle/ecdh-import-pkcs8-key-p521.html (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdh-import-pkcs8-key-p521.html	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-pkcs8-key-p521.html	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a P-521 PKCS8 ECDH key");
+
+jsTestIsAsync = true;
+
+var pkcs8Key = hexStringToUint8Array("3081ee020100301006072a8648ce3d020106052b810400230481d63081d302010104420160ccf72d28b6df9768c30f67e77a000ecdb6e20381d8ee6f5474d6a612c39b7f3d361e1e9901f4cc573dcfc7da3eeadcb3e10532ca12d39df5ed39a5156c3e3ceba18189038186000400e9a76aed2acda29ba2a5dbdc1f04c6160bc16c6d16b737a557f9dcbc8efb79dd1b9eabfc0a911ea3fd574176e2cbf32caa9babb505b04f30ecf369e6bec91d1ac201a8aa718c0c293b085d7902a314cab6e8048e458cc28c7da4fff2fcbf3da6d42fee94de5e0a3fb34342780e3f9df7b424911d6efb8628079566b50efe6971271eea");
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("pkcs8", pkcs8Key, {name: "ECDH", namedCurve: "P-521"}, extractable, ["deriveKey", "deriveBits"]).then(function(result) {
+    publicKey = result;
+
+    shouldBe("publicKey.toString()", "'[object CryptoKey]'");
+    shouldBe("publicKey.type", "'private'");
+    shouldBe("publicKey.extractable", "true");
+    shouldBe("publicKey.algorithm.name", "'ECDH'");
+    shouldBe("publicKey.algorithm.namedCurve", "'P-521'");
+    shouldBe("publicKey.usages", "[ 'deriveBits', 'deriveKey' ]");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/crypto/subtle/ecdh-import-raw-key-p521-expected.txt (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdh-import-raw-key-p521-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-raw-key-p521-expected.txt	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,16 @@
+Test importing an ECDH raw key with P-521
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS publicKey.toString() is '[object CryptoKey]'
+PASS publicKey.type is 'public'
+PASS publicKey.extractable is true
+PASS publicKey.algorithm.name is 'ECDH'
+PASS publicKey.algorithm.namedCurve is 'P-521'
+PASS publicKey.usages is [ ]
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/crypto/subtle/ecdh-import-raw-key-p521.html (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdh-import-raw-key-p521.html	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-raw-key-p521.html	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing an ECDH raw key with P-521");
+
+jsTestIsAsync = true;
+
+var rawKey = hexStringToUint8Array("0400e9a76aed2acda29ba2a5dbdc1f04c6160bc16c6d16b737a557f9dcbc8efb79dd1b9eabfc0a911ea3fd574176e2cbf32caa9babb505b04f30ecf369e6bec91d1ac201a8aa718c0c293b085d7902a314cab6e8048e458cc28c7da4fff2fcbf3da6d42fee94de5e0a3fb34342780e3f9df7b424911d6efb8628079566b50efe6971271eea");
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("raw", rawKey, { name: "ECDH", namedCurve: "P-521" }, extractable, [ ]).then(function(result) {
+    publicKey = result;
+
+    shouldBe("publicKey.toString()", "'[object CryptoKey]'");
+    shouldBe("publicKey.type", "'public'");
+    shouldBe("publicKey.extractable", "true");
+    shouldBe("publicKey.algorithm.name", "'ECDH'");
+    shouldBe("publicKey.algorithm.namedCurve", "'P-521'");
+    shouldBe("publicKey.usages", "[ ]");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/crypto/subtle/ecdh-import-spki-key-ecdh-identifier-expected.txt (221344 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdh-import-spki-key-ecdh-identifier-expected.txt	2017-08-30 06:59:57 UTC (rev 221344)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-spki-key-ecdh-identifier-expected.txt	2017-08-30 07:31:32 UTC (rev 221345)
@@ -1,4 +1,4 @@
-Test importing P-256 and P-384 SPKI ECDH keys that are using the ecDH algorithm identifier
+Test importing P-256, P-384 and P-521 SPKI ECDH keys that are using the ecDH algorithm identifier
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
@@ -17,6 +17,8 @@
 PASS publicKey.algorithm.name is 'ECDH'
 PASS publicKey.algorithm.namedCurve is 'P-384'
 PASS publicKey.usages is [ ]
+Importing a P-521 key that uses the ecDH algorithm identifier ...
+Importing EC P-521 key failed, likely due to missing P-521 support.
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/crypto/subtle/ecdh-import-spki-key-ecdh-identifier.html (221344 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdh-import-spki-key-ecdh-identifier.html	2017-08-30 06:59:57 UTC (rev 221344)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-spki-key-ecdh-identifier.html	2017-08-30 07:31:32 UTC (rev 221345)
@@ -9,12 +9,13 @@
 <div id="console"></div>
 
 <script>
-description("Test importing P-256 and P-384 SPKI ECDH keys that are using the ecDH algorithm identifier");
+description("Test importing P-256, P-384 and P-521 SPKI ECDH keys that are using the ecDH algorithm identifier");
 
 jsTestIsAsync = true;
 
 var spkiP256Key = hexStringToUint8Array("3057301106052b8104010c06082a8648ce3d03010703420004c3ee3a2c3380072b9b2a59fed2cada65121806e22c4f4f8a25e740fc3e54d75d86c200298e6dfc1611d185eedbdb3c2661b0eb0441f7fd57c90d08112e9ae71c");
 var spkiP384Key = hexStringToUint8Array("3074300e06052b8104010c06052b81040022036200044fe8f479a01b2d524d0f637add0391b733344a9eca4702359d42ad42acfd0632e77c855534e896828fec76318b3aa7f9745ed94a19a55152a4418cfdf277d3d706ddf3d443ee0710ac717ce85ba60e8fe29e7d8b3dfe0797c7eb47d2c19a86ca");
+var spkiP521Key = hexStringToUint8Array("30819b301006072a8648ce3d020106052b81040023038186000400e9a76aed2acda29ba2a5dbdc1f04c6160bc16c6d16b737a557f9dcbc8efb79dd1b9eabfc0a911ea3fd574176e2cbf32caa9babb505b04f30ecf369e6bec91d1ac201a8aa718c0c293b085d7902a314cab6e8048e458cc28c7da4fff2fcbf3da6d42fee94de5e0a3fb34342780e3f9df7b424911d6efb8628079566b50efe6971271eea");
 var extractable = true;
 
 Promise.resolve().then(function(result) {
@@ -42,7 +43,22 @@
     shouldBe("publicKey.algorithm.namedCurve", "'P-384'");
     shouldBe("publicKey.usages", "[ ]");
 
+    debug("Importing a P-521 key that uses the ecDH algorithm identifier ...");
+    return crypto.subtle.importKey("spki", spkiP521Key, {name: "ECDH", namedCurve: "P-521"}, extractable, [ ]);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe("publicKey.toString()", "'[object CryptoKey]'");
+    shouldBe("publicKey.type", "'public'");
+    shouldBe("publicKey.extractable", "true");
+    shouldBe("publicKey.algorithm.name", "'ECDH'");
+    shouldBe("publicKey.algorithm.namedCurve", "'P-521'");
+    shouldBe("publicKey.usages", "[ ]");
+
     finishJSTest();
+}, function(result) {
+    debug("Importing EC P-521 key failed, likely due to missing P-521 support.");
+    finishJSTest();
 });
 
 </script>

Added: trunk/LayoutTests/crypto/subtle/ecdh-import-spki-key-p521-expected.txt (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdh-import-spki-key-p521-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-spki-key-p521-expected.txt	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,16 @@
+Test importing a P-521 SPKI ECDH key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS publicKey.toString() is '[object CryptoKey]'
+PASS publicKey.type is 'public'
+PASS publicKey.extractable is true
+PASS publicKey.algorithm.name is 'ECDH'
+PASS publicKey.algorithm.namedCurve is 'P-521'
+PASS publicKey.usages is [ ]
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/crypto/subtle/ecdh-import-spki-key-p521.html (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdh-import-spki-key-p521.html	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-spki-key-p521.html	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test importing a P-521 SPKI ECDH key");
+
+jsTestIsAsync = true;
+
+var spkiKey = hexStringToUint8Array("30819b301006072a8648ce3d020106052b81040023038186000400e9a76aed2acda29ba2a5dbdc1f04c6160bc16c6d16b737a557f9dcbc8efb79dd1b9eabfc0a911ea3fd574176e2cbf32caa9babb505b04f30ecf369e6bec91d1ac201a8aa718c0c293b085d7902a314cab6e8048e458cc28c7da4fff2fcbf3da6d42fee94de5e0a3fb34342780e3f9df7b424911d6efb8628079566b50efe6971271eea");
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("spki", spkiKey, {name: "ECDH", namedCurve: "P-521"}, extractable, [ ]).then(function(result) {
+    publicKey = result;
+
+    shouldBe("publicKey.toString()", "'[object CryptoKey]'");
+    shouldBe("publicKey.type", "'public'");
+    shouldBe("publicKey.extractable", "true");
+    shouldBe("publicKey.algorithm.name", "'ECDH'");
+    shouldBe("publicKey.algorithm.namedCurve", "'P-521'");
+    shouldBe("publicKey.usages", "[ ]");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/crypto/subtle/ecdsa-generate-key-sign-verify-p521-expected.txt (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdsa-generate-key-sign-verify-p521-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdsa-generate-key-sign-verify-p521-expected.txt	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,14 @@
+Test ECDSA signing/verifying operations with generated P-521 keys
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Generating keys
+Signing
+PASS signature.byteLength is 132
+Verifying
+PASS verified is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/crypto/subtle/ecdsa-generate-key-sign-verify-p521.html (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdsa-generate-key-sign-verify-p521.html	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdsa-generate-key-sign-verify-p521.html	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script type="text/_javascript_">
+description("Test ECDSA signing/verifying operations with generated P-521 keys");
+
+jsTestIsAsync = true;
+
+var extractable = true;
+var ecdsaParams = {
+    name: "ECDSA",
+    hash: "SHA-256",
+}
+var data = "" World!");
+
+debug("Generating keys");
+crypto.subtle.generateKey({ name: "ECDSA", namedCurve: "P-521" }, extractable, ["sign", "verify"]).then(function(result) {
+    keyPair = result;
+
+    debug("Signing");
+    return crypto.subtle.sign(ecdsaParams, keyPair.privateKey, data);
+}).then(function(result) {
+    signature = result;
+
+    shouldBe("signature.byteLength", "132");
+
+    debug("Verifying");
+    return crypto.subtle.verify(ecdsaParams, keyPair.publicKey, signature, data);
+}).then(function(result) {
+    verified = result;
+
+    shouldBeTrue("verified");
+
+    finishJSTest();
+}, failAndFinishJSTest);
+</script>
+
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/crypto/subtle/ecdsa-import-jwk-public-key-alg-521-expected.txt (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdsa-import-jwk-public-key-alg-521-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdsa-import-jwk-public-key-alg-521-expected.txt	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,16 @@
+Test importing a JWK ECDSA public key with ES521
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing a key...
+PASS publicKey.toString() is '[object CryptoKey]'
+PASS publicKey.type is 'public'
+PASS publicKey.extractable is true
+PASS publicKey.algorithm.name is 'ECDSA'
+PASS publicKey.algorithm.namedCurve is 'P-521'
+PASS publicKey.usages is ['verify']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/crypto/subtle/ecdsa-import-jwk-public-key-alg-521.html (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdsa-import-jwk-public-key-alg-521.html	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdsa-import-jwk-public-key-alg-521.html	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script type="text/_javascript_">
+description("Test importing a JWK ECDSA public key with ES521");
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: "EC",
+    use: "sig",
+    ext: true,
+    crv: "P-521",
+    x: "ATyYJNg6KbLelgL09FGKksW7qfIEPf4OPCHB7PuoUq4AyiJQaMqWD7TagGc4gwY5lJ7rDRLKGdxGmf19inAT_X1a",
+    y: "AAF1xys7jFj4QkHBC3uF_Kodak7rOkbmpAPKrqzR_akXaCwNfdsjX12_uVkDhyUqF-C5oUYsKLqET8RMm8kg8cX9",
+    alg: "ES512"
+};
+var extractable = true;
+
+debug("Importing a key...");
+crypto.subtle.importKey("jwk", jwkKey, { name: "ECDSA", namedCurve: "P-521" }, extractable, ['verify']).then(function(result) {
+    publicKey = result;
+
+    shouldBe("publicKey.toString()", "'[object CryptoKey]'");
+    shouldBe("publicKey.type", "'public'");
+    shouldBe("publicKey.extractable", "true");
+    shouldBe("publicKey.algorithm.name", "'ECDSA'");
+    shouldBe("publicKey.algorithm.namedCurve", "'P-521'");
+    shouldBe("publicKey.usages", "['verify']");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/crypto/subtle/ecdsa-import-key-sign-p521-expected.txt (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdsa-import-key-sign-p521-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdsa-import-key-sign-p521-expected.txt	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,10 @@
+Test ECDSA signing operation with a P-521 private key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS signature.byteLength is 132
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/crypto/subtle/ecdsa-import-key-sign-p521.html (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdsa-import-key-sign-p521.html	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdsa-import-key-sign-p521.html	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script type="text/_javascript_">
+description("Test ECDSA signing operation with a P-521 private key");
+
+jsTestIsAsync = true;
+
+var extractable = true;
+var jwkPrivateKey = {
+    kty: "EC",
+    crv: "P-521",
+    x: "ATyYJNg6KbLelgL09FGKksW7qfIEPf4OPCHB7PuoUq4AyiJQaMqWD7TagGc4gwY5lJ7rDRLKGdxGmf19inAT_X1a",
+    y: "AAF1xys7jFj4QkHBC3uF_Kodak7rOkbmpAPKrqzR_akXaCwNfdsjX12_uVkDhyUqF-C5oUYsKLqET8RMm8kg8cX9",
+    d: "APLcP3zg0beau_cHUhnqmoeduWOKTh3Ki7shV0NxvrXTIp4pCUv3RX6do19RD7c4Goh3EGO3UJ9FdhzbeNLzYmmH",
+};
+var ecdsaParams = {
+    name: "ECDSA",
+    hash: "SHA-256",
+}
+var data = "" World!");
+
+crypto.subtle.importKey("jwk", jwkPrivateKey, { name: "ECDSA", namedCurve: "P-521" }, extractable, ["sign"]).then(function(key) {
+    return crypto.subtle.sign(ecdsaParams, key, data);
+}).then(function(result) {
+    signature = result;
+
+    shouldBe("signature.byteLength", "132");
+
+    finishJSTest();
+}, failAndFinishJSTest);
+
+</script>
+
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/crypto/subtle/ecdsa-import-key-verify-p521-expected.txt (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdsa-import-key-verify-p521-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdsa-import-key-verify-p521-expected.txt	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,10 @@
+Test ECDSA verifying operation with a P-521 public key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS verified is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/crypto/subtle/ecdsa-import-key-verify-p521.html (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdsa-import-key-verify-p521.html	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdsa-import-key-verify-p521.html	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script type="text/_javascript_">
+description("Test ECDSA verifying operation with a P-521 public key");
+
+jsTestIsAsync = true;
+
+var extractable = true;
+var jwkPublicKey = {
+    kty: "EC",
+    crv: "P-521",
+    x: "ATyYJNg6KbLelgL09FGKksW7qfIEPf4OPCHB7PuoUq4AyiJQaMqWD7TagGc4gwY5lJ7rDRLKGdxGmf19inAT_X1a",
+    y: "AAF1xys7jFj4QkHBC3uF_Kodak7rOkbmpAPKrqzR_akXaCwNfdsjX12_uVkDhyUqF-C5oUYsKLqET8RMm8kg8cX9",
+};
+var ecdsaParams = {
+    name: "ECDSA",
+    hash: "SHA-256",
+}
+var data = "" World!");
+var signature = hexStringToUint8Array("013f4994b96ea2d6ce58e70bde70717f00891194c91acb9ad6e6897b7769d837d3ed2695dd3de6f5e06413310a4e8b0aad83873ca7359584958a2d1ec1dad86a841c008961578f7cc2fb15703f614854921b7b5fff7ee38cacd37744419213582328903cb7c44d9c08378c5e1e70edabac439d3490680e9e1225f7c377bd44311717bdaa");
+
+crypto.subtle.importKey("jwk", jwkPublicKey, { name: "ECDSA", namedCurve: "P-521" }, extractable, ["verify"]).then(function(key) {
+    return crypto.subtle.verify(ecdsaParams, key, signature, data);
+}).then(function(result) {
+    verified = result;
+
+    shouldBeTrue("verified");
+
+    finishJSTest();
+}, failAndFinishJSTest);
+
+</script>
+
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/crypto/subtle/ecdsa-import-pkcs8-key-p521-validate-ecprivatekey-parameters-publickey-expected.txt (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdsa-import-pkcs8-key-p521-validate-ecprivatekey-parameters-publickey-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdsa-import-pkcs8-key-p521-validate-ecprivatekey-parameters-publickey-expected.txt	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,19 @@
+Test that importing P-521 EC keys for the ECDSA algorithm through PKCS#8 fails in case of incorrect curve identifier or public key used in the ECPrivateKey structure
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+ECDSA: importing P-521 key that uses matching curve identifiers and valid public key in ECParameters structures in PKCS#8 ...
+PASS Successfully imported a P-521 key.
+ECDSA: importing P-521 key whose curve identifiers in ECParameters structures in PKCS#8 don't match ...
+PASS importKey(pkcs8P521KeyMismatchedCurveIdentifiers) rejected promise  with DataError: Data provided to an operation does not meet requirements.
+ECDSA: importing P-521 key that has a public key in PKCS#8 of invalid length ...
+PASS importKey(pkcs8P521KeyInvalidPublicKeyLength) rejected promise  with DataError: Data provided to an operation does not meet requirements.
+ECDSA: importing P-521 key that has a public key in PKCS#8 of invalid EC point format ...
+PASS importKey(pkcs8P521KeyInvalidPublicKeyECPointFormat) rejected promise  with DataError: Data provided to an operation does not meet requirements.
+ECDSA: importing P-521 key that has an invalid public key in PKCS#8 ...
+PASS importKey(pkcs8P521KeyInvalidPublicKey) rejected promise  with DataError: Data provided to an operation does not meet requirements.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/crypto/subtle/ecdsa-import-pkcs8-key-p521-validate-ecprivatekey-parameters-publickey.html (0 => 221345)


--- trunk/LayoutTests/crypto/subtle/ecdsa-import-pkcs8-key-p521-validate-ecprivatekey-parameters-publickey.html	                        (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdsa-import-pkcs8-key-p521-validate-ecprivatekey-parameters-publickey.html	2017-08-30 07:31:32 UTC (rev 221345)
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test that importing P-521 EC keys for the ECDSA algorithm through PKCS#8 fails in case of incorrect curve identifier or public key used in the ECPrivateKey structure");
+
+jsTestIsAsync = true;
+
+// Valid P-521 key that has matching named curve identifiers in ECParameters structures under
+// both AlgorithmIdentifier parameters and under ECPrivateKey parameters in the PKCS#8 structure,
+// as well as a valid public key under ECPrivateKey.
+var pkcs8P521ValidKey = hexStringToUint8Array("3081f7020100301006072a8648ce3d020106052b810400230481df3081dc02010104420160ccf72d28b6df9768c30f67e77a000ecdb6e20381d8ee6f5474d6a612c39b7f3d361e1e9901f4cc573dcfc7da3eeadcb3e10532ca12d39df5ed39a5156c3e3ceba00706052b81040023a18189038186000400e9a76aed2acda29ba2a5dbdc1f04c6160bc16c6d16b737a557f9dcbc8efb79dd1b9eabfc0a911ea3fd574176e2cbf32caa9babb505b04f30ecf369e6bec91d1ac201a8aa718c0c293b085d7902a314cab6e8048e458cc28c7da4fff2fcbf3da6d42fee94de5e0a3fb34342780e3f9df7b424911d6efb8628079566b50efe6971271eea");
+
+// Invalid P-521 key that has mismatched named curve identifiers in the mentioned ECParameters structures.
+var pkcs8P521KeyMismatchedCurveIdentifiers = hexStringToUint8Array("3081f7020100301006072a8648ce3d020106052b810400230481df3081dc02010104420160ccf72d28b6df9768c30f67e77a000ecdb6e20381d8ee6f5474d6a612c39b7f3d361e1e9901f4cc573dcfc7da3eeadcb3e10532ca12d39df5ed39a5156c3e3ceba00706052b81040022a18189038186000400e9a76aed2acda29ba2a5dbdc1f04c6160bc16c6d16b737a557f9dcbc8efb79dd1b9eabfc0a911ea3fd574176e2cbf32caa9babb505b04f30ecf369e6bec91d1ac201a8aa718c0c293b085d7902a314cab6e8048e458cc28c7da4fff2fcbf3da6d42fee94de5e0a3fb34342780e3f9df7b424911d6efb8628079566b50efe6971271eea");
+
+// Invalid P-521 key that has a public key of invalid length (its last byte is clipped).
+var pkcs8P521KeyInvalidPublicKeyLength = hexStringToUint8Array("3081f6020100301006072a8648ce3d020106052b810400230481de3081db02010104420160ccf72d28b6df9768c30f67e77a000ecdb6e20381d8ee6f5474d6a612c39b7f3d361e1e9901f4cc573dcfc7da3eeadcb3e10532ca12d39df5ed39a5156c3e3ceba00706052b81040023a18188038185000400e9a76aed2acda29ba2a5dbdc1f04c6160bc16c6d16b737a557f9dcbc8efb79dd1b9eabfc0a911ea3fd574176e2cbf32caa9babb505b04f30ecf369e6bec91d1ac201a8aa718c0c293b085d7902a314cab6e8048e458cc28c7da4fff2fcbf3da6d42fee94de5e0a3fb34342780e3f9df7b424911d6efb8628079566b50efe6971271eea");
+
+// Invalid P-521 key that has a public key of invalid EC point format (leading 0x05 byte instead of 0x04).
+var pkcs8P521KeyInvalidPublicKeyECPointFormat= hexStringToUint8Array("3081f7020100301006072a8648ce3d020106052b810400230481df3081dc02010104420160ccf72d28b6df9768c30f67e77a000ecdb6e20381d8ee6f5474d6a612c39b7f3d361e1e9901f4cc573dcfc7da3eeadcb3e10532ca12d39df5ed39a5156c3e3ceba00706052b81040023a18189038186000500e9a76aed2acda29ba2a5dbdc1f04c6160bc16c6d16b737a557f9dcbc8efb79dd1b9eabfc0a911ea3fd574176e2cbf32caa9babb505b04f30ecf369e6bec91d1ac201a8aa718c0c293b085d7902a314cab6e8048e458cc28c7da4fff2fcbf3da6d42fee94de5e0a3fb34342780e3f9df7b424911d6efb8628079566b50efe6971271eea");
+
+// Invalid P-521 key that has a public key of invalid value (0xabad1dea).
+var pkcs8P521KeyInvalidPublicKey = hexStringToUint8Array("3081f7020100301006072a8648ce3d020106052b810400230481df3081dc02010104420160ccf72d28b6df9768c30f67e77a000ecdb6e20381d8ee6f5474d6a612c39b7f3d361e1e9901f4cc573dcfc7da3eeadcb3e10532ca12d39df5ed39a5156c3e3ceba00706052b81040023a1818903818600040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000abad1dea");
+
+function importKey(keyData)
+{
+    return crypto.subtle.importKey("pkcs8", keyData, { name: "ECDSA", namedCurve: "P-521" }, true, [ "sign" ]);
+}
+
+Promise.resolve().then(function(result) {
+    debug("ECDSA: importing P-521 key that uses matching curve identifiers and valid public key in ECParameters structures in PKCS#8 ...");
+    return importKey(pkcs8P521ValidKey);
+}).then(function(result) {
+    testPassed("Successfully imported a P-521 key.");
+
+    debug("ECDSA: importing P-521 key whose curve identifiers in ECParameters structures in PKCS#8 don't match ...");
+    return shouldReject('importKey(pkcs8P521KeyMismatchedCurveIdentifiers)');
+}).then(function(result) {
+    debug("ECDSA: importing P-521 key that has a public key in PKCS#8 of invalid length ...");
+    return shouldReject('importKey(pkcs8P521KeyInvalidPublicKeyLength)');
+}).then(function(result) {
+    debug("ECDSA: importing P-521 key that has a public key in PKCS#8 of invalid EC point format ...");
+    return shouldReject('importKey(pkcs8P521KeyInvalidPublicKeyECPointFormat)');
+}).then(function(result) {
+    debug("ECDSA: importing P-521 key that has an invalid public key in PKCS#8 ...");
+    return shouldReject('importKey(pkcs8P521KeyInvalidPublicKey)');
+}).then(function(result) {
+    finishJSTest();
+});;
+
+</script>
+
+</body>
+</html>

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (221344 => 221345)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2017-08-30 06:59:57 UTC (rev 221344)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2017-08-30 07:31:32 UTC (rev 221345)
@@ -783,6 +783,26 @@
 crypto/workers/subtle/rsa-pss-import-key-sign.html [ Pass ]
 crypto/workers/subtle/rsa-pss-import-key-verify.html [ Pass ]
 
+# Missing support for 521-bit elliptic curves.
+webkit.org/b/175199 crypto/subtle/ec-import-pkcs8-key-export-pkcs8-key-p521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ec-import-spki-key-export-spki-key-p521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdh-generate-export-jwk-key-p521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdh-generate-export-key-pkcs8-p521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdh-generate-export-key-raw-p521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdh-generate-export-key-spki-p521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdh-generate-key-p521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdh-import-jwk-private-key-p521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdh-import-jwk-public-key-p521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdh-import-pkcs8-key-p521-validate-ecprivatekey-parameters-publickey.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdh-import-pkcs8-key-p521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdh-import-raw-key-p521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdh-import-spki-key-p521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdsa-generate-key-sign-verify-p521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdsa-import-jwk-public-key-alg-521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdsa-import-key-sign-p521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdsa-import-key-verify-p521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdsa-import-pkcs8-key-p521-validate-ecprivatekey-parameters-publickey.html [ Skip ]
+
 # libgcrypt-based implementation supports ecDH algorithm identifier for ECDH SPKI imports.
 crypto/subtle/ecdh-import-spki-key-ecdh-identifier.html [ Pass ]
 

Modified: trunk/LayoutTests/platform/ios/TestExpectations (221344 => 221345)


--- trunk/LayoutTests/platform/ios/TestExpectations	2017-08-30 06:59:57 UTC (rev 221344)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2017-08-30 07:31:32 UTC (rev 221345)
@@ -2881,3 +2881,23 @@
 fast/text/font-lookup-dot-prefix-case-sensitive.html [ Pass ]
 
 webkit.org/b/172518 http/tests/preload/viewport/meta-viewport-link-headers.php [ Pass Failure ]
+
+# Missing support for 521-bit elliptic curves.
+crypto/subtle/ec-import-pkcs8-key-export-pkcs8-key-p521.html
+crypto/subtle/ec-import-spki-key-export-spki-key-p521.html
+crypto/subtle/ecdh-generate-export-jwk-key-p521.html
+crypto/subtle/ecdh-generate-export-key-pkcs8-p521.html
+crypto/subtle/ecdh-generate-export-key-raw-p521.html
+crypto/subtle/ecdh-generate-export-key-spki-p521.html
+crypto/subtle/ecdh-generate-key-p521.html
+crypto/subtle/ecdh-import-jwk-private-key-p521.html
+crypto/subtle/ecdh-import-jwk-public-key-p521.html
+crypto/subtle/ecdh-import-pkcs8-key-p521-validate-ecprivatekey-parameters-publickey.html
+crypto/subtle/ecdh-import-pkcs8-key-p521.html
+crypto/subtle/ecdh-import-raw-key-p521.html
+crypto/subtle/ecdh-import-spki-key-p521.html
+crypto/subtle/ecdsa-generate-key-sign-verify-p521.html
+crypto/subtle/ecdsa-import-jwk-public-key-alg-521.html
+crypto/subtle/ecdsa-import-key-sign-p521.html
+crypto/subtle/ecdsa-import-key-verify-p521.html
+crypto/subtle/ecdsa-import-pkcs8-key-p521-validate-ecprivatekey-parameters-publickey.html

Modified: trunk/LayoutTests/platform/mac/TestExpectations (221344 => 221345)


--- trunk/LayoutTests/platform/mac/TestExpectations	2017-08-30 06:59:57 UTC (rev 221344)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2017-08-30 07:31:32 UTC (rev 221345)
@@ -1614,3 +1614,22 @@
 
 webkit.org/b/173780 [ Debug ] imported/w3c/web-platform-tests/html/webappapis/timers/type-long-settimeout.html [ Pass Failure ]
 
+# Missing support for 521-bit elliptic curves.
+crypto/subtle/ec-import-pkcs8-key-export-pkcs8-key-p521.html
+crypto/subtle/ec-import-spki-key-export-spki-key-p521.html
+crypto/subtle/ecdh-generate-export-jwk-key-p521.html
+crypto/subtle/ecdh-generate-export-key-pkcs8-p521.html
+crypto/subtle/ecdh-generate-export-key-raw-p521.html
+crypto/subtle/ecdh-generate-export-key-spki-p521.html
+crypto/subtle/ecdh-generate-key-p521.html
+crypto/subtle/ecdh-import-jwk-private-key-p521.html
+crypto/subtle/ecdh-import-jwk-public-key-p521.html
+crypto/subtle/ecdh-import-pkcs8-key-p521-validate-ecprivatekey-parameters-publickey.html
+crypto/subtle/ecdh-import-pkcs8-key-p521.html
+crypto/subtle/ecdh-import-raw-key-p521.html
+crypto/subtle/ecdh-import-spki-key-p521.html
+crypto/subtle/ecdsa-generate-key-sign-verify-p521.html
+crypto/subtle/ecdsa-import-jwk-public-key-alg-521.html
+crypto/subtle/ecdsa-import-key-sign-p521.html
+crypto/subtle/ecdsa-import-key-verify-p521.html
+crypto/subtle/ecdsa-import-pkcs8-key-p521-validate-ecprivatekey-parameters-publickey.html

Modified: trunk/LayoutTests/platform/wpe/TestExpectations (221344 => 221345)


--- trunk/LayoutTests/platform/wpe/TestExpectations	2017-08-30 06:59:57 UTC (rev 221344)
+++ trunk/LayoutTests/platform/wpe/TestExpectations	2017-08-30 07:31:32 UTC (rev 221345)
@@ -735,6 +735,26 @@
 crypto/workers/subtle/rsa-pss-import-key-sign.html [ Pass ]
 crypto/workers/subtle/rsa-pss-import-key-verify.html [ Pass ]
 
+# Missing support for 521-bit elliptic curves.
+webkit.org/b/175199 crypto/subtle/ec-import-pkcs8-key-export-pkcs8-key-p521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ec-import-spki-key-export-spki-key-p521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdh-generate-export-jwk-key-p521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdh-generate-export-key-pkcs8-p521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdh-generate-export-key-raw-p521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdh-generate-export-key-spki-p521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdh-generate-key-p521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdh-import-jwk-private-key-p521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdh-import-jwk-public-key-p521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdh-import-pkcs8-key-p521-validate-ecprivatekey-parameters-publickey.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdh-import-pkcs8-key-p521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdh-import-raw-key-p521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdh-import-spki-key-p521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdsa-generate-key-sign-verify-p521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdsa-import-jwk-public-key-alg-521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdsa-import-key-sign-p521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdsa-import-key-verify-p521.html [ Skip ]
+webkit.org/b/175199 crypto/subtle/ecdsa-import-pkcs8-key-p521-validate-ecprivatekey-parameters-publickey.html [ Skip ]
+
 # ENABLE_CSS_COMPOSITING
 Bug(WPE) transitions/blendmode-transitions.html [ Failure ]
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to