You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.6 KiB

  1. Port of the OpenBSD `bcrypt_pbkdf` function to pure Javascript. `npm`-ified
  2. version of [Devi Mandiri's port](https://github.com/devi/tmp/blob/master/js/bcrypt_pbkdf.js),
  3. with some minor performance improvements. The code is copied verbatim (and
  4. un-styled) from Devi's work.
  5. This product includes software developed by Niels Provos.
  6. ## API
  7. ### `bcrypt_pbkdf.pbkdf(pass, passlen, salt, saltlen, key, keylen, rounds)`
  8. Derive a cryptographic key of arbitrary length from a given password and salt,
  9. using the OpenBSD `bcrypt_pbkdf` function. This is a combination of Blowfish and
  10. SHA-512.
  11. See [this article](http://www.tedunangst.com/flak/post/bcrypt-pbkdf) for
  12. further information.
  13. Parameters:
  14. * `pass`, a Uint8Array of length `passlen`
  15. * `passlen`, an integer Number
  16. * `salt`, a Uint8Array of length `saltlen`
  17. * `saltlen`, an integer Number
  18. * `key`, a Uint8Array of length `keylen`, will be filled with output
  19. * `keylen`, an integer Number
  20. * `rounds`, an integer Number, number of rounds of the PBKDF to run
  21. ### `bcrypt_pbkdf.hash(sha2pass, sha2salt, out)`
  22. Calculate a Blowfish hash, given SHA2-512 output of a password and salt. Used as
  23. part of the inner round function in the PBKDF.
  24. Parameters:
  25. * `sha2pass`, a Uint8Array of length 64
  26. * `sha2salt`, a Uint8Array of length 64
  27. * `out`, a Uint8Array of length 32, will be filled with output
  28. ## License
  29. This source form is a 1:1 port from the OpenBSD `blowfish.c` and `bcrypt_pbkdf.c`.
  30. As a result, it retains the original copyright and license. The two files are
  31. under slightly different (but compatible) licenses, and are here combined in
  32. one file. For each of the full license texts see `LICENSE`.