| author | |
| committer | |
| log | db5aa6cff7f497dbb2ba7422260eea343bd5b248 |
| tree | b434bf6a90f5ef0cb7a146f674cf0e714ee71923 |
| parent | ba450411c0e4086819d0790cc3ae4371823a323e |
Round numbers that were not a multiple of 3 caused an OOB.
Nothing in the standard library uses a number of round that is
not 12 or 24, and these are the only values used in current
specifications.
But we should be future proof and we already provide an API
that's expected to work with any number of rounds, so honor that.1 files changed, 2 insertions(+), 1 deletions(-)
lib/std/crypto/keccak_p.zig+2-1| ... | ... | @@ -177,8 +177,9 @@ pub fn KeccakF(comptime f: u11) type { |
| 177 | 177 | |
| 178 | 178 | /// Apply a (possibly) reduced-round permutation to the state. |
| 179 | 179 | pub fn permuteR(self: *Self, comptime rounds: u5) void { |
| 180 | comptime assert(rounds <= max_rounds); // Keccak only supports up to 24 rounds | |
| 180 | 181 | var i = RC.len - rounds; |
| 181 | while (i < RC.len - RC.len % 3) : (i += 3) { | |
| 182 | while (i < RC.len - rounds % 3) : (i += 3) { | |
| 182 | 183 | self.round(RC[i]); |
| 183 | 184 | self.round(RC[i + 1]); |
| 184 | 185 | self.round(RC[i + 2]); |