Skip to content

Commit

Permalink
Fix an overflow in Streebog causing panic or incorrect output (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-fortanix authored and newpavlov committed Nov 6, 2019
1 parent 7f3080b commit 9695573
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions streebog/src/streebog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,10 @@ impl StreebogState {
}

fn update_sigma(&mut self, m: &Block) {
let mut over = false;
let mut carry = 0;
for (a, b) in self.sigma.iter_mut().zip(m.iter()) {
let (res, loc_over) = (*a).overflowing_add(*b);
*a = res;
if over { *a += 1; }
over = loc_over;
carry = (*a as u16) + (*b as u16) + (carry >> 8);
*a = (carry & 0xFF) as u8;
}
}

Expand Down

0 comments on commit 9695573

Please sign in to comment.