authorgravatar for 124872+jedisct1@users.noreply.github.comFrank Denis <124872+jedisct1@users.noreply.github.com> 2021-03-16 18:34:02+01:00
committergravatar for 124872+jedisct1@users.noreply.github.comFrank Denis <124872+jedisct1@users.noreply.github.com> 2021-03-16 18:55:58+01:00
logd1b1e542a032b8f2323c0cdd808088310c693051
treedc2eccff7271ef866bf192526659b910109db18c
parent6787f163eb6db2b8b89c2ea6cb51d63606487e12

crypto/pbkdf2: simplify the check for the max number of iterations


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

lib/std/crypto/pbkdf2.zig+2-2
...@@ -67,8 +67,8 @@ pub fn pbkdf2(derivedKey: []u8, password: []const u8, salt: []const u8, rounds:...@@ -67,8 +67,8 @@ pub fn pbkdf2(derivedKey: []u8, password: []const u8, salt: []const u8, rounds:
67 // 1. If dkLen > maxInt(u32) * hLen, output "derived key too long" and67 // 1. If dkLen > maxInt(u32) * hLen, output "derived key too long" and
68 // stop.68 // stop.
69 //69 //
70 if (comptime (maxInt(usize) > maxInt(u32) * hLen) and (dkLen > @as(usize, maxInt(u32) * hLen))) {70 if (dkLen / hLen >= maxInt(u32)) {
71 // If maxInt(usize) is less than `maxInt(u32) * hLen` then dkLen is always inbounds71 // Counter starts at 1 and is 32 bit, so if we have to return more blocks, we would overflow
72 return error.OutputTooLong;72 return error.OutputTooLong;
73 }73 }
7474