[WIP] 64-bit counters for legacy and XChaCha variants, fix looping counter regressions #399
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 is still WIP. So far it is basically a PoC of what is needed to perform these changes.
The overall checklist before merging is:
Ietf
ChaCha20traits
so that there is an explicit representation of a looped/saturated counter. Currently the implementation of StreamCipherCoreWrapper does not allow me to directly implement a cipher that stops once it would loop; in the current implementation I get around this by effectively using a 64-bit counter for the 32-bit counter mode, which allows me to distinguish between a just-initialized cipher (block_pos = 0, pos = 64
) and a looped cipher (block_pos = 2**32, pos = 64
). Note that this does not currently allow correct behavior at the end of a 64-bit-counter keystream.Ietf
variant to use a 32-bit counter again, fixing thebad_overflow_check{6,7}
seek-focused testsSeekNum::from_block_byte
intraits
to match the looped counter representation, thereby fixing cipher: Seeking near the end of the keystream causestry_current_pos
to return an error traits#1808. (NOTE: the test in that issue is present in this PR, and succeeds; that is because I use a 64-bit overall counter even in 32-bitIetf
mode)This would close #334, #391.