diff --git a/.github/workflows/belt-mac.yml b/.github/workflows/belt-mac.yml index 1f538b3..44c5692 100644 --- a/.github/workflows/belt-mac.yml +++ b/.github/workflows/belt-mac.yml @@ -22,7 +22,7 @@ jobs: strategy: matrix: rust: - - 1.57.0 # MSRV + - 1.71.0 # MSRV - stable target: - thumbv7em-none-eabi @@ -37,6 +37,8 @@ jobs: - run: cargo build --no-default-features --release --target ${{ matrix.target }} minimal-versions: + # disabled until belt-block gets published + if: false uses: RustCrypto/actions/.github/workflows/minimal-versions.yml@master with: working-directory: ${{ github.workflow }} @@ -46,7 +48,7 @@ jobs: strategy: matrix: rust: - - 1.57.0 # MSRV + - 1.71.0 # MSRV - stable steps: - uses: actions/checkout@v4.1.1 diff --git a/.github/workflows/cbc-mac.yml b/.github/workflows/cbc-mac.yml index 65cf533..cdf3fa1 100644 --- a/.github/workflows/cbc-mac.yml +++ b/.github/workflows/cbc-mac.yml @@ -23,7 +23,7 @@ jobs: strategy: matrix: rust: - - 1.56.0 # MSRV + - 1.71.0 # MSRV - stable target: - thumbv7em-none-eabi @@ -38,6 +38,8 @@ jobs: - run: cargo build --no-default-features --release --target ${{ matrix.target }} minimal-versions: + # disabled until belt-block gets published + if: false uses: RustCrypto/actions/.github/workflows/minimal-versions.yml@master with: working-directory: ${{ github.workflow }} @@ -47,7 +49,7 @@ jobs: strategy: matrix: rust: - - 1.56.0 # MSRV + - 1.72.0 # MSRV - stable steps: - uses: actions/checkout@v4.1.1 diff --git a/.github/workflows/cmac.yml b/.github/workflows/cmac.yml index ac54281..5150c83 100644 --- a/.github/workflows/cmac.yml +++ b/.github/workflows/cmac.yml @@ -22,7 +22,7 @@ jobs: strategy: matrix: rust: - - 1.56.0 # MSRV + - 1.71.0 # MSRV - stable target: - thumbv7em-none-eabi @@ -37,6 +37,8 @@ jobs: - run: cargo build --no-default-features --release --target ${{ matrix.target }} minimal-versions: + # disabled until belt-block gets published + if: false uses: RustCrypto/actions/.github/workflows/minimal-versions.yml@master with: working-directory: ${{ github.workflow }} @@ -46,7 +48,7 @@ jobs: strategy: matrix: rust: - - 1.56.0 # MSRV + - 1.72.0 # MSRV - stable steps: - uses: actions/checkout@v4.1.1 diff --git a/.github/workflows/pmac.yml b/.github/workflows/pmac.yml index 812bb81..7e40b4b 100644 --- a/.github/workflows/pmac.yml +++ b/.github/workflows/pmac.yml @@ -22,7 +22,7 @@ jobs: strategy: matrix: rust: - - 1.56.0 # MSRV + - 1.71.0 # MSRV - stable target: - thumbv7em-none-eabi @@ -37,6 +37,8 @@ jobs: - run: cargo build --no-default-features --release --target ${{ matrix.target }} minimal-versions: + # disabled until belt-block gets published + if: false uses: RustCrypto/actions/.github/workflows/minimal-versions.yml@master with: working-directory: ${{ github.workflow }} @@ -46,7 +48,7 @@ jobs: strategy: matrix: rust: - - 1.56.0 # MSRV + - 1.72.0 # MSRV - stable steps: - uses: actions/checkout@v4.1.1 diff --git a/.github/workflows/workspace.yml b/.github/workflows/workspace.yml index cfaba69..f7f6866 100644 --- a/.github/workflows/workspace.yml +++ b/.github/workflows/workspace.yml @@ -17,7 +17,7 @@ jobs: - uses: RustCrypto/actions/cargo-cache@master - uses: dtolnay/rust-toolchain@master with: - toolchain: 1.71.0 + toolchain: 1.72.0 components: clippy - run: cargo clippy --all -- -D warnings diff --git a/Cargo.lock b/Cargo.lock index ddecc1f..30ec07c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,8 @@ version = 3 [[package]] name = "aes" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" +version = "0.9.0-pre" +source = "git+https://github.com/baloo/block-ciphers.git?branch=baloo/bump-cipher/0.5.0-pre.4#bb94e5e71f5320fcaab727ad0c503cca5190da4c" dependencies = [ "cfg-if", "cipher", @@ -15,16 +14,15 @@ dependencies = [ [[package]] name = "belt-block" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9aa1eef3994e2ccd304a78fe3fea4a73e5792007f85f09b79bb82143ca5f82b" +version = "0.2.0-pre" +source = "git+https://github.com/baloo/block-ciphers.git?branch=baloo/bump-cipher/0.5.0-pre.4#bb94e5e71f5320fcaab727ad0c503cca5190da4c" dependencies = [ "cipher", ] [[package]] name = "belt-mac" -version = "0.1.0" +version = "0.2.0-pre" dependencies = [ "belt-block", "cipher", @@ -40,16 +38,16 @@ checksum = "847495c209977a90e8aad588b959d0ca9f5dc228096d29a6bd3defd53f35eaec" [[package]] name = "block-buffer" -version = "0.10.4" +version = "0.11.0-pre.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +checksum = "3ded684142010808eb980d9974ef794da2bcf97d13396143b1515e9f0fb4a10e" dependencies = [ - "generic-array", + "crypto-common", ] [[package]] name = "cbc-mac" -version = "0.1.1" +version = "0.2.0-pre" dependencies = [ "aes", "cipher", @@ -66,9 +64,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cipher" -version = "0.4.4" +version = "0.5.0-pre.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +checksum = "84fba98785cecd0e308818a87c817576a40f99d8bab6405bf422bacd3efb6c1f" dependencies = [ "blobby", "crypto-common", @@ -78,7 +76,7 @@ dependencies = [ [[package]] name = "cmac" -version = "0.7.2" +version = "0.8.0-pre" dependencies = [ "aes", "cipher", @@ -101,37 +99,37 @@ dependencies = [ [[package]] name = "crypto-common" -version = "0.1.6" +version = "0.2.0-pre.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +checksum = "b7aa2ec04f5120b830272a481e8d9d8ba4dda140d2cda59b0f1110d5eb93c38e" dependencies = [ - "generic-array", - "typenum", + "getrandom", + "hybrid-array", + "rand_core", ] [[package]] name = "dbl" -version = "0.3.2" +version = "0.4.0-pre.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd2735a791158376708f9347fe8faba9667589d82427ef3aed6794a8981de3d9" +checksum = "977125a36bcb9fcf23cec295ffd25a7499046d5ae95603cd536d4ec1e39bd673" dependencies = [ - "generic-array", + "hybrid-array", ] [[package]] name = "des" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdd80ce8ce993de27e9f063a444a4d53ce8e8db4c1f00cc03af5ad5a9867a1e" +version = "0.9.0-pre" +source = "git+https://github.com/baloo/block-ciphers.git?branch=baloo/bump-cipher/0.5.0-pre.4#bb94e5e71f5320fcaab727ad0c503cca5190da4c" dependencies = [ "cipher", ] [[package]] name = "digest" -version = "0.10.7" +version = "0.11.0-pre.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +checksum = "065d93ead7c220b85d5b4be4795d8398eac4ff68b5ee63895de0a3c1fb6edf25" dependencies = [ "blobby", "block-buffer", @@ -140,13 +138,14 @@ dependencies = [ ] [[package]] -name = "generic-array" -version = "0.14.7" +name = "getrandom" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ - "typenum", - "version_check", + "cfg-if", + "libc", + "wasi", ] [[package]] @@ -161,42 +160,71 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "hmac" +version = "0.13.0-pre.3" +dependencies = [ + "digest", + "hex-literal 0.4.1", + "md-5", + "sha1", + "sha2", + "streebog", +] + +[[package]] +name = "hybrid-array" +version = "0.2.0-rc.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87c2311a0adecbffff284aabcf1249b1485193b16e685f9ef171b1ba82979cff" +dependencies = [ + "typenum", +] + [[package]] name = "inout" -version = "0.1.3" +version = "0.2.0-pre.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +checksum = "0a2cc35b920cc3b344af824e64e508ffc2c819fc2368ed4d253244446194d2fe" dependencies = [ - "generic-array", + "hybrid-array", ] [[package]] name = "kuznyechik" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca7899a524198c60ded686fc826703de2a04470aff9d042e8cc1f845b912c12f" +version = "0.9.0-pre" +source = "git+https://github.com/baloo/block-ciphers.git?branch=baloo/bump-cipher/0.5.0-pre.4#bb94e5e71f5320fcaab727ad0c503cca5190da4c" dependencies = [ "cipher", ] [[package]] name = "libc" -version = "0.2.148" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "magma" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b09bd24ba5fcb427ee21a09e28f9a5e2c2fce78c69af974fb8d373662ceedb4" +version = "0.10.0-pre" +source = "git+https://github.com/baloo/block-ciphers.git?branch=baloo/bump-cipher/0.5.0-pre.4#bb94e5e71f5320fcaab727ad0c503cca5190da4c" dependencies = [ "cipher", ] +[[package]] +name = "md-5" +version = "0.11.0-pre.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "649f2dc52b97a3d781ba9a36dad970f147d55920d17a27735f551b560024f3bf" +dependencies = [ + "cfg-if", + "digest", +] + [[package]] name = "pmac" -version = "0.7.1" +version = "0.8.0-pre" dependencies = [ "aes", "cipher", @@ -204,6 +232,46 @@ dependencies = [ "digest", ] +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "sha1" +version = "0.11.0-pre.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3885de8cb916f223718c1ccd47a840b91f806333e76002dc5cb3862154b4fed3" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha2" +version = "0.11.0-pre.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f33549bf3064b62478926aa89cbfc7c109aab66ae8f0d5d2ef839e482cc30d6" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "streebog" +version = "0.11.0-pre.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "906aaaef0b6bfcf186c7aac662b06a11769e688744323aa6ff3b9f96a5c71c09" +dependencies = [ + "digest", +] + [[package]] name = "subtle" version = "2.5.0" @@ -217,13 +285,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] -name = "version_check" -version = "0.9.4" +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "zeroize" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/Cargo.toml b/Cargo.toml index 6213730..dc510b7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,11 +3,18 @@ members = [ "belt-mac", "cbc-mac", "cmac", - "pmac", -] -exclude = [ "hmac", + "pmac", ] [profile.dev] opt-level = 2 + +[patch.crates-io] +# please re-enable the minimal-versions when you remove those patches. +# https://github.com/RustCrypto/block-ciphers/pull/413 +aes = { git = "https://github.com/baloo/block-ciphers.git", branch = "baloo/bump-cipher/0.5.0-pre.4" } +belt-block = { git = "https://github.com/baloo/block-ciphers.git", branch = "baloo/bump-cipher/0.5.0-pre.4" } +des = { git = "https://github.com/baloo/block-ciphers.git", branch = "baloo/bump-cipher/0.5.0-pre.4" } +kuznyechik = { git = "https://github.com/baloo/block-ciphers.git", branch = "baloo/bump-cipher/0.5.0-pre.4" } +magma = { git = "https://github.com/baloo/block-ciphers.git", branch = "baloo/bump-cipher/0.5.0-pre.4" } diff --git a/belt-mac/Cargo.toml b/belt-mac/Cargo.toml index 5a87489..0263047 100644 --- a/belt-mac/Cargo.toml +++ b/belt-mac/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "belt-mac" -version = "0.1.0" +version = "0.2.0-pre" description = "MAC specified by the BelT standard" authors = ["RustCrypto Developers"] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.57" +rust-version = "1.71" readme = "README.md" documentation = "https://docs.rs/belt-mac" repository = "https://github.com/RustCrypto/MACs" @@ -13,13 +13,13 @@ keywords = ["crypto", "mac", "belt-mac"] categories = ["cryptography", "no-std"] [dependencies] -belt-block = { version = "0.1" } -digest = { version = "0.10.3", features = ["mac"] } -cipher = "0.4" +belt-block = { version = "0.2.0-pre" } +digest = { version = "=0.11.0-pre.8", features = ["mac"] } +cipher = "=0.5.0-pre.4" [dev-dependencies] -cipher = { version = "0.4", features = ["dev"] } -digest = { version = "0.10", features = ["dev"] } +cipher = { version = "=0.5.0-pre.4", features = ["dev"] } +digest = { version = "=0.11.0-pre.8", features = ["dev"] } hex-literal = "0.4" [features] diff --git a/belt-mac/README.md b/belt-mac/README.md index d4bad6c..cdab28e 100644 --- a/belt-mac/README.md +++ b/belt-mac/README.md @@ -11,7 +11,7 @@ Pure Rust implementation of [`belt-mac`]. # Example ```rust -use belt_mac::{BeltMac, Mac}; +use belt_mac::{digest::KeyInit, BeltMac, Mac}; use hex_literal::hex; let key = [0x42; 32]; diff --git a/belt-mac/src/lib.rs b/belt-mac/src/lib.rs index cec1874..7d38019 100644 --- a/belt-mac/src/lib.rs +++ b/belt-mac/src/lib.rs @@ -11,19 +11,19 @@ pub use digest::{self, Mac}; use belt_block::BeltBlock; -use cipher::{BlockBackend, BlockCipher, BlockClosure, BlockEncryptMut}; +use cipher::{BlockBackend, BlockCipher, BlockCipherEncrypt, BlockClosure}; use core::fmt; use digest::{ + array::{ + typenum::{IsLess, Le, NonZero, U256}, + Array, ArraySize, + }, block_buffer::Lazy, core_api::{ AlgorithmName, Block, BlockSizeUser, Buffer, BufferKindUser, CoreWrapper, FixedOutputCore, UpdateCore, }, - crypto_common::{InnerInit, InnerUser}, - generic_array::{ - typenum::{IsLess, Le, NonZero, U256}, - ArrayLength, GenericArray, - }, + crypto_common::{BlockSizes, InnerInit, InnerUser}, MacMarker, Output, OutputSizeUser, Reset, }; @@ -37,7 +37,7 @@ pub type BeltMac = CoreWrapper>; /// Generic core BeltMac instance, which operates over blocks. pub struct BeltMacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, { cipher: C, state: Block, @@ -46,63 +46,63 @@ where impl BlockSizeUser for BeltMacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, { type BlockSize = C::BlockSize; } impl OutputSizeUser for BeltMacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, { type OutputSize = C::BlockSize; } impl InnerUser for BeltMacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, { type Inner = C; } -impl MacMarker for BeltMacCore where C: BlockCipher + BlockEncryptMut + Clone {} +impl MacMarker for BeltMacCore where C: BlockCipher + BlockCipherEncrypt + Clone {} impl InnerInit for BeltMacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, { #[inline] - fn inner_init(mut cipher: C) -> Self { + fn inner_init(cipher: C) -> Self { let state = Default::default(); let mut r = Default::default(); - cipher.encrypt_block_mut(&mut r); + cipher.encrypt_block(&mut r); Self { cipher, state, r } } } impl BufferKindUser for BeltMacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, { type BufferKind = Lazy; } impl UpdateCore for BeltMacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, { #[inline] fn update_blocks(&mut self, blocks: &[Block]) { - struct Ctx<'a, N: ArrayLength> { + struct Ctx<'a, N: BlockSizes> { state: &'a mut Block, blocks: &'a [Block], } - impl<'a, N: ArrayLength> BlockSizeUser for Ctx<'a, N> { + impl<'a, N: BlockSizes> BlockSizeUser for Ctx<'a, N> { type BlockSize = N; } - impl<'a, N: ArrayLength> BlockClosure for Ctx<'a, N> { + impl<'a, N: BlockSizes> BlockClosure for Ctx<'a, N> { #[inline(always)] fn call>(self, backend: &mut B) { for block in self.blocks { @@ -113,13 +113,13 @@ where } let Self { cipher, state, .. } = self; - cipher.encrypt_with_backend_mut(Ctx { state, blocks }) + cipher.encrypt_with_backend(Ctx { state, blocks }) } } impl Reset for BeltMacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, { #[inline(always)] fn reset(&mut self) { @@ -129,14 +129,14 @@ where impl FixedOutputCore for BeltMacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, C::BlockSize: IsLess, Le: NonZero, { #[inline] fn finalize_fixed_core(&mut self, buffer: &mut Buffer, out: &mut Output) { let pos = buffer.get_pos(); - let buf = buffer.pad_with_zeros(); + let mut buf = buffer.pad_with_zeros(); let cipher = &mut self.cipher; let r = &self.r; @@ -160,15 +160,15 @@ where } let mut state = self.state.clone(); - xor(&mut state, buf); + xor(&mut state, &buf); xor(&mut state, &new_r); - cipher.encrypt_block_b2b_mut(&state, out); + cipher.encrypt_block_b2b(&state, out); } } impl AlgorithmName for BeltMacCore where - C: BlockCipher + BlockEncryptMut + Clone + AlgorithmName, + C: BlockCipher + BlockCipherEncrypt + Clone + AlgorithmName, { fn write_alg_name(f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("BeltMac<")?; @@ -179,7 +179,7 @@ where impl fmt::Debug for BeltMacCore where - C: BlockCipher + BlockEncryptMut + Clone + AlgorithmName, + C: BlockCipher + BlockCipherEncrypt + Clone + AlgorithmName, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("BeltMacCore<")?; @@ -192,7 +192,7 @@ where #[cfg_attr(docsrs, doc(cfg(feature = "zeroize")))] impl Drop for BeltMacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, { fn drop(&mut self) { self.state.zeroize(); @@ -202,12 +202,12 @@ where #[cfg(feature = "zeroize")] #[cfg_attr(docsrs, doc(cfg(feature = "zeroize")))] impl ZeroizeOnDrop for BeltMacCore where - C: BlockCipher + BlockEncryptMut + Clone + ZeroizeOnDrop + C: BlockCipher + BlockCipherEncrypt + Clone + ZeroizeOnDrop { } #[inline(always)] -fn xor>(buf: &mut GenericArray, data: &GenericArray) { +fn xor(buf: &mut Array, data: &Array) { for i in 0..N::USIZE { buf[i] ^= data[i]; } diff --git a/cbc-mac/Cargo.toml b/cbc-mac/Cargo.toml index 0afdb7e..bc3840a 100644 --- a/cbc-mac/Cargo.toml +++ b/cbc-mac/Cargo.toml @@ -1,24 +1,24 @@ [package] name = "cbc-mac" -version = "0.1.1" # Also update html_root_url in lib.rs when bumping this +version = "0.2.0-pre" # Also update html_root_url in lib.rs when bumping this description = "Implementation of Cipher Block Chaining Message Authentication Code (CBC-MAC)" authors = ["RustCrypto Developers"] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.56" +rust-version = "1.71" readme = "README.md" documentation = "https://docs.rs/cbc-mac" repository = "https://github.com/RustCrypto/MACs" keywords = ["crypto", "mac", "daa"] [dependencies] -digest = { version = "0.10.3", features = ["mac"] } -cipher = "0.4.2" +digest = { version = "=0.11.0-pre.8", features = ["mac"] } +cipher = "=0.5.0-pre.4" [dev-dependencies] -aes = "0.8" -des = "0.8" -digest = { version = "0.10.3", features = ["dev"] } +aes = "0.9.0-pre" +des = "0.9.0-pre" +digest = { version = "=0.11.0-pre.8", features = ["dev"] } hex-literal = "0.3" [features] diff --git a/cbc-mac/src/lib.rs b/cbc-mac/src/lib.rs index 8c11027..ac57f42 100644 --- a/cbc-mac/src/lib.rs +++ b/cbc-mac/src/lib.rs @@ -7,7 +7,7 @@ //! # Examples //! //! ``` -//! use cbc_mac::{CbcMac, Mac}; +//! use cbc_mac::{digest::KeyInit, CbcMac, Mac}; //! use des::Des; //! use hex_literal::hex; //! @@ -36,19 +36,19 @@ pub use digest::{self, Mac}; -use cipher::{BlockBackend, BlockCipher, BlockClosure, BlockEncryptMut}; +use cipher::{BlockBackend, BlockCipher, BlockCipherEncrypt, BlockClosure}; use core::fmt; use digest::{ + array::{ + typenum::{IsLess, Le, NonZero, U256}, + Array, ArraySize, + }, block_buffer::Eager, core_api::{ AlgorithmName, Block, BlockSizeUser, Buffer, BufferKindUser, CoreWrapper, FixedOutputCore, UpdateCore, }, - crypto_common::{InnerInit, InnerUser}, - generic_array::{ - typenum::{IsLess, Le, NonZero, U256}, - ArrayLength, GenericArray, - }, + crypto_common::{BlockSizes, InnerInit, InnerUser}, MacMarker, Output, OutputSizeUser, Reset, }; @@ -62,7 +62,7 @@ pub type CbcMac = CoreWrapper>; #[derive(Clone)] pub struct CbcMacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, { cipher: C, state: Block, @@ -70,30 +70,30 @@ where impl BlockSizeUser for CbcMacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, { type BlockSize = C::BlockSize; } impl OutputSizeUser for CbcMacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, { type OutputSize = C::BlockSize; } impl InnerUser for CbcMacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, { type Inner = C; } -impl MacMarker for CbcMacCore where C: BlockCipher + BlockEncryptMut + Clone {} +impl MacMarker for CbcMacCore where C: BlockCipher + BlockCipherEncrypt + Clone {} impl InnerInit for CbcMacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, { #[inline] fn inner_init(cipher: C) -> Self { @@ -104,27 +104,27 @@ where impl BufferKindUser for CbcMacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, { type BufferKind = Eager; } impl UpdateCore for CbcMacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, { #[inline] fn update_blocks(&mut self, blocks: &[Block]) { - struct Ctx<'a, N: ArrayLength> { + struct Ctx<'a, N: BlockSizes> { state: &'a mut Block, blocks: &'a [Block], } - impl<'a, N: ArrayLength> BlockSizeUser for Ctx<'a, N> { + impl<'a, N: BlockSizes> BlockSizeUser for Ctx<'a, N> { type BlockSize = N; } - impl<'a, N: ArrayLength> BlockClosure for Ctx<'a, N> { + impl<'a, N: BlockSizes> BlockClosure for Ctx<'a, N> { #[inline(always)] fn call>(self, backend: &mut B) { for block in self.blocks { @@ -135,13 +135,13 @@ where } let Self { cipher, state } = self; - cipher.encrypt_with_backend_mut(Ctx { state, blocks }) + cipher.encrypt_with_backend(Ctx { state, blocks }) } } impl Reset for CbcMacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, { #[inline(always)] fn reset(&mut self) { @@ -151,7 +151,7 @@ where impl FixedOutputCore for CbcMacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, C::BlockSize: IsLess, Le: NonZero, { @@ -160,8 +160,8 @@ where let Self { state, cipher } = self; let pos = buffer.get_pos(); if pos != 0 { - xor(state, buffer.pad_with_zeros()); - cipher.encrypt_block_mut(state); + xor(state, &buffer.pad_with_zeros()); + cipher.encrypt_block(state); } out.copy_from_slice(state); } @@ -169,7 +169,7 @@ where impl AlgorithmName for CbcMacCore where - C: BlockCipher + BlockEncryptMut + Clone + AlgorithmName, + C: BlockCipher + BlockCipherEncrypt + Clone + AlgorithmName, { fn write_alg_name(f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("CbcMac<")?; @@ -180,7 +180,7 @@ where impl fmt::Debug for CbcMacCore where - C: BlockCipher + BlockEncryptMut + Clone + AlgorithmName, + C: BlockCipher + BlockCipherEncrypt + Clone + AlgorithmName, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("CbcMacCore<")?; @@ -193,7 +193,7 @@ where #[cfg_attr(docsrs, doc(cfg(feature = "zeroize")))] impl Drop for CbcMacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, { fn drop(&mut self) { self.state.zeroize(); @@ -203,12 +203,12 @@ where #[cfg(feature = "zeroize")] #[cfg_attr(docsrs, doc(cfg(feature = "zeroize")))] impl ZeroizeOnDrop for CbcMacCore where - C: BlockCipher + BlockEncryptMut + Clone + ZeroizeOnDrop + C: BlockCipher + BlockCipherEncrypt + Clone + ZeroizeOnDrop { } #[inline(always)] -fn xor>(buf: &mut GenericArray, data: &GenericArray) { +fn xor(buf: &mut Array, data: &Array) { for i in 0..N::USIZE { buf[i] ^= data[i]; } diff --git a/cmac/Cargo.toml b/cmac/Cargo.toml index e82e31c..b55b22e 100644 --- a/cmac/Cargo.toml +++ b/cmac/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "cmac" -version = "0.7.2" +version = "0.8.0-pre" description = "Generic implementation of Cipher-based Message Authentication Code" authors = ["RustCrypto Developers"] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.56" +rust-version = "1.71" readme = "README.md" documentation = "https://docs.rs/cmac" repository = "https://github.com/RustCrypto/MACs" @@ -14,17 +14,17 @@ categories = ["cryptography", "no-std"] exclude = ["tests/cavp_large.rs", "tests/data/cavp_aes128_large.blb"] [dependencies] -digest = { version = "0.10.3", features = ["mac"] } -cipher = "0.4.2" -dbl = "0.3" +digest = { version = "=0.11.0-pre.8", features = ["mac"] } +cipher = "=0.5.0-pre.4" +dbl = "0.4.0-pre.4" [dev-dependencies] -digest = { version = "0.10.3", features = ["dev"] } +digest = { version = "=0.11.0-pre.8", features = ["dev"] } hex-literal = "0.3" -aes = "0.8" -des = "0.8" -kuznyechik = "0.8" -magma = "0.9" +aes = "0.9.0-pre" +des = "0.9.0-pre" +kuznyechik = "0.9.0-pre" +magma = "0.10.0-pre" [features] std = ["digest/std"] diff --git a/cmac/src/lib.rs b/cmac/src/lib.rs index 1ff1845..c26316e 100644 --- a/cmac/src/lib.rs +++ b/cmac/src/lib.rs @@ -8,7 +8,7 @@ //! //! ```rust //! use aes::Aes128; -//! use cmac::{Cmac, Mac}; +//! use cmac::{digest::KeyInit, Cmac, Mac}; //! //! // Create `Mac` trait implementation, namely CMAC-AES128 //! let mut mac = Cmac::::new_from_slice(b"very secret key.").unwrap(); @@ -27,7 +27,7 @@ //! //! ```rust //! # use aes::Aes128; -//! # use cmac::{Cmac, Mac}; +//! # use cmac::{digest::KeyInit, Cmac, Mac}; //! let mut mac = Cmac::::new_from_slice(b"very secret key.").unwrap(); //! //! mac.update(b"input message"); @@ -50,20 +50,20 @@ pub use digest::{self, Mac}; -use cipher::{BlockBackend, BlockCipher, BlockClosure, BlockEncryptMut}; +use cipher::{BlockBackend, BlockCipher, BlockCipherEncrypt, BlockClosure}; use core::fmt; use dbl::Dbl; use digest::{ + array::{ + typenum::{IsLess, Le, NonZero, U256}, + Array, ArraySize, + }, block_buffer::Lazy, core_api::{ AlgorithmName, Block, BlockSizeUser, Buffer, BufferKindUser, CoreWrapper, FixedOutputCore, UpdateCore, }, - crypto_common::{InnerInit, InnerUser}, - generic_array::{ - typenum::{IsLess, Le, NonZero, U256}, - ArrayLength, GenericArray, - }, + crypto_common::{BlockSizes, InnerInit, InnerUser}, MacMarker, Output, OutputSizeUser, Reset, }; @@ -77,7 +77,7 @@ pub type Cmac = CoreWrapper>; #[derive(Clone)] pub struct CmacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, Block: Dbl, { cipher: C, @@ -86,7 +86,7 @@ where impl BlockSizeUser for CmacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + BlockSizeUser + Clone, Block: Dbl, { type BlockSize = C::BlockSize; @@ -94,7 +94,7 @@ where impl OutputSizeUser for CmacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, Block: Dbl, { type OutputSize = C::BlockSize; @@ -102,7 +102,7 @@ where impl InnerUser for CmacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, Block: Dbl, { type Inner = C; @@ -110,14 +110,14 @@ where impl MacMarker for CmacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, Block: Dbl, { } impl InnerInit for CmacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, Block: Dbl, { #[inline] @@ -129,7 +129,7 @@ where impl BufferKindUser for CmacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, Block: Dbl, { type BufferKind = Lazy; @@ -137,21 +137,21 @@ where impl UpdateCore for CmacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, Block: Dbl, { #[inline] fn update_blocks(&mut self, blocks: &[Block]) { - struct Ctx<'a, N: ArrayLength> { + struct Ctx<'a, N: BlockSizes> { state: &'a mut Block, blocks: &'a [Block], } - impl<'a, N: ArrayLength> BlockSizeUser for Ctx<'a, N> { + impl<'a, N: BlockSizes> BlockSizeUser for Ctx<'a, N> { type BlockSize = N; } - impl<'a, N: ArrayLength> BlockClosure for Ctx<'a, N> { + impl<'a, N: BlockSizes> BlockClosure for Ctx<'a, N> { #[inline(always)] fn call>(self, backend: &mut B) { for block in self.blocks { @@ -162,13 +162,13 @@ where } let Self { cipher, state } = self; - cipher.encrypt_with_backend_mut(Ctx { state, blocks }) + cipher.encrypt_with_backend(Ctx { state, blocks }) } } impl Reset for CmacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, Block: Dbl, { #[inline(always)] @@ -179,7 +179,7 @@ where impl FixedOutputCore for CmacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, Block: Dbl, C::BlockSize: IsLess, Le: NonZero, @@ -191,10 +191,10 @@ where let buf = buffer.pad_with_zeros(); let mut subkey = Default::default(); - cipher.encrypt_block_mut(&mut subkey); + cipher.encrypt_block(&mut subkey); let key1 = subkey.dbl(); - xor(state, buf); + xor(state, &buf); if pos == buf.len() { xor(state, &key1); } else { @@ -202,14 +202,14 @@ where let key2 = key1.dbl(); xor(state, &key2); } - cipher.encrypt_block_mut(state); + cipher.encrypt_block(state); out.copy_from_slice(state); } } impl AlgorithmName for CmacCore where - C: BlockCipher + BlockEncryptMut + Clone + AlgorithmName, + C: BlockCipher + BlockCipherEncrypt + Clone + AlgorithmName, Block: Dbl, { fn write_alg_name(f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -221,7 +221,7 @@ where impl fmt::Debug for CmacCore where - C: BlockCipher + BlockEncryptMut + Clone + AlgorithmName, + C: BlockCipher + BlockCipherEncrypt + Clone + AlgorithmName, Block: Dbl, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -235,7 +235,7 @@ where #[cfg_attr(docsrs, doc(cfg(feature = "zeroize")))] impl Drop for CmacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, Block: Dbl, { fn drop(&mut self) { @@ -247,13 +247,13 @@ where #[cfg_attr(docsrs, doc(cfg(feature = "zeroize")))] impl ZeroizeOnDrop for CmacCore where - C: BlockCipher + BlockEncryptMut + Clone + ZeroizeOnDrop, + C: BlockCipher + BlockCipherEncrypt + Clone + ZeroizeOnDrop, Block: Dbl, { } #[inline(always)] -fn xor>(buf: &mut GenericArray, data: &GenericArray) { +fn xor(buf: &mut Array, data: &Array) { for i in 0..N::USIZE { buf[i] ^= data[i]; } diff --git a/hmac/Cargo.lock b/hmac/Cargo.lock deleted file mode 100644 index 99a70e5..0000000 --- a/hmac/Cargo.lock +++ /dev/null @@ -1,168 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "blobby" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "847495c209977a90e8aad588b959d0ca9f5dc228096d29a6bd3defd53f35eaec" - -[[package]] -name = "block-buffer" -version = "0.11.0-pre.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ded684142010808eb980d9974ef794da2bcf97d13396143b1515e9f0fb4a10e" -dependencies = [ - "crypto-common", -] - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "cpufeatures" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" -dependencies = [ - "libc", -] - -[[package]] -name = "crypto-common" -version = "0.2.0-pre.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7aa2ec04f5120b830272a481e8d9d8ba4dda140d2cda59b0f1110d5eb93c38e" -dependencies = [ - "getrandom", - "hybrid-array", - "rand_core", -] - -[[package]] -name = "digest" -version = "0.11.0-pre.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "065d93ead7c220b85d5b4be4795d8398eac4ff68b5ee63895de0a3c1fb6edf25" -dependencies = [ - "blobby", - "block-buffer", - "crypto-common", - "subtle", -] - -[[package]] -name = "getrandom" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "hex-literal" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" - -[[package]] -name = "hmac" -version = "0.13.0-pre.3" -dependencies = [ - "digest", - "hex-literal", - "md-5", - "sha1", - "sha2", - "streebog", -] - -[[package]] -name = "hybrid-array" -version = "0.2.0-rc.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18e63b66aee2df5599ba69b17a48113dfc68d2e143ea387ef836509e433bbd7e" -dependencies = [ - "typenum", -] - -[[package]] -name = "libc" -version = "0.2.152" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" - -[[package]] -name = "md-5" -version = "0.11.0-pre.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "649f2dc52b97a3d781ba9a36dad970f147d55920d17a27735f551b560024f3bf" -dependencies = [ - "cfg-if", - "digest", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] - -[[package]] -name = "sha1" -version = "0.11.0-pre.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3885de8cb916f223718c1ccd47a840b91f806333e76002dc5cb3862154b4fed3" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - -[[package]] -name = "sha2" -version = "0.11.0-pre.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f33549bf3064b62478926aa89cbfc7c109aab66ae8f0d5d2ef839e482cc30d6" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - -[[package]] -name = "streebog" -version = "0.11.0-pre.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "906aaaef0b6bfcf186c7aac662b06a11769e688744323aa6ff3b9f96a5c71c09" -dependencies = [ - "digest", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - -[[package]] -name = "typenum" -version = "1.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" diff --git a/pmac/Cargo.toml b/pmac/Cargo.toml index a512e5d..a819a20 100644 --- a/pmac/Cargo.toml +++ b/pmac/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "pmac" -version = "0.7.1" # Also update html_root_url in lib.rs when bumping this +version = "0.8.0-pre" # Also update html_root_url in lib.rs when bumping this description = "Generic implementation of Parallelizable Message Authentication Code" authors = ["RustCrypto Developers"] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.56" +rust-version = "1.71" readme = "README.md" documentation = "https://docs.rs/pmac" repository = "https://github.com/RustCrypto/MACs" @@ -13,13 +13,13 @@ keywords = ["crypto", "mac", "pmac"] categories = ["cryptography", "no-std"] [dependencies] -digest = { version = "0.10.3", features = ["mac"] } -cipher = "0.4.2" -dbl = "0.3" +digest = { version = "=0.11.0-pre.8", features = ["mac"] } +cipher = "=0.5.0-pre.4" +dbl = "0.4.0-pre.4" [dev-dependencies] -aes = "0.8" -digest = { version = "0.10.3", features = ["dev"] } +aes = "0.9.0-pre" +digest = { version = "=0.11.0-pre.8", features = ["dev"] } [features] std = ["digest/std"] diff --git a/pmac/src/lib.rs b/pmac/src/lib.rs index 41ee11d..9ee7d6d 100644 --- a/pmac/src/lib.rs +++ b/pmac/src/lib.rs @@ -8,7 +8,7 @@ //! //! ```rust //! use aes::Aes128; -//! use pmac::{Pmac, Mac}; +//! use pmac::{digest::KeyInit, Pmac, Mac}; //! //! // Create `Mac` trait implementation, namely PMAC-AES128 //! let mut mac = Pmac::::new_from_slice(b"very secret key.").unwrap(); @@ -27,7 +27,7 @@ //! //! ```rust //! # use aes::Aes128; -//! # use pmac::{Pmac, Mac}; +//! # use pmac::{digest::KeyInit, Pmac, Mac}; //! let mut mac = Pmac::::new_from_slice(b"very secret key.").unwrap(); //! //! mac.update(b"input message"); @@ -54,20 +54,20 @@ extern crate std; pub use digest::{self, Mac}; -use cipher::{BlockBackend, BlockCipher, BlockClosure, BlockEncryptMut, ParBlocks}; +use cipher::{BlockBackend, BlockCipher, BlockCipherEncrypt, BlockClosure, ParBlocks}; use core::fmt; use dbl::Dbl; use digest::{ + array::{ + typenum::{IsLess, Le, NonZero, Unsigned, U256}, + Array, ArraySize, + }, block_buffer::Lazy, core_api::{ AlgorithmName, Block, BlockSizeUser, Buffer, BufferKindUser, CoreWrapper, FixedOutputCore, UpdateCore, }, - crypto_common::{InnerInit, InnerUser}, - generic_array::{ - typenum::{IsLess, Le, NonZero, Unsigned, U256}, - ArrayLength, GenericArray, - }, + crypto_common::{BlockSizes, InnerInit, InnerUser}, MacMarker, Output, OutputSizeUser, Reset, }; @@ -89,7 +89,7 @@ pub type Pmac = CoreWrapper>; #[derive(Clone)] pub struct PmacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, Block: Dbl, { state: PmacState, @@ -99,8 +99,8 @@ where #[derive(Clone)] struct PmacState where - N: ArrayLength, - GenericArray: Dbl, + N: BlockSizes, + Array: Dbl, { counter: usize, l_inv: Block, @@ -111,16 +111,16 @@ where impl BlockSizeUser for PmacState where - N: ArrayLength, - GenericArray: Dbl, + N: BlockSizes, + Array: Dbl, { type BlockSize = N; } impl PmacState where - N: ArrayLength, - GenericArray: Dbl, + N: BlockSizes, + Array: Dbl, { #[inline(always)] fn next_offset(&mut self) -> &Block { @@ -143,8 +143,8 @@ where #[cfg(feature = "zeroize")] impl Drop for PmacState where - N: ArrayLength, - GenericArray: Dbl, + N: BlockSizes, + Array: Dbl, { fn drop(&mut self) { self.counter.zeroize(); @@ -157,7 +157,7 @@ where impl BlockSizeUser for PmacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, Block: Dbl, { type BlockSize = C::BlockSize; @@ -165,7 +165,7 @@ where impl OutputSizeUser for PmacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, Block: Dbl, { type OutputSize = C::BlockSize; @@ -173,7 +173,7 @@ where impl InnerUser for PmacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, Block: Dbl, { type Inner = C; @@ -181,14 +181,14 @@ where impl MacMarker for PmacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, Block: Dbl, { } impl Reset for PmacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, Block: Dbl, { #[inline(always)] @@ -201,7 +201,7 @@ where impl BufferKindUser for PmacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, Block: Dbl, { type BufferKind = Lazy; @@ -209,7 +209,7 @@ where impl AlgorithmName for PmacCore where - C: BlockCipher + BlockEncryptMut + Clone + AlgorithmName, + C: BlockCipher + BlockCipherEncrypt + Clone + AlgorithmName, Block: Dbl, { fn write_alg_name(f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -221,7 +221,7 @@ where impl fmt::Debug for PmacCore where - C: BlockCipher + BlockEncryptMut + Clone + AlgorithmName, + C: BlockCipher + BlockCipherEncrypt + Clone + AlgorithmName, Block: Dbl, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -233,13 +233,13 @@ where impl InnerInit for PmacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, Block: Dbl, { #[inline] - fn inner_init(mut cipher: C) -> Self { + fn inner_init(cipher: C) -> Self { let mut l = Default::default(); - cipher.encrypt_block_mut(&mut l); + cipher.encrypt_block(&mut l); let l_inv = l.clone().inv_dbl(); let l_cache = [(); LC_SIZE].map(|_| { @@ -260,15 +260,15 @@ where impl UpdateCore for PmacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, Block: Dbl, { #[inline] fn update_blocks(&mut self, blocks: &[Block]) { struct Ctx<'a, N, const LC_SIZE: usize> where - N: ArrayLength, - GenericArray: Dbl, + N: BlockSizes, + Array: Dbl, { state: &'a mut PmacState, blocks: &'a [Block], @@ -276,16 +276,16 @@ where impl<'a, N, const LC_SIZE: usize> BlockSizeUser for Ctx<'a, N, LC_SIZE> where - N: ArrayLength, - GenericArray: Dbl, + N: BlockSizes, + Array: Dbl, { type BlockSize = N; } impl<'a, N, const LC_SIZE: usize> BlockClosure for Ctx<'a, N, LC_SIZE> where - N: ArrayLength, - GenericArray: Dbl, + N: BlockSizes, + Array: Dbl, { #[inline(always)] fn call>(self, backend: &mut B) { @@ -317,13 +317,13 @@ where } let Self { cipher, state } = self; - cipher.encrypt_with_backend_mut(Ctx { blocks, state }) + cipher.encrypt_with_backend(Ctx { blocks, state }) } } impl FixedOutputCore for PmacCore where - C: BlockCipher + BlockEncryptMut + Clone, + C: BlockCipher + BlockCipherEncrypt + Clone, Block: Dbl, C::BlockSize: IsLess, Le: NonZero, @@ -337,20 +337,20 @@ where let pos = buffer.get_pos(); let buf = buffer.pad_with_zeros(); if pos == buf.len() { - xor(tag, buf); + xor(tag, &buf); xor(tag, l_inv); } else { tag[pos] ^= 0x80; - xor(tag, buf); + xor(tag, &buf); } - cipher.encrypt_block_b2b_mut(tag, out); + cipher.encrypt_block_b2b(tag, out); } } #[cfg(feature = "zeroize")] impl ZeroizeOnDrop for PmacCore where - C: BlockCipher + BlockEncryptMut + Clone + ZeroizeOnDrop, + C: BlockCipher + BlockCipherEncrypt + Clone + ZeroizeOnDrop, Block: Dbl, C::BlockSize: IsLess, Le: NonZero, @@ -358,7 +358,7 @@ where } #[inline(always)] -fn xor>(buf: &mut GenericArray, data: &GenericArray) { +fn xor(buf: &mut Array, data: &Array) { for i in 0..N::USIZE { buf[i] ^= data[i]; }