pbkdf2_test.js 592 B

12345678910111213141516
  1. /* From http://www.cryptosys.net/manapi/api_PBE_Kdf2.html */
  2. new sjcl.test.TestCase("PBKDF2", function (cb) {
  3. if (!sjcl.misc.pbkdf2 || !sjcl.misc.hmac || !sjcl.hash.sha256) {
  4. this.unimplemented();
  5. cb && cb();
  6. return;
  7. }
  8. var h = sjcl.codec.hex, password = "password", salt = "78 57 8E 5A 5D 63 CB 06", count = 2048, output,
  9. goodOutput = "97b5a91d35af542324881315c4f849e327c4707d1bc9d322";
  10. output = sjcl.misc.pbkdf2(password, h.toBits(salt), count);
  11. output = h.fromBits(output);
  12. this.require(output.substr(0,goodOutput.length) == goodOutput);
  13. cb && cb();
  14. });