Skip to content

cipher: rename BlockCipher*/BlockMode*#1482

Merged
tarcieri merged 2 commits intomasterfrom
cipher/rename-block-cipher-traits
Jan 21, 2024
Merged

cipher: rename BlockCipher*/BlockMode*#1482
tarcieri merged 2 commits intomasterfrom
cipher/rename-block-cipher-traits

Conversation

@tarcieri
Copy link
Member

Renames the following traits:

  • BlockEncrypt => BlockCipherEncrypt
  • BlockDecrypt => BlockCipherDecrypt
  • BlockEncryptMut => BlockModeEncrypt
  • BlockDecryptMut => BlockModeDecrypt

As originally suggested in this comment:

RustCrypto/block-modes#14 (comment)

This better reflects how these traits are actually used, i.e. BlockCipher* is used by ciphers, and BlockMode* is used by their modes of operation.

Renames the following traits:

- `BlockEncrypt` => `BlockCipherEncrypt`
- `BlockDecrypt` => `BlockCipherDecrypt`
- `BlockEncryptMut` => `BlockModeEncrypt`
- `BlockDecryptMut` => `BlockModeDecrypt`

As originally suggested in this comment:

RustCrypto/block-modes#14 (comment)

This better reflects how these traits are actually used, i.e.
`BlockCipher*` is used by ciphers, and `BlockMode*` is used by their
modes of operation.
@tarcieri tarcieri requested a review from newpavlov January 21, 2024 21:56
@tarcieri tarcieri changed the title [WIP] cipher: rename BlockCipher*/BlockMode* cipher: rename BlockCipher*/BlockMode* Jan 21, 2024
Copy link
Member

@newpavlov newpavlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's worth to remove the _mut suffixes from BlockMode* method names? It may cause issues when both BlockMode* and BlockCipher* imported simultaneously, but I think it's a relatively rare situation in user code.

@tarcieri tarcieri merged commit 7ae1519 into master Jan 21, 2024
@tarcieri tarcieri deleted the cipher/rename-block-cipher-traits branch January 21, 2024 23:30
@tarcieri
Copy link
Member Author

Hmm, guess I should've prepared a branch of https://github.com/rustcrypto/block-ciphers first because this is causing all sorts of wacky breakages including macro invocation failures like:

error: expected one of `!`, `(`, `+`, `::`, `<`, `for`, `where`, or `{`, found `:`
   --> sm4/src/lib.rs:127:1
    |
127 | / cipher::impl_simple_block_encdec!(
128 | |     Sm4, U16, cipher, block,
129 | |     encrypt: {
130 | |         let b = block.get_in();
...   |
174 | |     }
175 | | );
    | | ^
    | | |
    | |_expected one of 8 possible tokens
    |   in this macro invocation

tarcieri added a commit that referenced this pull request Jan 22, 2024
The branch was never tested against the block ciphers repo located at
https://github.com/rustcrypto/block-ciphers

There were various errors and missed changes in macros which were
required to get everything to compile.

This includes fixes and has been tested against the downstream repo.
@tarcieri
Copy link
Member Author

#1483 contains fixes to errors/omissions in this PR

tarcieri added a commit that referenced this pull request Jan 22, 2024
The branch was never tested against the block ciphers repo located at
https://github.com/rustcrypto/block-ciphers

There were various errors and missed changes in macros which were
required to get everything to compile.

This includes fixes and has been tested against the downstream repo.
tarcieri added a commit to RustCrypto/block-ciphers that referenced this pull request Jan 22, 2024
Updates the previous `BlockEncrypt`/`BlockEncrypt` trait names to use
the new ones introduced in RustCrypto/traits#1482
tarcieri added a commit to RustCrypto/block-ciphers that referenced this pull request Jan 22, 2024
Updates the previous `BlockEncrypt`/`BlockEncrypt` trait names to use
the new ones introduced in RustCrypto/traits#1482
@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.

2 participants