diff --git a/chacha20_poly1305/src/chacha20.rs b/chacha20_poly1305/src/chacha20.rs index 34f041304..a93e0f1e6 100644 --- a/chacha20_poly1305/src/chacha20.rs +++ b/chacha20_poly1305/src/chacha20.rs @@ -328,11 +328,8 @@ impl ChaCha20 { } } - /// Get the keystream block at a specified block. - pub fn get_keystream(&mut self, block: u32) -> [u8; 64] { - self.block(block); - self.keystream_at_block(self.block_count) - } + /// Get the keystream for specified block. + pub fn get_keystream(&self, block: u32) -> [u8; 64] { self.keystream_at_block(block) } /// Update the index of the keystream to the given byte. pub fn seek(&mut self, seek: u32) { diff --git a/chacha20_poly1305/src/lib.rs b/chacha20_poly1305/src/lib.rs index 42b2df3af..1627b511e 100644 --- a/chacha20_poly1305/src/lib.rs +++ b/chacha20_poly1305/src/lib.rs @@ -118,7 +118,7 @@ impl ChaCha20Poly1305 { tag: [u8; 16], aad: Option<&[u8]>, ) -> Result<(), Error> { - let mut chacha = ChaCha20::new_from_block(self.key, self.nonce, 0); + let chacha = ChaCha20::new_from_block(self.key, self.nonce, 0); let keystream = chacha.get_keystream(0); let mut poly = Poly1305::new(keystream[..32].try_into().expect("slicing produces 32-byte slice"));