| ... | @@ -35,12 +35,23 @@ pub const onetimeauth = struct { | ... | @@ -35,12 +35,23 @@ pub const onetimeauth = struct { |
| 35 | pub const Poly1305 = @import("crypto/poly1305.zig").Poly1305; | 35 | pub const Poly1305 = @import("crypto/poly1305.zig").Poly1305; |
| 36 | }; | 36 | }; |
| 37 | | 37 | |
| 38 | /// A Key Derivation Function (KDF) is intended to turn a weak, human generated password into a | 38 | /// A password hashing function derives a uniform key from low-entropy input material such as passwords. |
| 39 | /// strong key, suitable for cryptographic uses. It does this by salting and stretching the | 39 | /// It is intentionally slow or expensive. |
| 40 | /// password. Salting injects non-secret random data, so that identical passwords will be converted | 40 | /// |
| 41 | /// into unique keys. Stretching applies a deliberately slow hashing function to frustrate | 41 | /// With the standard definition of a key derivation function, if a key space is small, an exhaustive search may be practical. |
| 42 | /// brute-force guessing. | 42 | /// Password hashing functions make exhaustive searches way slower or way more expensive, even when implemented on GPUs and ASICs, by using different, optionally combined strategies: |
| 43 | pub const kdf = struct { | 43 | /// |
| | 44 | /// - Requiring a lot of computation cycles to complete |
| | 45 | /// - Requiring a lot of memory to complete |
| | 46 | /// - Requiring multiple CPU cores to complete |
| | 47 | /// - Requiring cache-local data to complete in reasonable time |
| | 48 | /// - Requiring large static tables |
| | 49 | /// - Avoiding precomputations and time/memory tradeoffs |
| | 50 | /// - Requiring multi-party computations |
| | 51 | /// - Combining the input material with random per-entry data (salts), application-specific contexts and keys |
| | 52 | /// |
| | 53 | /// Password hashing functions must be used whenever sensitive data has to be directly derived from a password. |
| | 54 | pub const pwhash = struct { |
| 44 | pub const pbkdf2 = @import("crypto/pbkdf2.zig").pbkdf2; | 55 | pub const pbkdf2 = @import("crypto/pbkdf2.zig").pbkdf2; |
| 45 | }; | 56 | }; |
| 46 | | 57 | |