Skip to content

Conversation

@newpavlov
Copy link
Member

Cloning of a block mode state can be considered a footgun. If state has to be cloned for some reason, users should prefer passing key/IV instead (see the IvState trait).

Previous discussion: rust-random/rand#1101

Note that we previously had people complaining about Clone: #23

@newpavlov newpavlov requested a review from tarcieri September 10, 2025 00:22
@newpavlov newpavlov merged commit 0f92e05 into master Sep 10, 2025
58 checks passed
@newpavlov newpavlov deleted the rm_clone branch September 10, 2025 00:27
tarcieri added a commit to RustCrypto/stream-ciphers that referenced this pull request Sep 11, 2025
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 added a commit to RustCrypto/stream-ciphers that referenced this pull request Sep 11, 2025
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 added a commit to RustCrypto/stream-ciphers that referenced this pull request Sep 11, 2025
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
dfvgbh added a commit to dfvgbh/stream-siphers that referenced this pull request Oct 4, 2025
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 added a commit to RustCrypto/SSH that referenced this pull request Nov 8, 2025
#266)"

This reverts commit ab1f278.

The latest versions of `cbc` and `ctr` no longer impl `Clone`
deliberately, so this can no longer be implemented in this manner:
RustCrypto/block-modes#91

The cipher needs to be fully reinitialized from the original key
instead.
tarcieri added a commit to RustCrypto/SSH that referenced this pull request Nov 8, 2025
This reverts commit ab1f278 (#266).

The latest versions of `cbc` and `ctr` no longer impl `Clone`
deliberately, so this can no longer be implemented in this manner:
RustCrypto/block-modes#91

The cipher needs to be fully reinitialized from the original key
instead.
tarcieri added a commit to RustCrypto/SSH that referenced this pull request Nov 8, 2025
…e" (#416)

This reverts commit ab1f278 (#266).

The latest versions of `cbc` and `ctr` no longer impl `Clone`
deliberately, so this can no longer be implemented in this manner:
RustCrypto/block-modes#91

The cipher needs to be fully reinitialized from the original key
instead.
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