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

Unified Diff: LayoutTests/crypto/clone-ecKey-public.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/clone-ecKey-public.html
diff --git a/LayoutTests/crypto/clone-rsaHashedKey-public.html b/LayoutTests/crypto/clone-ecKey-public.html
similarity index 56%
copy from LayoutTests/crypto/clone-rsaHashedKey-public.html
copy to LayoutTests/crypto/clone-ecKey-public.html
index db010d2a4d8afb3edf4c066bb9b4bfafac802b25..c4a3f3edf4c6fa00dca4b2b76c69e4195f98200f 100644
--- a/LayoutTests/crypto/clone-rsaHashedKey-public.html
+++ b/LayoutTests/crypto/clone-ecKey-public.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 public keys (with a hash)");
+description("Tests structured cloning of EC public 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 = [[], ['verify']];
-var kPossibleHashAlgorithms = ['SHA-1', 'SHA-256', 'SHA-512'];
+var kPossibleNamedCurves = ['P-256', 'P-384', 'P-521'];
-var kPossibleKeyData = [
- kKeyData.rsa2,
- kKeyData.rsa3
-];
+// A mapping from curve name, to SPKI data (hex-encoded) for a valid public key.
+var kKeyDataForCurve = {
+ "P-256": "3059301306072A8648CE3D020106082A8648CE3D030107034200049CB0CF69303DAFC761D4E4687B4ECF039E6D34AB964AF80810D8D558A4A8D6F72D51233A1788920A86EE08A1962C79EFA317FB7879E297DAD2146DB995FA1C78",
+ "P-384": "3076301006072A8648CE3D020106052B81040022036200040874A2E0B8FF448F0E54321E27F4F1E64D064CDEB7D26F458C32E930120F4E57DC85C2693F977EED4A8ECC8DB981B4D91F69446DF4F4C6F5DE19003F45F891D0EBCD2FFFDB5C81C040E8D6994C43C7FEEDB98A4A31EDFB35E89A30013C3B9267",
+ "P-521": "30819B301006072A8648CE3D020106052B81040023038186000400F50A08703250C15F043C8C46E99783435245CF98F4F2694B0E2F8D029A514DD6F0B086D4ED892000CD5590107AAE69C4C0A7A95F7CF74E5770A07D5DB55BCE4AB400F2C770BAB8B9BE4CDB6ECD3DC26C698DA0D2599CEBF3D904F7F9CA3A55E64731810D73CD317264E50BABA4BC2860857E16D6CBB79501BC9E3A32BD172EA8A71DEE"
+};
-function runTest(algorithmName, hashName, extractable, keyUsages, keyData)
+function runTest(algorithmName, namedCurve, extractable, keyUsages)
{
- var importData = hexStringToUint8Array(keyData.spki);
- 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", "public");
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", "public");
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.spki, 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));
+ });
});
});
});

Powered by Google App Engine
This is Rietveld 408576698