Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / crypto / subtle / pbkdf2 / deriveBits-failures.html
blob9562e287594a01005e70839f6028179842fc04a7
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>
11 <script>
12 description("Tests deriveBits() with various bad parameters for PBKDF2");
14 jsTestIsAsync = true;
16 var testCase = {
17 password: "password",
18 salt: "salt",
19 c: 1,
20 hash: "SHA-1"
23 function importPbkdf2Key() {
24 var key = null;
26 debug("Importing the password...");
28 var algorithm = {name: 'PBKDF2'};
30 var password = asciiToUint8Array(testCase.password);
31 var usages = ['deriveBits', 'deriveKey'];
32 var extractable = false;
34 // (1) Import the password
35 return crypto.subtle.importKey('raw', password, algorithm, extractable, usages).then(function(result) {
36 key = result;
37 return key;
38 });
41 var pbkdf2Key = null;
43 var params = {
44 name: 'PBKDF2',
45 salt: asciiToUint8Array(testCase.salt),
46 iterations: testCase.c,
47 hash: {name: testCase.hash}
49 importPbkdf2Key().then(function(result) {
50 pbkdf2Key = result;
51 debug("\nDeriving 100 bits...");
52 return crypto.subtle.deriveBits(params, pbkdf2Key, 100);
53 }).then(failAndFinishJSTest, function(result) {
54 logError(result);
56 debug("");
57 }).then(finishJSTest, failAndFinishJSTest);
59 </script>
61 </body>
62 </html>