Skip to content

Commit

Permalink
cipher: rework backend traits (#1636)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
newpavlov authored Aug 14, 2024
1 parent f1ae691 commit 3ebd677
Show file tree
Hide file tree
Showing 13 changed files with 472 additions and 281 deletions.
58 changes: 41 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions cipher/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "cipher"
description = "Traits for describing block ciphers and stream ciphers"
version = "0.5.0-pre.6"
version = "0.5.0-pre.7"
authors = ["RustCrypto Developers"]
license = "MIT OR Apache-2.0"
readme = "README.md"
Expand All @@ -13,18 +13,19 @@ keywords = ["crypto", "block-cipher", "stream-cipher", "trait"]
categories = ["cryptography", "no-std"]

[dependencies]
crypto-common = "0.2.0-rc.0"
crypto-common = { version = "0.2.0-rc.1", path = "../crypto-common/" }
inout = "0.2.0-rc.0"

# optional dependencies
blobby = { version = "0.3", optional = true }
zeroize = { version = "1.7", optional = true, default-features = false }
zeroize = { version = "1.8", optional = true, default-features = false }

[features]
alloc = []
std = ["alloc", "crypto-common/std", "inout/std"]
block-padding = ["inout/block-padding"]
rand_core = ["crypto-common/rand_core"] # Enable random key and IV generation methods
# Enable random key and IV generation methods
rand_core = ["crypto-common/rand_core"]
dev = ["blobby"]

[package.metadata.docs.rs]
Expand Down
Loading

0 comments on commit 3ebd677

Please sign in to comment.