| ... | @@ -10,11 +10,11 @@ const debug = std.debug; | ... | @@ -10,11 +10,11 @@ const debug = std.debug; |
| 10 | const assert = debug.assert; | 10 | const assert = debug.assert; |
| 11 | const mem = std.mem; | 11 | const mem = std.mem; |
| 12 | | 12 | |
| 13 | //! PBKDF2 (Password-Based Key Derivation Function 2) is a specific Key Derivation Function, | 13 | //! PBKDF2 (Password-Based Key Derivation Function 2) is intended to turn a weak, human generated |
| 14 | //! intended to turn a weak, human generated password into a strong key, suitable for cryptographic | 14 | //! password into a strong key, suitable for cryptographic uses. It does this by salting and |
| 15 | //! uses. It does this by salting and stretching the password. Salting injects non-secret random | 15 | //! stretching the password. Salting injects non-secret random data, so that identical passwords |
| 16 | //! data, so that identical passwords will be converted into unique keys. Stretching applies a | 16 | //! will be converted into unique keys. Stretching applies a deliberately slow hashing function to |
| 17 | //! deliberately slow hashing function to frustrate brute-force guessing. | 17 | //! frustrate brute-force guessing. |
| 18 | //! | 18 | //! |
| 19 | //! PBKDF2 is defined in RFC 2898, and is a recommendation of NIST SP 800-132. | 19 | //! PBKDF2 is defined in RFC 2898, and is a recommendation of NIST SP 800-132. |
| 20 | | 20 | |
| ... | @@ -46,8 +46,7 @@ const mem = std.mem; | ... | @@ -46,8 +46,7 @@ const mem = std.mem; |
| 46 | | 46 | |
| 47 | // Based on Apple's CommonKeyDerivation, based originally on code by Damien Bergamini. | 47 | // Based on Apple's CommonKeyDerivation, based originally on code by Damien Bergamini. |
| 48 | | 48 | |
| 49 | /// Given a password, salt, iteration count (rounds), and a pseudo-random function, generates a | 49 | /// Apply PBKDF2 to generate a key from a password. |
| 50 | /// derived key in the provided buffer slice. | | |
| 51 | /// | 50 | /// |
| 52 | /// derivedKey: Slice of appropriate size for generated key. Generally 16 or 32 bytes in length. | 51 | /// derivedKey: Slice of appropriate size for generated key. Generally 16 or 32 bytes in length. |
| 53 | /// May be uninitialized. All bytes will be written. | 52 | /// May be uninitialized. All bytes will be written. |