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 importing empty password for PBKDF2"); |
| 13 |
| 14 jsTestIsAsync = true; |
| 15 |
| 16 // ------------------------------------------------- |
| 17 // Test importing empty password for PBKDF2 |
| 18 // ------------------------------------------------- |
| 19 |
| 20 // Empty password |
| 21 var testCase = |
| 22 { |
| 23 password: "", |
| 24 salt: "salt", |
| 25 c: 1, |
| 26 dkLen: 20, |
| 27 hash: "SHA-1", |
| 28 }; |
| 29 |
| 30 function runPbkdf2SuccessTestCase(testCase) |
| 31 { |
| 32 var algorithm = {name: 'PBKDF2'}; |
| 33 var password = asciiToUint8Array(testCase.password); |
| 34 var usages = ['deriveBits', 'deriveKey']; |
| 35 var extractable = false; |
| 36 |
| 37 var params = { |
| 38 name: 'PBKDF2', |
| 39 salt: asciiToUint8Array(testCase.salt), |
| 40 iterations: testCase.c, |
| 41 hash: {name: testCase.hash} |
| 42 }; |
| 43 // (1) Import the password |
| 44 return crypto.subtle.importKey('raw', password, algorithm, extractable, usag
es).then(function(result) { |
| 45 // shouldBe() can only resolve variables in global context. |
| 46 key = result; |
| 47 shouldEvaluateAs("key.type", "secret"); |
| 48 shouldEvaluateAs("key.extractable", false); |
| 49 shouldEvaluateAs("key.algorithm.name", "PBKDF2"); |
| 50 shouldEvaluateAs("key.usages.join(',')", "deriveKey,deriveBits"); |
| 51 |
| 52 return crypto.subtle.deriveBits(params, key, 80); |
| 53 }).then(failAndFinishJSTest, function(result) { |
| 54 logError(result); |
| 55 }).then(finishJSTest, failAndFinishJSTest); |
| 56 } |
| 57 |
| 58 runPbkdf2SuccessTestCase(testCase); |
| 59 |
| 60 </script> |
| 61 |
| 62 </body> |
| 63 </html> |
OLD | NEW |