refactor block
This commit is contained in:
parent
c7b4502db0
commit
76695723ed
1 changed files with 10 additions and 0 deletions
10
src/lib.rs
10
src/lib.rs
|
|
@ -38,6 +38,10 @@ impl Block {
|
|||
|
||||
pub fn advance(&mut self) {
|
||||
self.counter += 1;
|
||||
self.compute_block();
|
||||
}
|
||||
|
||||
fn compute_block(&mut self) {
|
||||
self.chunk = few_u32_to_many_u8(&chacha_block(&self.key, self.counter, self.nonce, self.rounds));
|
||||
}
|
||||
|
||||
|
|
@ -53,6 +57,12 @@ impl Block {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn reset(&mut self, next_nonce: [u32; 3]) {
|
||||
self.counter = 0;
|
||||
self.nonce = next_nonce;
|
||||
self.compute_block();
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue