authorgravatar for rob@neverwood.orgRob Napier <rob@neverwood.org> 2020-09-12 18:33:53-04:00
committergravatar for rob@neverwood.orgRob Napier <rob@neverwood.org> 2020-09-12 18:33:53-04:00
log17156e1775f60893b4c5040d7a0073659ea9157d
treee0db8ae10c7d0351407be8b7eff1210443bfef8c
parent3f450b7e931b76b20e36d2bab2e2d1fed3ee19ec

pbkdf2 "very large dklen test" should just check for crashes


1 files changed, 4 insertions(+), 5 deletions(-)

lib/std/crypto/pbkdf2.zig+4-5
...@@ -59,8 +59,10 @@ const mem = std.mem;...@@ -59,8 +59,10 @@ const mem = std.mem;
59/// salt: Arbitrary sequence of bytes of any length, including empty. A common length is 8 bytes.59/// salt: Arbitrary sequence of bytes of any length, including empty. A common length is 8 bytes.
60///60///
61/// rounds: Iteration count. Must be greater than 0. Common values range from 1,000 to 100,000.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.
64pub fn pbkdf2(derivedKey: []u8, password: []const u8, salt: []const u8, rounds: u32, comptime Prf: type) void {66pub fn pbkdf2(derivedKey: []u8, password: []const u8, salt: []const u8, rounds: u32, comptime Prf: type) void {
65 assert(rounds >= 1);67 assert(rounds >= 1);
6668
...@@ -263,8 +265,5 @@ test "Very large dkLen" {...@@ -263,8 +265,5 @@ test "Very large dkLen" {
263 }265 }
264266
265 pbkdf2(derivedKey, p, s, c, crypto.auth.hmac.HmacSha1);267 pbkdf2(derivedKey, p, s, c, crypto.auth.hmac.HmacSha1);
266268 // Just verify this doesn't crash with an overflow
267 const expected = "0c60c80f961f0e71f3a9b524af6012062fe037a6";
268
269 htest.assertEqual(expected, derivedKey[0..]);
270}269}