Skip to content

cipher: rework backend traits#1636

Merged
newpavlov merged 12 commits intomasterfrom
block_backends
Aug 14, 2024
Merged

cipher: rework backend traits#1636
newpavlov merged 12 commits intomasterfrom
block_backends

Conversation

@newpavlov
Copy link
Member

@newpavlov newpavlov commented Jul 31, 2024

This PR splits BlockBackend traits into 4 specific traits: BlockCipherEncBackend, BlockCipherDecBackend, BlockModeEncBackend, and BlockModeDecBackend. Same for BlockClosure. This allows for cipher backends to remove awkard &mut &backend juggling (see RustCrypto/block-ciphers#442), makes code a bit easier to read (i.e. encrypt_blocks instead of proc_blocks), and allows for one backend type to be used for both encryption and decryption.

The impl_simple_block_encdec macro is removed since we now can implement the backend traits directly on cipher types, which should make implementation crates slightly easier to understand.

Additionally, it moves traits to the block and cipher modules to reduce clutter in the crate root. Later we can add docs to each module to describe the traits in detail.

@newpavlov newpavlov requested a review from tarcieri July 31, 2024 19:53
@newpavlov newpavlov merged commit 3ebd677 into master Aug 14, 2024
@newpavlov newpavlov deleted the block_backends branch August 14, 2024 13:40
@tarcieri tarcieri mentioned this pull request Feb 3, 2026
newpavlov pushed a commit that referenced this pull request Feb 4, 2026
### Added
- Sealed `BlockSizes` trait implemented for types from `U1` to `U255`
([#1172])
- `SerializableState` trait under `hazmat` module ([#1369])
- `OutputSize` type alias ([#1533])
- `IvState` trait ([#1636])
- `core::error::Error` impls for error types ([#1660])
- `Generate` trait as a common RNG API ([#2096], [#2145])
- `TryKeyInit` trait ([#2097])
- Re-export `getrandom` ([#2152])
- `KeyExport` trait ([#2213])

### Changed
- Replaced `generic-array` with `hybrid-array` ([#1319], [#1976])
- `BlockUser::BlockSize` is now bounded by the `BlockSizes` trait
- Edition changed to 2024 and MSRV bumped to 1.85 ([#1759])
- `generate_*` methods on `KeyInit` and `KeyIvInit` traits have been
deprecated in favor of the
  new `Generate` trait ([#2162])
- Bump `rand_core` to v0.10 ([#2250])
- Bump `getrandom` to v0.4 ([#2258])

### Removed
- `std` feature ([#1680])

[#1172]: #1172
[#1319]: #1319
[#1369]: #1369
[#1533]: #1533
[#1636]: #1636
[#1660]: #1660
[#1680]: #1680
[#1759]: #1759
[#1976]: #1976
[#2096]: #2096
[#2097]: #2097
[#2145]: #2145
[#2152]: #2152
[#2162]: #2162
[#2213]: #2213
[#2250]: #2250
[#2258]: #2258
@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.

1 participant