Index: LayoutTests/crypto/clone-ecKey-private.html |
diff --git a/LayoutTests/crypto/clone-rsaHashedKey-private.html b/LayoutTests/crypto/clone-ecKey-private.html |
similarity index 51% |
copy from LayoutTests/crypto/clone-rsaHashedKey-private.html |
copy to LayoutTests/crypto/clone-ecKey-private.html |
index 8c05815a700a927be3c0a8b551ec02a74727487a..997130470c96ae4b9e7991292a9f50438753cb6a 100644 |
--- a/LayoutTests/crypto/clone-rsaHashedKey-private.html |
+++ b/LayoutTests/crypto/clone-ecKey-private.html |
@@ -3,36 +3,38 @@ |
<head> |
<script src="../resources/js-test.js"></script> |
<script src="resources/common.js"></script> |
-<script src="resources/keys.js"></script> |
</head> |
<body> |
<p id="description"></p> |
<div id="console"></div> |
<script> |
-description("Tests structured cloning of RSA private keys (with a hash)"); |
+description("Tests structured cloning of EC private keys"); |
jsTestIsAsync = true; |
// Tests the 12 permutations of keys generated by: |
-// kPossibleAlgorithms x kPossibleExtractable x kPossibleKeyUsages x kPossibleKeyData x kPossibleHashAlgorithms |
+// kPossibleAlgorithms x kPossibleExtractable x kPossibleKeyUsages x kPossibleCurves |
// |
// For practical reasons these tests are not exhaustive. |
-var kPossibleAlgorithms = ['RSASSA-PKCS1-v1_5']; |
+var kPossibleAlgorithms = ['ECDSA']; |
var kPossibleExtractable = [true, false]; |
var kPossibleKeyUsages = [[], ['sign']]; |
-var kPossibleHashAlgorithms = ['SHA-1', 'SHA-256', 'SHA-512']; |
+var kPossibleNamedCurves = ['P-256', 'P-384', 'P-521']; |
-var kPossibleKeyData = [ |
- kKeyData.rsa1, |
- kKeyData.rsa4 |
-]; |
+// A mapping from curve name, to PKCS8 data (hex-encoded) for a valid private key. |
+var kKeyDataForCurve = { |
+ "P-256": "308187020100301306072A8648CE3D020106082A8648CE3D030107046D306B02010104201FE33950C5F461124AE992C2BDFDF1C73B1615F571BD567E60D19AA1F48CDF42A144034200047C110C66DCFDA807F6E69E45DDB3C74F69A1484D203E8DC5ADA8E9A9DD7CB3C70DF448986E51BDE5D1576F99901F9C2C6A806A47FD907643A72B835597EFC8C6", |
+ "P-384": "3081B6020100301006072A8648CE3D020106052B8104002204819E30819B0201010430A492CE8FA90084C227E1A32F7974D39E9FF67A7E8705EC3419B35FB607582BEBD461E0B1520AC76EC2DD4E9B63EBAE71A16403620004E55FEE6C49D8D523F5CE7BF9C0425CE4FF650708B7DE5CFB095901523979A7F042602DB30854735369813B5C3F5EF86828F59CC5DC509892A988D38A8E2519DE3D0C4FD0FBDB0993E38F18506C17606C5E24249246F1CE94983A5361C5BE983E", |
+ "P-521": "3081EE020100301006072A8648CE3D020106052B810400230481D63081D3020101044201BD56BD106118EDA246155BD43B42B8E13F0A6E25DD3BB376026FAB4DC92B6157BC6DFEC2D15DD3D0CF2A39AA68494042AF48BA9601118DA82C6F2108A3A203AD74A181890381860004012FBCAEFFA6A51F3EE4D3D2B51C5DEC6D7C726CA353FC014EA2BF7CFBB9B910D32CBFA6A00FE39B6CDB8946F22775398B2E233C0CF144D78C8A7742B5C7A3BB5D23009CDEF823DD7BF9A79E8CCEACD2E4527C231D0AE5967AF0958E931D7DDCCF2805A3E618DC3039FEC9FEBBD33052FE4C0FEE98F033106064982D88F4E03549D4A64D" |
+}; |
-function runTest(algorithmName, hashName, extractable, keyUsages, keyData) |
+function runTest(algorithmName, namedCurve, extractable, keyUsages) |
{ |
- var importData = hexStringToUint8Array(keyData.pkcs8); |
- var importAlgorithm = { name: algorithmName, hash: {name: hashName} }; |
+ var keyDataHex = kKeyDataForCurve[namedCurve]; |
+ var importData = hexStringToUint8Array(keyDataHex); |
+ var importAlgorithm = { name: algorithmName, namedCurve: namedCurve }; |
var results = {}; |
@@ -53,9 +55,7 @@ function runTest(algorithmName, hashName, extractable, keyUsages, keyData) |
shouldEvaluateAs("importedKey.type", "private"); |
shouldEvaluateAs("importedKey.extractable", extractable); |
shouldEvaluateAs("importedKey.algorithm.name", algorithmName); |
- shouldEvaluateAs("importedKey.algorithm.modulusLength", keyData.modulusLengthBits); |
- bytesShouldMatchHexString("importedKey.algorithm.publicExponent", keyData.publicExponent, importedKey.algorithm.publicExponent); |
- shouldEvaluateAs("importedKey.algorithm.hash.name", hashName); |
+ shouldEvaluateAs("importedKey.algorithm.namedCurve", namedCurve); |
shouldEvaluateAs("importedKey.usages.join(',')", keyUsages.join(",")); |
shouldNotBe("importedKey", "clonedKey"); |
@@ -64,15 +64,13 @@ function runTest(algorithmName, hashName, extractable, keyUsages, keyData) |
shouldEvaluateAs("clonedKey.type", "private"); |
shouldEvaluateAs("clonedKey.extractable", extractable); |
shouldEvaluateAs("clonedKey.algorithm.name", algorithmName); |
- shouldEvaluateAs("clonedKey.algorithm.modulusLength", keyData.modulusLengthBits); |
- bytesShouldMatchHexString("clonedKey.algorithm.publicExponent", keyData.publicExponent, clonedKey.algorithm.publicExponent); |
- shouldEvaluateAs("clonedKey.algorithm.hash.name", hashName); |
+ shouldEvaluateAs("clonedKey.algorithm.namedCurve", namedCurve); |
shouldEvaluateAs("clonedKey.usages.join(',')", keyUsages.join(",")); |
logSerializedKey(importedKey); |
if (extractable) |
- bytesShouldMatchHexString("Cloned key exported data", keyData.pkcs8, clonedKeyData); |
+ bytesShouldMatchHexString("Cloned key exported data", keyDataHex, clonedKeyData); |
debug(""); |
}); |
@@ -83,11 +81,9 @@ var lastPromise = Promise.resolve(null); |
kPossibleAlgorithms.forEach(function(algorithmName) { |
kPossibleExtractable.forEach(function(extractable) { |
kPossibleKeyUsages.forEach(function(keyUsages) { |
- kPossibleKeyData.forEach(function(keyData) { |
- kPossibleHashAlgorithms.forEach(function(hashName) { |
- lastPromise = lastPromise.then(runTest.bind(null, algorithmName, hashName, extractable, keyUsages, keyData)); |
- }); |
- }); |
+ kPossibleNamedCurves.forEach(function(namedCurve) { |
+ lastPromise = lastPromise.then(runTest.bind(null, algorithmName, namedCurve, extractable, keyUsages)); |
+ }); |
}); |
}); |
}); |