Skip to content

cipher: add traits for tweakable block ciphers#1721

Merged
newpavlov merged 2 commits intomasterfrom
tweak
Jan 30, 2025
Merged

cipher: add traits for tweakable block ciphers#1721
newpavlov merged 2 commits intomasterfrom
tweak

Conversation

@newpavlov
Copy link
Member

@newpavlov newpavlov commented Dec 4, 2024

The trait design generally follows the BlockCipherEnc/Dec traits. We currently do not have tweakable block cipher implementations which use the backend capability, but I think it's still worth to include it for API consistency and to future-proof the traits. Some of the helper methods (e.g. encrypt_blocks) are not translated since it's unclear how to organize passing of tweaks. Arguably, such methods should not be used with tweakable block ciphers either way.

As a bridge between tweakable and non-tweakable traits the ZeroTweak wrapper is introduced. It allows users to use tweakable block cipher implementations with the parts of the ecosystem which expects non-tweakble block ciphers while still being explicit in the code (e.g. ZeroTweak<Threefish256>).

Closes #177

@newpavlov newpavlov requested a review from tarcieri December 4, 2024 13:41
@newpavlov newpavlov merged commit 1a770af into master Jan 30, 2025
10 checks passed
@newpavlov newpavlov deleted the tweak branch January 30, 2025 20:15
@tarcieri tarcieri mentioned this pull request Feb 4, 2026
tarcieri added a commit that referenced this pull request Feb 4, 2026
### Added
- Traits for tweakable block ciphers (#1721)
- Methods for writing keystream (#1907)

### Changed
- Replaced `generic-array` with `hybrid-array` (#1358)
- Rename `BlockCipher*`/`BlockMode*` (#1482)
  - `BlockEncrypt` => `BlockCipherEncrypt`
  - `BlockDecrypt` => `BlockCipherDecrypt`
  - `BlockEncryptMut` => `BlockModeEncrypt`
  - `BlockDecryptMut` => `BlockModeDecrypt`
- Split `BlockBackend` traits into 4 specific traits: (#1636)
  - `BlockCipherEncBackend`
  - `BlockCipherDecBackend`
  - `BlockModeEncBackend`
  - `BlockModeDecBackend`
- Edition changed to 2024 and MSRV bumped to 1.85 (#1759)
- Use `block_buffer::ReadBuffer` in `StreamCipherCoreWrapper` (#1959)
- Re-export of `crypto-common` moved to `cipher::common` (#2237, #2260)
- `crypto-common` dependency bumped to v0.2 (#2276)
- `blobby` requirement bumped to v0.4 (#2147)
- `inout` dependency bumped to v0.2.2 (#2149)

### Fixed
- Bugs in `StreamCipherCoreWrapper` trait implementations (#1421)
- Seeking implementation in the stream cipher wrapper (#2052)

### Removed
- `std` feature (#1691)
- `BlockCipherEncrypt::encrypt_padded*` and
`BlockCipherDecrypt::decrypt_padded*` methods.
Users of the ECB mode should use the `ecb-mode` crate instead. (#2245)
- `AsyncStreamCipher` trait (#2280)
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.

Trait for tweakable block ciphers

2 participants