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

Side by Side Diff: LayoutTests/crypto/clone-rsaKey-public.html

Issue 285823002: [webcrypto] Remove RSA-ES support (1 of 3) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix some usages Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../resources/js-test.js"></script>
5 <script src="resources/common.js"></script>
6 <script src="resources/keys.js"></script>
7 </head>
8 <body>
9 <p id="description"></p>
10 <div id="console"></div>
11
12 <script>
13 description("Tests structured cloning of RSA public keys (without a hash)");
14
15 jsTestIsAsync = true;
16
17 // Tests the 16 permutations of keys generated by:
18 // kPossibleAlgorithms x kPossibleExtractable x kPossibleKeyUsages x kPossible KeyData
19 //
20 // For practical reasons these tests are not exhaustive.
21
22 var kPossibleAlgorithms = ['RSAES-PKCS1-v1_5'];
23 var kPossibleExtractable = [true, false];
24 var kPossibleKeyUsages = [[], ['encrypt'], ['decrypt', 'wrapKey'], ['encrypt', ' wrapKey', 'unwrapKey']];
25
26 var kPossibleKeyData = [
27 kKeyData.rsa2,
28 kKeyData.rsa3
29 ];
30
31 function runTest(algorithmName, extractable, keyUsages, keyData)
32 {
33 var importData = hexStringToUint8Array(keyData.spki);
34 var importAlgorithm = { name: algorithmName };
35
36 var results = {};
37
38 return crypto.subtle.importKey('spki', importData, importAlgorithm, extracta ble, keyUsages).then(function(importedKey) {
39 results.importedKey = importedKey;
40 importedKey.extraProperty = 'hi';
41 return cloneKey(importedKey);
42 }).then(function(clonedKey) {
43 results.clonedKey = clonedKey;
44 if (extractable)
45 return crypto.subtle.exportKey('spki', clonedKey);
46 return null;
47 }).then(function(clonedKeyData) {
48 importedKey = results.importedKey;
49 clonedKey = results.clonedKey;
50
51 shouldEvaluateAs("importedKey.extraProperty", "hi");
52 shouldEvaluateAs("importedKey.type", "public");
53 shouldEvaluateAs("importedKey.extractable", extractable);
54 shouldEvaluateAs("importedKey.algorithm.name", algorithmName);
55 shouldEvaluateAs("importedKey.algorithm.modulusLength", keyData.modulusL engthBits);
56 bytesShouldMatchHexString("importedKey.algorithm.publicExponent", keyDat a.publicExponent, importedKey.algorithm.publicExponent);
57 shouldBeUndefined("importedKey.algorithm.hash");
58 shouldEvaluateAs("importedKey.usages.join(',')", keyUsages.join(","));
59
60 shouldNotBe("importedKey", "clonedKey");
61
62 shouldBeUndefined("clonedKey.extraProperty");
63 shouldEvaluateAs("clonedKey.type", "public");
64 shouldEvaluateAs("clonedKey.extractable", extractable);
65 shouldEvaluateAs("clonedKey.algorithm.name", algorithmName);
66 shouldEvaluateAs("clonedKey.algorithm.modulusLength", keyData.modulusLen gthBits);
67 bytesShouldMatchHexString("clonedKey.algorithm.publicExponent", keyData. publicExponent, clonedKey.algorithm.publicExponent);
68 shouldBeUndefined("clonedKey.algorithm.hash");
69 shouldEvaluateAs("clonedKey.usages.join(',')", keyUsages.join(","));
70
71 logSerializedKey(importedKey);
72
73 if (extractable)
74 bytesShouldMatchHexString("Cloned key exported data", keyData.spki, clonedKeyData);
75
76 debug("");
77 });
78 }
79
80 var lastPromise = Promise.resolve(null);
81
82 kPossibleAlgorithms.forEach(function(algorithmName) {
83 kPossibleExtractable.forEach(function(extractable) {
84 kPossibleKeyUsages.forEach(function(keyUsages) {
85 kPossibleKeyData.forEach(function(keyData) {
86 lastPromise = lastPromise.then(runTest.bind(null, algorithmNam e, extractable, keyUsages, keyData));
87 });
88 });
89 });
90 });
91
92 lastPromise.then(finishJSTest, failAndFinishJSTest);
93
94 </script>
95
96 </body>
97 </html>
OLDNEW
« no previous file with comments | « LayoutTests/crypto/clone-rsaKey-private-expected.txt ('k') | LayoutTests/crypto/clone-rsaKey-public-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698