| OLD | NEW |
| (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 deriveBits() with various bad parameters for PBKDF2"); | |
| 13 | |
| 14 jsTestIsAsync = true; | |
| 15 | |
| 16 var testCase = { | |
| 17 password: "password", | |
| 18 salt: "salt", | |
| 19 c: 1, | |
| 20 hash: "SHA-1" | |
| 21 }; | |
| 22 | |
| 23 function importPbkdf2Key() { | |
| 24 var key = null; | |
| 25 | |
| 26 debug("Importing the password..."); | |
| 27 | |
| 28 var algorithm = {name: 'PBKDF2'}; | |
| 29 | |
| 30 var password = asciiToUint8Array(testCase.password); | |
| 31 var usages = ['deriveBits', 'deriveKey']; | |
| 32 var extractable = false; | |
| 33 | |
| 34 // (1) Import the password | |
| 35 return crypto.subtle.importKey('raw', password, algorithm, extractable, usag
es).then(function(result) { | |
| 36 key = result; | |
| 37 return key; | |
| 38 }); | |
| 39 } | |
| 40 | |
| 41 var pbkdf2Key = null; | |
| 42 | |
| 43 var params = { | |
| 44 name: 'PBKDF2', | |
| 45 salt: asciiToUint8Array(testCase.salt), | |
| 46 iterations: testCase.c, | |
| 47 hash: {name: testCase.hash} | |
| 48 }; | |
| 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); | |
| 55 | |
| 56 debug(""); | |
| 57 }).then(finishJSTest, failAndFinishJSTest); | |
| 58 | |
| 59 </script> | |
| 60 | |
| 61 </body> | |
| 62 </html> | |
| OLD | NEW |