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

Unified Diff: LayoutTests/crypto/subtle/clone-ecKey-private.html

Issue 958353003: [WebCrypto] Move cloneKey test to respective algorithm directory (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 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: LayoutTests/crypto/subtle/clone-ecKey-private.html
diff --git a/LayoutTests/crypto/subtle/clone-ecKey-private.html b/LayoutTests/crypto/subtle/clone-ecKey-private.html
deleted file mode 100644
index 615f0ea5fc98ed78634a804f2fd3fd1e6d9073ef..0000000000000000000000000000000000000000
--- a/LayoutTests/crypto/subtle/clone-ecKey-private.html
+++ /dev/null
@@ -1,107 +0,0 @@
-<!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("Tests structured cloning of EC private keys");
-
-jsTestIsAsync = true;
-
-// 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 12 permutations of keys generated by:
-// kPossibleAlgorithms x kPossibleExtractable x kPossibleKeyUsages x kPossibleCurves
-//
-// For practical reasons these tests are not exhaustive.
-
-var kPossibleAlgorithms = ['ECDSA', 'ECDH'];
-var kPossibleExtractable = [true, false];
-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.
-var kKeyDataForCurve = {
- "P-256": "308187020100301306072A8648CE3D020106082A8648CE3D030107046D306B02010104201FE33950C5F461124AE992C2BDFDF1C73B1615F571BD567E60D19AA1F48CDF42A144034200047C110C66DCFDA807F6E69E45DDB3C74F69A1484D203E8DC5ADA8E9A9DD7CB3C70DF448986E51BDE5D1576F99901F9C2C6A806A47FD907643A72B835597EFC8C6",
- "P-384": "3081B6020100301006072A8648CE3D020106052B8104002204819E30819B0201010430A492CE8FA90084C227E1A32F7974D39E9FF67A7E8705EC3419B35FB607582BEBD461E0B1520AC76EC2DD4E9B63EBAE71A16403620004E55FEE6C49D8D523F5CE7BF9C0425CE4FF650708B7DE5CFB095901523979A7F042602DB30854735369813B5C3F5EF86828F59CC5DC509892A988D38A8E2519DE3D0C4FD0FBDB0993E38F18506C17606C5E24249246F1CE94983A5361C5BE983E",
- "P-521": "3081EE020100301006072A8648CE3D020106052B810400230481D63081D3020101044201BD56BD106118EDA246155BD43B42B8E13F0A6E25DD3BB376026FAB4DC92B6157BC6DFEC2D15DD3D0CF2A39AA68494042AF48BA9601118DA82C6F2108A3A203AD74A181890381860004012FBCAEFFA6A51F3EE4D3D2B51C5DEC6D7C726CA353FC014EA2BF7CFBB9B910D32CBFA6A00FE39B6CDB8946F22775398B2E233C0CF144D78C8A7742B5C7A3BB5D23009CDEF823DD7BF9A79E8CCEACD2E4527C231D0AE5967AF0958E931D7DDCCF2805A3E618DC3039FEC9FEBBD33052FE4C0FEE98F033106064982D88F4E03549D4A64D"
-};
-
-function runTest(algorithmName, namedCurve, extractable, keyUsages)
-{
- var keyDataHex = kKeyDataForCurve[namedCurve];
- var importData = hexStringToUint8Array(keyDataHex);
- var importAlgorithm = { name: algorithmName, namedCurve: namedCurve };
-
- 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';
- return cloneKey(importedKey);
- }).then(function(clonedKey) {
- results.clonedKey = clonedKey;
- if (extractable)
- return crypto.subtle.exportKey('pkcs8', clonedKey);
- return null;
- }).then(function(clonedKeyData) {
- importedKey = results.importedKey;
- clonedKey = results.clonedKey;
-
- shouldEvaluateAs("importedKey.extraProperty", "hi");
- shouldEvaluateAs("importedKey.type", "private");
- shouldEvaluateAs("importedKey.extractable", extractable);
- shouldEvaluateAs("importedKey.algorithm.name", algorithmName);
- shouldEvaluateAs("importedKey.algorithm.namedCurve", namedCurve);
- shouldEvaluateAs("importedKey.usages.join(',')", keyUsages.join(","));
-
- shouldNotBe("importedKey", "clonedKey");
-
- shouldBeUndefined("clonedKey.extraProperty");
- shouldEvaluateAs("clonedKey.type", "private");
- shouldEvaluateAs("clonedKey.extractable", extractable);
- shouldEvaluateAs("clonedKey.algorithm.name", algorithmName);
- shouldEvaluateAs("clonedKey.algorithm.namedCurve", namedCurve);
- shouldEvaluateAs("clonedKey.usages.join(',')", keyUsages.join(","));
-
- logSerializedKey(importedKey);
-
- if (extractable)
- bytesShouldMatchHexString("Cloned key exported data", keyDataHex, clonedKeyData);
-
- debug("");
- });
-}
-
-var lastPromise = Promise.resolve(null);
-
-kPossibleAlgorithms.forEach(function(algorithmName) {
- kPossibleExtractable.forEach(function(extractable) {
- kPossibleKeyUsages.forEach(function(keyUsages) {
- kPossibleNamedCurves.forEach(function(namedCurve) {
- lastPromise = lastPromise.then(runTest.bind(null, algorithmName, namedCurve, extractable, keyUsages));
- });
- });
- });
-});
-
-lastPromise.then(finishJSTest, failAndFinishJSTest);
-
-</script>
-
-</body>
-</html>
« no previous file with comments | « LayoutTests/crypto/subtle/clone-aesKey-expected.txt ('k') | LayoutTests/crypto/subtle/clone-ecKey-private-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698