| ... | ... | @@ -59,15 +59,15 @@ pub fn pbkdf2(derivedKey: []u8, password: []const u8, salt: []const u8, rounds: |
| 59 | 59 | |
| 60 | 60 | const dkLen = derivedKey.len; |
| 61 | 61 | const hLen = Prf.mac_length; |
| 62 | comptime std.debug.assert(hLen >= 1); |
| 62 | 63 | |
| 63 | 64 | // FromSpec: |
| 64 | 65 | // |
| 65 | 66 | // 1. If dkLen > maxInt(u32) * hLen, output "derived key too long" and |
| 66 | 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 | 70 | // If maxInt(usize) is less than `maxInt(u32) * hLen` then dkLen is always inbounds |
| 70 | | // This also asserts hLen >= 1 |
| 71 | 71 | return error.DerivedKeyTooLong; |
| 72 | 72 | } |
| 73 | 73 | |