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

Side by Side Diff: LayoutTests/crypto/subtle/pbkdf2-deriveKey-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 deriveKey() with various bad parameters for PBKDF2");
13
14 jsTestIsAsync = true;
15
16 var testCase = {
17 password: "password",
18 salt: "salt",
19 c: 1,
20 dkLen: 20,
21 hash: "SHA-1",
22 derived_key_full_length: "0c60c80f961f0e71f3a9b524af6012062fe037a6"
23 };
24
25 function importPbkdf2Key() {
26 var key = null;
27
28 debug("Importing the password...");
29
30 var algorithm = {name: 'PBKDF2'};
31
32 var password = asciiToUint8Array(testCase.password);
33 var usages = ['deriveBits', 'deriveKey'];
34 var extractable = false;
35
36 // (1) Import the password
37 return crypto.subtle.importKey('raw', password, algorithm, extractable, usag es).then(function(result) {
38 key = result;
39 return key;
40 });
41 }
42
43 var pbkdf2Key = null;
44
45 var params = {
46 name: 'PBKDF2',
47 salt: asciiToUint8Array(testCase.salt),
48 iterations: testCase.c,
49 hash: {name: testCase.hash}
50 };
51 importPbkdf2Key().then(function(result) {
52 pbkdf2Key = result;
53
54 debug("\nDeriving an AES key with no length...");
55 var derivedAlgorithm = {name: 'aes-cbc'};
56 var extractable = true;
57 var usages = ['encrypt'];
58
59 return crypto.subtle.deriveKey(params, pbkdf2Key, derivedAlgorithm, extracta ble, usages);
60 }).then(failAndFinishJSTest, function(result) {
61 logError(result);
62
63 debug("\nDeriving an AES key with bad length...");
64 var derivedAlgorithm = {name: 'aes-cbc', length: 120};
65 var extractable = true;
66 var usages = ['encrypt'];
67
68 return crypto.subtle.deriveKey(params, pbkdf2Key, derivedAlgorithm, extracta ble, usages);
69 }).then(failAndFinishJSTest, function(result) {
70 logError(result);
71
72 debug("\nDeriving an AES key with unsupported length...");
73 var derivedAlgorithm = {name: 'aes-cbc', length: 192};
74 var extractable = true;
75 var usages = ['encrypt'];
76
77 return crypto.subtle.deriveKey(params, pbkdf2Key, derivedAlgorithm, extracta ble, usages);
78 }).then(failAndFinishJSTest, function(result) {
79 logError(result);
80
81 debug("\nDeriving an AES-CBC key with unsupported usage (sign)...");
82 var derivedAlgorithm = {name: 'aes-cbc', length: 128};
83 var extractable = true;
84 var usages = ['sign']; // Not valid for AES-CBC.
85
86 return crypto.subtle.deriveKey(params, pbkdf2Key, derivedAlgorithm, extracta ble, usages);
87 }).then(failAndFinishJSTest, function(result) {
88 logError(result);
89
90 debug("\nDeriving a zero-length HMAC key...");
91 var derivedAlgorithm = {name: 'HMAC', hash: "sha-1", length: 0};
92 var extractable = true;
93 var usages = ['sign'];
94
95 return crypto.subtle.deriveKey(params, pbkdf2Key, derivedAlgorithm, extracta ble, usages);
96 }).then(failAndFinishJSTest, function(result) {
97 logError(result);
98
99 debug("\nDeriving an ECDH key...");
100 var derivedAlgorithm = {name: 'ECDH', namedCurve: "P-256"};
101 var extractable = true;
102 var usages = ['deriveBits'];
103
104 return crypto.subtle.deriveKey(params, pbkdf2Key, derivedAlgorithm, extracta ble, usages);
105 }).then(failAndFinishJSTest, function(result) {
106 logError(result);
107
108 debug("\nDeriving an RSA-OAEP key...");
109 var derivedAlgorithm = {name: 'RSA-OAEP', hash: "sha-1"};
110 var extractable = true;
111 var usages = ['encrypt'];
112
113 return crypto.subtle.deriveKey(params, pbkdf2Key, derivedAlgorithm, extracta ble, usages);
114 }).then(failAndFinishJSTest, function(result) {
115 logError(result);
116
117 debug("");
118 }).then(finishJSTest, failAndFinishJSTest);
119
120 </script>
121
122 </body>
123 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698