Skip to content

Commit c80434b

Browse files
committed
Tweak RNG max-counter assert
1 parent 6931e7f commit c80434b

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

chacha20/src/rng.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rand_core::{CryptoRng, Error, RngCore, SeedableRng};
66
use crate::{
77
backend::{Core, BUFFER_SIZE},
88
rounds::{R12, R20, R8},
9-
KEY_SIZE, MAX_BLOCKS,
9+
KEY_SIZE,
1010
};
1111
use core::convert::TryInto;
1212

@@ -74,7 +74,8 @@ macro_rules! impl_chacha_rng {
7474
type Results = [u32; BUFFER_SIZE / 4];
7575

7676
fn generate(&mut self, results: &mut Self::Results) {
77-
assert!(self.counter <= MAX_BLOCKS as u64, "maximum number of allowed ChaCha blocks exceeded");
77+
// is this necessary?
78+
assert!(self.counter < u32::MAX as u64, "maximum number of allowed ChaCha blocks exceeded");
7879

7980
let mut buffer = [0u8; BUFFER_SIZE];
8081
self.block.generate(self.counter, &mut buffer);

0 commit comments

Comments
 (0)