Index: LayoutTests/crypto/clone-ecKey-private.html |
diff --git a/LayoutTests/crypto/clone-ecKey-private.html b/LayoutTests/crypto/clone-ecKey-private.html |
index 997130470c96ae4b9e7991292a9f50438753cb6a..bee675e5249f2901a4f7d98d23f8caa419de5082 100644 |
--- a/LayoutTests/crypto/clone-ecKey-private.html |
+++ b/LayoutTests/crypto/clone-ecKey-private.html |
@@ -13,14 +13,22 @@ description("Tests structured cloning of EC private keys"); |
jsTestIsAsync = true; |
-// Tests the 12 permutations of keys generated by: |
+// ECDSA and ECDH support different key usages. Pick either sign or deriveBits depending on the algorithm. |
+function signOrDeriveBits(algorithmName) { |
+ if (algorithmName == "ECDSA") |
+ return ['sign']; |
+ if (algorithmName == "ECDH") |
+ return ['deriveBits']; |
+} |
+ |
+// Tests the 24 permutations of keys generated by: |
// kPossibleAlgorithms x kPossibleExtractable x kPossibleKeyUsages x kPossibleCurves |
// |
// For practical reasons these tests are not exhaustive. |
-var kPossibleAlgorithms = ['ECDSA']; |
+var kPossibleAlgorithms = ['ECDSA', 'ECDH']; |
var kPossibleExtractable = [true, false]; |
-var kPossibleKeyUsages = [[], ['sign']]; |
+var kPossibleKeyUsages = [[], signOrDeriveBits]; |
var kPossibleNamedCurves = ['P-256', 'P-384', 'P-521']; |
// A mapping from curve name, to PKCS8 data (hex-encoded) for a valid private key. |
@@ -38,6 +46,9 @@ function runTest(algorithmName, namedCurve, extractable, keyUsages) |
var results = {}; |
+ if (typeof keyUsages == "function") |
+ keyUsages = keyUsages(algorithmName); |
+ |
return crypto.subtle.importKey('pkcs8', importData, importAlgorithm, extractable, keyUsages).then(function(importedKey) { |
results.importedKey = importedKey; |
importedKey.extraProperty = 'hi'; |