Skip to content

Conversation

@newpavlov
Copy link
Member

The change forbids seeking to the last keystream block and its application.

TODO: explicitly document that the wrapper forbids generation of the last keystream block

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.

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