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

Side by Side Diff: LayoutTests/crypto/subtle/ecdh-deriveBits-failures.html

Issue 957713004: [WebCrypto] Split LayoutTests/crypto/subtle into per-algorithm directories (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated to latest master Created 5 years, 10 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 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 <script src="resources/common.js"></script>
6 </head>
7 <body>
8 <p id="description"></p>
9 <div id="console"></div>
10
11 <script>
12 description("Tests bad inputs to ECDH's deriveBits()");
13
14 jsTestIsAsync = true;
15
16 var keyPairs = {
17 ecdh: {},
18 ecdsa: {}
19 };
20
21 // Generate some EC keys for ECDSA and ECDH.
22 function createTestKeys() {
23 return crypto.subtle.generateKey({name: "ecdh", namedCurve: "P-256"}, true, ["deriveBits"]).then(function(result) {
24 keyPairs.ecdh.p256_1 = result;
25
26 return crypto.subtle.generateKey({name: "ecdh", namedCurve: "P-256"}, true , ["deriveBits"]);
27 }).then(function(result) {
28 keyPairs.ecdh.p256_2 = result;
29
30 return crypto.subtle.generateKey({name: "ecdh", namedCurve: "P-384"}, true , ["deriveBits"]);
31 }).then(function(result) {
32 keyPairs.ecdh.p384_1 = result;
33
34 return crypto.subtle.generateKey({name: "ecdsa", namedCurve: "P-256"}, tru e, ["sign"]);
35 }).then(function(result) {
36 keyPairs.ecdsa.p256_1 = result;
37 });
38 }
39
40 createTestKeys().then(function(result) {
41 debug("\nderiveBits() without algorithm name or public key...");
42 return crypto.subtle.deriveBits({}, keyPairs.ecdh.p256_1.privateKey, 256);
43 }).then(failAndFinishJSTest, function(result) {
44 logError(result);
45
46 debug("\nderiveBits() without public key...");
47 return crypto.subtle.deriveBits({name: 'ecdh'}, keyPairs.ecdh.p256_1.privateKe y, 256);
48 }).then(failAndFinishJSTest, function(result) {
49 logError(result);
50
51 debug("\nderiveBits() with algorithm that is null...");
52 return crypto.subtle.deriveBits(null, keyPairs.ecdh.p256_1.privateKey, 256);
53 }).then(failAndFinishJSTest, function(result) {
54 logError(result);
55
56 debug("\nderiveBits() with algorithm that is -1...");
57 return crypto.subtle.deriveBits(-1, keyPairs.ecdh.p256_1.privateKey, 256);
58 }).then(failAndFinishJSTest, function(result) {
59 logError(result);
60
61 debug("\nderiveBits() with public key that is null...");
62 return crypto.subtle.deriveBits({name: 'ecdh', public: null}, keyPairs.ecdh.p2 56_1.privateKey, 256);
63 }).then(failAndFinishJSTest, function(result) {
64 logError(result);
65
66 debug("\nderiveBits() with public key that is -1...");
67 return crypto.subtle.deriveBits({name: 'ecdh', public: -1}, keyPairs.ecdh.p256 _1.privateKey, 256);
68 }).then(failAndFinishJSTest, function(result) {
69 logError(result);
70
71 debug("\nderiveBits() with public key that is a string...");
72 return crypto.subtle.deriveBits({name: 'ecdh', public: "foo"}, keyPairs.ecdh.p 256_1.privateKey, 256);
73 }).then(failAndFinishJSTest, function(result) {
74 logError(result);
75
76 debug("\nderiveBits() with wrong curve public key...");
77 return crypto.subtle.deriveBits({name: 'ecdh', public: keyPairs.ecdh.p384_1.pu blicKey}, keyPairs.ecdh.p256_1.privateKey, 256);
78 }).then(failAndFinishJSTest, function(result) {
79 logError(result);
80
81 debug("\nderiveBits() with a private key as the 'public' parameter");
82 return crypto.subtle.deriveBits({name: 'ecdh', public: keyPairs.ecdh.p256_2.pr ivateKey}, keyPairs.ecdh.p256_1.privateKey, 256);
83 }).then(failAndFinishJSTest, function(result) {
84 logError(result);
85
86 debug("\nderiveBits() with public key that is for ECDSA...");
87 return crypto.subtle.deriveBits({name: 'ecdh', public: keyPairs.ecdsa.p256_1.p ublicKey}, keyPairs.ecdh.p256_1.privateKey, {test: 3});
88 }).then(failAndFinishJSTest, function(result) {
89 logError(result);
90 }).then(finishJSTest, failAndFinishJSTest);
91
92 </script>
93
94 </body>
95 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698