| ... | ... | @@ -59,8 +59,10 @@ const mem = std.mem; |
| 59 | 59 | /// salt: Arbitrary sequence of bytes of any length, including empty. A common length is 8 bytes. |
| 60 | 60 | /// |
| 61 | 61 | /// rounds: Iteration count. Must be greater than 0. Common values range from 1,000 to 100,000. |
| 62 | /// Larger iteration counts improve security by increasing the time required to compute |
| 63 | /// the derivedKey. It is common to tune this parameter to achieve approximately 100ms. |
| 62 | 64 | /// |
| 63 | | /// Prf: Pseudo-random function to use. The most common choice is std.crypto.auth.hmac.HmacSha256. |
| 65 | /// Prf: Pseudo-random function to use. A common choice is std.crypto.auth.hmac.HmacSha256. |
| 64 | 66 | pub fn pbkdf2(derivedKey: []u8, password: []const u8, salt: []const u8, rounds: u32, comptime Prf: type) void { |
| 65 | 67 | assert(rounds >= 1); |
| 66 | 68 | |
| ... | ... | @@ -263,8 +265,5 @@ test "Very large dkLen" { |
| 263 | 265 | } |
| 264 | 266 | |
| 265 | 267 | pbkdf2(derivedKey, p, s, c, crypto.auth.hmac.HmacSha1); |
| 266 | | |
| 267 | | const expected = "0c60c80f961f0e71f3a9b524af6012062fe037a6"; |
| 268 | | |
| 269 | | htest.assertEqual(expected, derivedKey[0..]); |
| 268 | // Just verify this doesn't crash with an overflow |
| 270 | 269 | } |