Skip to content

Conversation

@newpavlov
Copy link
Member

@newpavlov newpavlov commented Oct 29, 2025

The change forbids seeking to the last keystream block and its application. Additionally, unchecked methods added as an escape hatch.

Closes #1808

@newpavlov newpavlov requested a review from tarcieri October 29, 2025 17:43
@tarcieri
Copy link
Member

Is this really a fix for #1808? I would think a real fix would make the last keystream block usable

@newpavlov
Copy link
Member Author

newpavlov commented Oct 29, 2025

See my comment in the issue. I spent a significant time trying to implement the last byte approach, but I couldn't get a satisfying solution.

@newpavlov
Copy link
Member Author

newpavlov commented Oct 29, 2025

Another alternative could be to add a special "exhausted" state to the wrapper (either as a separate field, or as part of ReadBuffer), but I don't quite like it either. Adding the field would make all buffered stream cipher implementations bigger (often by more than one byte because of alignment), while modifying ReadBuffer would mean that we need to check the special case every time. Also, I would like to keep the block-buffer code as simple as possible.

Considering that users arguably should not rely on the last keystream block in practice, I am not sure it's worth the trouble.

@newpavlov
Copy link
Member Author

@tarcieri
Could you take a look at the updated docs?

Copy link
Member

@tarcieri tarcieri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs look good to me

@newpavlov newpavlov merged commit 00a29f8 into master Nov 7, 2025
11 checks passed
@newpavlov newpavlov deleted the cipher/fix_stream_seek branch November 7, 2025 17:03
newpavlov added a commit that referenced this pull request Nov 7, 2025
newpavlov added a commit that referenced this pull request Nov 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cipher: Seeking near the end of the keystream causes try_current_pos to return an error

3 participants