| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../../../resources/js-test.js"></script> | 4 <script src="../../../resources/js-test.js"></script> |
| 5 <script src="../resources/common.js"></script> | 5 <script src="../resources/common.js"></script> |
| 6 </head> | 6 </head> |
| 7 <body> | 7 <body> |
| 8 <p id="description"></p> | 8 <p id="description"></p> |
| 9 <div id="console"></div> | 9 <div id="console"></div> |
| 10 | 10 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 60 |
| 61 // Empty password. | 61 // Empty password. |
| 62 { | 62 { |
| 63 password: [], | 63 password: [], |
| 64 salt: "salt", | 64 salt: "salt", |
| 65 c: 20, | 65 c: 20, |
| 66 dkLen: 16, | 66 dkLen: 16, |
| 67 hash: "SHA-384", | 67 hash: "SHA-384", |
| 68 derived_key: "750261780a187897a9978371599db5d1" | 68 derived_key: "750261780a187897a9978371599db5d1" |
| 69 }, | 69 }, |
| 70 | |
| 71 // Derive zero bytes. | |
| 72 { | |
| 73 password: "password", | |
| 74 salt: "salt", | |
| 75 c: 4096, | |
| 76 dkLen: 0, | |
| 77 hash: "SHA-512", | |
| 78 derived_key: "" | |
| 79 }, | |
| 80 ]; | 70 ]; |
| 81 | 71 |
| 82 function runPbkdf2SuccessTestCase(testCase) | 72 function runPbkdf2SuccessTestCase(testCase) |
| 83 { | 73 { |
| 84 var algorithm = {name: 'PBKDF2'}; | 74 var algorithm = {name: 'PBKDF2'}; |
| 85 | 75 |
| 86 var key = null; | 76 var key = null; |
| 87 var password = null; | 77 var password = null; |
| 88 if (typeof testCase.password === 'string') | 78 if (typeof testCase.password === 'string') |
| 89 password = asciiToUint8Array(testCase.password); | 79 password = asciiToUint8Array(testCase.password); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 106 tmpKey = key; | 96 tmpKey = key; |
| 107 shouldEvaluateAs("tmpKey.type", "secret"); | 97 shouldEvaluateAs("tmpKey.type", "secret"); |
| 108 shouldEvaluateAs("tmpKey.extractable", false); | 98 shouldEvaluateAs("tmpKey.extractable", false); |
| 109 shouldEvaluateAs("tmpKey.algorithm.name", "PBKDF2"); | 99 shouldEvaluateAs("tmpKey.algorithm.name", "PBKDF2"); |
| 110 shouldEvaluateAs("tmpKey.usages.join(',')", "deriveKey,deriveBits"); | 100 shouldEvaluateAs("tmpKey.usages.join(',')", "deriveKey,deriveBits"); |
| 111 | 101 |
| 112 // (2) Derive bits | 102 // (2) Derive bits |
| 113 return crypto.subtle.deriveBits(params, key, testCase.dkLen*8); | 103 return crypto.subtle.deriveBits(params, key, testCase.dkLen*8); |
| 114 }).then(function(result) { | 104 }).then(function(result) { |
| 115 bytesShouldMatchHexString("deriveBits", testCase.derived_key, result); | 105 bytesShouldMatchHexString("deriveBits", testCase.derived_key, result); |
| 116 return crypto.subtle.deriveBits(params, key, 0); | |
| 117 }).then(function(result) { | |
| 118 derivedBits = result; | |
| 119 shouldBe("derivedBits.byteLength", "0"); | |
| 120 }); | 106 }); |
| 121 } | 107 } |
| 122 | 108 |
| 123 var lastPromise = Promise.resolve(null); | 109 var lastPromise = Promise.resolve(null); |
| 124 | 110 |
| 125 kPbkdf2SuccessVectors.forEach(function(test) { | 111 kPbkdf2SuccessVectors.forEach(function(test) { |
| 126 lastPromise = lastPromise.then(runPbkdf2SuccessTestCase.bind(null, test)); | 112 lastPromise = lastPromise.then(runPbkdf2SuccessTestCase.bind(null, test)); |
| 127 }); | 113 }); |
| 128 | 114 |
| 129 lastPromise.then(finishJSTest, failAndFinishJSTest); | 115 lastPromise.then(finishJSTest, failAndFinishJSTest); |
| 130 | 116 |
| 131 </script> | 117 </script> |
| 132 | 118 |
| 133 </body> | 119 </body> |
| 134 </html> | 120 </html> |
| OLD | NEW |