Skip to content

Conversation

@tarcieri
Copy link
Member

Allow cloning on a stream cipher or RNG is problematic because it duplicates internal states, which can lead to keystream reuse / RNG output duplication, which in cryptographic contexts can be catastrophic.

Instead, for things like tests ciphers can be initialized from the same seed repeatedly, which is what this PR changes the e.g. chacha20 tests to do. This is a much more explicit way of deliberately duplicating stream ciphers/RNGs for the purposes of testing.

See also:

Allow cloning on a stream cipher or RNG is problematic because it
duplicates internal states, which can lead to keystream reuse / RNG
output duplication, which in cryptographic contexts can be catastrophic.

Instead, for things like tests ciphers can be initialized from the same
seed repeatedly, which is what this PR changes the e.g. `chacha20` tests
to do. This is a much more explicit way of deliberately duplicating
stream ciphers/RNGs for the purposes of testing.

See also:
- #220
- #461
- RustCrypto/block-modes/pull/91
- rust-random/rand#1101
@tarcieri tarcieri merged commit 9f095c4 into master Sep 11, 2025
41 checks passed
@tarcieri tarcieri deleted the remove-clone-impls branch September 11, 2025 15:22
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.

3 participants