Skip to content

ChaCha20 (legacy, xchacha): full 64bit counters#217

Merged
tarcieri merged 13 commits intoRustCrypto:masterfrom
jpdoyle:64bit-counters
Jan 11, 2021
Merged

ChaCha20 (legacy, xchacha): full 64bit counters#217
tarcieri merged 13 commits intoRustCrypto:masterfrom
jpdoyle:64bit-counters

Conversation

@jpdoyle
Copy link
Contributor

@jpdoyle jpdoyle commented Jan 8, 2021

This:

  • adds a Rounds-style tag trait for different possible values of MAX_BLOCKS
  • converts check_data_len to an overflow-friendly version which can check 64-bit counters without requiring 128bit arithmetic
  • adds tests exercising the 64-bit counters of ChaCha20Legacy and XChaCha20.
    closes XChaCha20 unnecessarily limits keystream to 256gb #213

Tests 1, 2, 3, 6, and 7 fail. I suspect they behave differently with the
`avx2` backend since it depends on where the boundary of the buffer is.
I don't think it's easy to exploit this unless you're trying really
hard. That said, I believe it's possible for sufficiently determined
user code to bypass the MAX_BLOCKS check and generate looped/overflowed
keystream past 256GB.
@jpdoyle
Copy link
Contributor Author

jpdoyle commented Jan 8, 2021

I left the assert!() call that prevents more than 256GB of random number generation in. However, I'm not sure it's necessary, and it seems like the kind of panic that might cause problems downstream.

@tarcieri tarcieri merged commit 119c9f4 into RustCrypto:master Jan 11, 2021
@tarcieri
Copy link
Member

Thanks!

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.

XChaCha20 unnecessarily limits keystream to 256gb

2 participants