Skip to content

Commit 2b52044

Browse files
committed
used the const BUF_BLOCKS
1 parent 440e634 commit 2b52044

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

chacha20/src/rng.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ macro_rules! impl_chacha_rng {
336336
let mut block_counter = (u64::from(self.core.core.0.state[13]) << 32)
337337
| u64::from(self.core.core.0.state[12]);
338338
if self.core.word_offset() != 0 {
339-
block_counter = block_counter.wrapping_sub(4);
339+
block_counter = block_counter.wrapping_sub(BUF_BLOCKS as u64);
340340
}
341341
let word_pos =
342342
block_counter as u128 * BLOCK_WORDS as u128 + self.core.word_offset() as u128;
@@ -391,7 +391,7 @@ macro_rules! impl_chacha_rng {
391391
let counter =
392392
self.core.core.0.state[12] as u64 | ((self.core.core.0.state[13] as u64) << 32);
393393
if self.core.word_offset() != 0 {
394-
counter - 4 + self.core.word_offset() as u64 / 16
394+
counter - BUF_BLOCKS as u64 + self.core.word_offset() as u64 / 16
395395
} else {
396396
counter
397397
}

0 commit comments

Comments
 (0)