You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The root cause appears to be a combination of the incorrect looping counter behavior highlighted in RustCrypto/stream-ciphers#391 and from the behavior of try_seek in StreamCipherCoreWrapper. try_seek sets the block position to (((256u64 << 30)-63) / 64) as u32, which is u32::MAX, and then calls write_keystream_block, which increments the counter, causing it to loop back to 0. Then the try_current_pos calls get_block_pos(), which returns 0 -- see
As explained here, it's an artifact of how we generically detect wrapping of keystream. We could change the code to properly detect wrapping around 0, but it has to be done in the cipher crate.
newpavlov
changed the title
chacha20: Seeking near the end of the keystream causes try_current_pos to return an error
cipher: Seeking near the end of the keystream causes try_current_pos to return an error
Apr 2, 2025
The following test fails on the last line:
The root cause appears to be a combination of the incorrect looping counter behavior highlighted in RustCrypto/stream-ciphers#391 and from the behavior of
try_seek
inStreamCipherCoreWrapper
.try_seek
sets the block position to(((256u64 << 30)-63) / 64) as u32
, which isu32::MAX
, and then callswrite_keystream_block
, which increments the counter, causing it to loop back to 0. Then thetry_current_pos
callsget_block_pos()
, which returns 0 -- seetraits/cipher/src/stream/wrapper.rs
Lines 176 to 202 in 67131af
SeekNum::get_block_byte
is then called with a value of 0 for theblock
parameter, and the checked subtraction on this line returnsNone
.The text was updated successfully, but these errors were encountered: