x.crypto.chacha20: makes 64-bit counter cipher works as an expected #25363
Merged
Conversation
…ith firebird test
Contributor
|
It seems to work well, good work! |
einar-hjortdal
added a commit
to einar-hjortdal/firebird
that referenced
this pull request
Sep 23, 2025
Contributor
Author
Glad to know its working for you. Thank you for testing it |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR was motivated by discord disccussion here, especially, for firebird client testing by @einar-hjortdal with 64-bit counter chacha20 cipher that does not works as an expected previously. This patch was inspired from nakagami chacha20 used by golang firebird client in golang firebirdsql. Its adapted into existing
x.crypto.chacha20implementation.This PR contains:
xor_key_streambuilding block with the new one. Its splitted out keystream generation and xoring bytes into separated logic. Previously, its falls on the samekeystream_with_blocksizeroutine. With this patch, key stream generation separated intoStream.keystream, focussing on keystream generation and updating internal counter, where xor-ing messages happens onxor_key_streamand orkeystream_fullhelper.xor_key_streamshow a nice improvement, from ±53.430ms down into ±43.668ms. The benchmark also added intobench/bench.vfile. It also make it more simpler and readable.Stream.inc_ctrCipher.resetmethod for deprecation. It intended for internal use, See some possibles culprits of this misbehaved calls tested by @tankf33der at here. Thanks to @tankf33der 👍After this patch applied, in my testing for v firebird client with 64-bit counter activated, the tests was passed successfully. @einar-hjortdal: can you give it a try ?
Cheers,
thanks