Skip to content

Commit

Permalink
blake2b/s: simplify update
Browse files Browse the repository at this point in the history
  • Loading branch information
kazcw committed Jan 23, 2019
1 parent 718f57e commit c5df7a5
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions blake2/src/blake2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,25 +311,13 @@ macro_rules! blake2_impl {
.expect("hash data length overflow");
}

while rest.len() >= block {
for part in rest.chunks(block) {
self.h.compress(&self.m, 0, 0, self.t);

let part = &rest[..block];
rest = &rest[part.len()..];

copy(part, &mut self.m.as_mut_bytes());
self.t = self.t.checked_add(part.len() as u64)
.expect("hash data length overflow");
}

let n = rest.len();
if n > 0 {
self.h.compress(&self.m, 0, 0, self.t);

copy(rest, &mut self.m.as_mut_bytes());
self.t = self.t.checked_add(rest.len() as u64)
.expect("hash data length overflow");
}
}

#[doc(hidden)]
Expand Down

0 comments on commit c5df7a5

Please sign in to comment.