authorgravatar for 35231115+Rocknest@users.noreply.github.comRocknest <35231115+Rocknest@users.noreply.github.com> 2020-09-14 02:27:09+03:00
committergravatar for 35231115+Rocknest@users.noreply.github.comRocknest <35231115+Rocknest@users.noreply.github.com> 2020-09-14 02:27:09+03:00
log988fc6f9d1419a63d7ecd3507966ba0b4c15eac5
tree2dede9f0248361203f57755a93de3d697e156ef6
parent73863cf72be02020886d9f8daf15754a8d3b2567

flip condition


1 files changed, 2 insertions(+), 2 deletions(-)

lib/std/crypto/pbkdf2.zig+2-2
...@@ -59,15 +59,15 @@ pub fn pbkdf2(derivedKey: []u8, password: []const u8, salt: []const u8, rounds:...@@ -59,15 +59,15 @@ pub fn pbkdf2(derivedKey: []u8, password: []const u8, salt: []const u8, rounds:
5959
60 const dkLen = derivedKey.len;60 const dkLen = derivedKey.len;
61 const hLen = Prf.mac_length;61 const hLen = Prf.mac_length;
62 comptime std.debug.assert(hLen >= 1);
6263
63 // FromSpec:64 // FromSpec:
64 //65 //
65 // 1. If dkLen > maxInt(u32) * hLen, output "derived key too long" and66 // 1. If dkLen > maxInt(u32) * hLen, output "derived key too long" and
66 // stop.67 // stop.
67 //68 //
68 if (comptime (maxInt(usize) < maxInt(u32) * hLen) and (dkLen > @as(usize, maxInt(u32) * hLen))) {69 if (comptime (maxInt(usize) > maxInt(u32) * hLen) and (dkLen > @as(usize, maxInt(u32) * hLen))) {
69 // If maxInt(usize) is less than `maxInt(u32) * hLen` then dkLen is always inbounds70 // If maxInt(usize) is less than `maxInt(u32) * hLen` then dkLen is always inbounds
70 // This also asserts hLen >= 1
71 return error.DerivedKeyTooLong;71 return error.DerivedKeyTooLong;
72 }72 }
7373