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

Side by Side Diff: LayoutTests/crypto/subtle/resources/ec-cloneKey.js

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 unified diff | Download patch
OLDNEW
(Empty)
1 if (self.importScripts) {
2 importScripts('common.js');
3 }
4
5 function runCloneECTests(format, algorithmName, namedCurve, keyType, extractable , keyUsages, keyData)
6 {
7 var importData = hexStringToUint8Array(keyData);
8 var importAlgorithm = { name: algorithmName, namedCurve: namedCurve };
9
10 var results = {};
11
12 return crypto.subtle.importKey(format, importData, importAlgorithm, extracta ble, keyUsages).then(function(importedKey) {
13 results.importedKey = importedKey;
14 importedKey.extraProperty = 'hi';
15 return cloneKey(importedKey);
16 }).then(function(clonedKey) {
17 results.clonedKey = clonedKey;
18 if (extractable)
19 return crypto.subtle.exportKey(format, clonedKey);
20 return null;
21 }).then(function(clonedKeyData) {
22 importedKey = results.importedKey;
23 clonedKey = results.clonedKey;
24
25 shouldEvaluateAs("importedKey.extraProperty", "hi");
26 shouldEvaluateAs("importedKey.type", keyType);
27 shouldEvaluateAs("importedKey.extractable", extractable);
28 shouldEvaluateAs("importedKey.algorithm.name", algorithmName);
29 shouldEvaluateAs("importedKey.algorithm.namedCurve", namedCurve);
30 shouldEvaluateAs("importedKey.usages.join(',')", keyUsages.join(","));
31
32 shouldNotBe("importedKey", "clonedKey");
33
34 shouldBeUndefined("clonedKey.extraProperty");
35 shouldEvaluateAs("clonedKey.type", keyType);
36 shouldEvaluateAs("clonedKey.extractable", extractable);
37 shouldEvaluateAs("clonedKey.algorithm.name", algorithmName);
38 shouldEvaluateAs("clonedKey.algorithm.namedCurve", namedCurve);
39 shouldEvaluateAs("clonedKey.usages.join(',')", keyUsages.join(","));
40
41 logSerializedKey(importedKey);
42
43 if (extractable)
44 bytesShouldMatchHexString("Cloned key exported data", keyData, clone dKeyData);
45
46 debug("");
47 });
48 }
49
50 function testCloneEcKeys(format, algorithmName, possibleKeyUsages, keyType, keyD ataForCurve)
51 {
52 var lastPromise = Promise.resolve(null);
53 var kPossibleExtractable = [true, false];
54 var kPossibleNamedCurves = ['P-256', 'P-384', 'P-521'];
55
56 kPossibleNamedCurves.forEach(function(namedCurve) {
57 kPossibleExtractable.forEach(function(extractable) {
58 possibleKeyUsages.forEach(function(keyUsages) {
59 lastPromise = lastPromise.then(runCloneECTests.bind(null, format , algorithmName, namedCurve, keyType, extractable, keyUsages, keyDataForCurve[na medCurve]));
60 });
61 });
62 });
63
64 return lastPromise;
65 }
66
67 function testCloneEcPublicKeys(algorithmName, possibleKeyUsages)
68 {
69 var kKeyDataForCurve = {
70 "P-256": "3059301306072A8648CE3D020106082A8648CE3D030107034200049CB0CF69 30" +
71 "3DAFC761D4E4687B4ECF039E6D34AB964AF80810D8D558A4A8D6F72D51233A 17" +
72 "88920A86EE08A1962C79EFA317FB7879E297DAD2146DB995FA1C78",
73 "P-384": "3076301006072A8648CE3D020106052B81040022036200040874A2E0B8FF44 8F" +
74 "0E54321E27F4F1E64D064CDEB7D26F458C32E930120F4E57DC85C2693F977E ED" +
75 "4A8ECC8DB981B4D91F69446DF4F4C6F5DE19003F45F891D0EBCD2FFFDB5C81 C0" +
76 "40E8D6994C43C7FEEDB98A4A31EDFB35E89A30013C3B9267",
77 "P-521": "30819B301006072A8648CE3D020106052B81040023038186000400F50A0870 32" +
78 "50C15F043C8C46E99783435245CF98F4F2694B0E2F8D029A514DD6F0B086D4 ED" +
79 "892000CD5590107AAE69C4C0A7A95F7CF74E5770A07D5DB55BCE4AB400F2C7 70" +
80 "BAB8B9BE4CDB6ECD3DC26C698DA0D2599CEBF3D904F7F9CA3A55E64731810D 73" +
81 "CD317264E50BABA4BC2860857E16D6CBB79501BC9E3A32BD172EA8A71DEE"
82 };
83 return testCloneEcKeys("spki", algorithmName, possibleKeyUsages, "public", k KeyDataForCurve);
84 }
85
86 function testCloneEcPrivateKeys(algorithmName, possibleKeyUsages)
87 {
88 var kKeyDataForCurve = {
89 "P-256": "308187020100301306072A8648CE3D020106082A8648CE3D030107046D306B 02" +
90 "010104201FE33950C5F461124AE992C2BDFDF1C73B1615F571BD567E60D19A A1" +
91 "F48CDF42A144034200047C110C66DCFDA807F6E69E45DDB3C74F69A1484D20 3E" +
92 "8DC5ADA8E9A9DD7CB3C70DF448986E51BDE5D1576F99901F9C2C6A806A47FD 90" +
93 "7643A72B835597EFC8C6",
94 "P-384": "3081B6020100301006072A8648CE3D020106052B8104002204819E30819B02 01" +
95 "010430A492CE8FA90084C227E1A32F7974D39E9FF67A7E8705EC3419B35FB6 07" +
96 "582BEBD461E0B1520AC76EC2DD4E9B63EBAE71A16403620004E55FEE6C49D8 D5" +
97 "23F5CE7BF9C0425CE4FF650708B7DE5CFB095901523979A7F042602DB30854 73" +
98 "5369813B5C3F5EF86828F59CC5DC509892A988D38A8E2519DE3D0C4FD0FBDB 09" +
99 "93E38F18506C17606C5E24249246F1CE94983A5361C5BE983E",
100 "P-521": "3081EE020100301006072A8648CE3D020106052B810400230481D63081D302 01" +
101 "01044201BD56BD106118EDA246155BD43B42B8E13F0A6E25DD3BB376026FAB 4D" +
102 "C92B6157BC6DFEC2D15DD3D0CF2A39AA68494042AF48BA9601118DA82C6F21 08" +
103 "A3A203AD74A181890381860004012FBCAEFFA6A51F3EE4D3D2B51C5DEC6D7C 72" +
104 "6CA353FC014EA2BF7CFBB9B910D32CBFA6A00FE39B6CDB8946F22775398B2E 23" +
105 "3C0CF144D78C8A7742B5C7A3BB5D23009CDEF823DD7BF9A79E8CCEACD2E452 7C" +
106 "231D0AE5967AF0958E931D7DDCCF2805A3E618DC3039FEC9FEBBD33052FE4C 0F" +
107 "EE98F033106064982D88F4E03549D4A64D"
108 };
109 return testCloneEcKeys("pkcs8", algorithmName, possibleKeyUsages, "private", kKeyDataForCurve);
110 }
OLDNEW
« no previous file with comments | « LayoutTests/crypto/subtle/pbkdf2/cloneKey-expected.txt ('k') | LayoutTests/crypto/subtle/resources/rsa-cloneKey.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698