Skip to content

Commit

Permalink
Bump cipher to v0.5.0-pre.7
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov committed Aug 14, 2024
1 parent 7cd5622 commit 3c81905
Show file tree
Hide file tree
Showing 15 changed files with 136 additions and 152 deletions.
55 changes: 28 additions & 27 deletions Cargo.lock

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

13 changes: 1 addition & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
[workspace]
resolver = "2"
members = [
"belt-mac",
"cbc-mac",
"cmac",
"hmac",
"pmac",
]
members = ["belt-mac", "cbc-mac", "cmac", "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
belt-block = { git = "https://github.com/RustCrypto/block-ciphers.git" }
5 changes: 2 additions & 3 deletions belt-mac/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ keywords = ["crypto", "mac", "belt-mac"]
categories = ["cryptography", "no-std"]

[dependencies]
belt-block = "0.2.0-pre.1"
cipher = "=0.5.0-pre.6"
belt-block = "0.2.0-pre.2"
cipher = "=0.5.0-pre.7"
digest = { version = "=0.11.0-pre.9", features = ["mac"] }

[dev-dependencies]
cipher = { version = "=0.5.0-pre.6", features = ["dev"] }
digest = { version = "=0.11.0-pre.9", features = ["dev"] }
hex-literal = "0.4"

Expand Down
2 changes: 1 addition & 1 deletion belt-mac/benches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
extern crate test;

use belt_block::BeltBlock;
use belt_mac::{BeltMac, Mac};
use belt_mac::{BeltMac, KeyInit};
use test::Bencher;

digest::bench_update!(
Expand Down
47 changes: 22 additions & 25 deletions belt-mac/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
#![cfg_attr(docsrs, feature(doc_cfg))]
#![warn(missing_docs, rust_2018_idioms)]

pub use digest::{self, Mac};
pub use digest::{self, KeyInit, Mac};

use belt_block::BeltBlock;
use cipher::{BlockBackend, BlockCipher, BlockCipherEncrypt, BlockClosure};
use cipher::{BlockCipherEncBackend, BlockCipherEncClosure, BlockCipherEncrypt};
use core::fmt;
use digest::{
array::{
Expand All @@ -37,7 +37,7 @@ pub type BeltMac<C = BeltBlock> = CoreWrapper<BeltMacCore<C>>;
/// Generic core BeltMac instance, which operates over blocks.
pub struct BeltMacCore<C = BeltBlock>
where
C: BlockCipher + BlockCipherEncrypt + Clone,
C: BlockCipherEncrypt + Clone,
{
cipher: C,
state: Block<C>,
Expand All @@ -46,30 +46,30 @@ where

impl<C> BlockSizeUser for BeltMacCore<C>
where
C: BlockCipher + BlockCipherEncrypt + Clone,
C: BlockCipherEncrypt + Clone,
{
type BlockSize = C::BlockSize;
}

impl<C> OutputSizeUser for BeltMacCore<C>
where
C: BlockCipher + BlockCipherEncrypt + Clone,
C: BlockCipherEncrypt + Clone,
{
type OutputSize = C::BlockSize;
}

impl<C> InnerUser for BeltMacCore<C>
where
C: BlockCipher + BlockCipherEncrypt + Clone,
C: BlockCipherEncrypt + Clone,
{
type Inner = C;
}

impl<C> MacMarker for BeltMacCore<C> where C: BlockCipher + BlockCipherEncrypt + Clone {}
impl<C> MacMarker for BeltMacCore<C> where C: BlockCipherEncrypt + Clone {}

impl<C> InnerInit for BeltMacCore<C>
where
C: BlockCipher + BlockCipherEncrypt + Clone,
C: BlockCipherEncrypt + Clone,
{
#[inline]
fn inner_init(cipher: C) -> Self {
Expand All @@ -82,44 +82,44 @@ where

impl<C> BufferKindUser for BeltMacCore<C>
where
C: BlockCipher + BlockCipherEncrypt + Clone,
C: BlockCipherEncrypt + Clone,
{
type BufferKind = Lazy;
}

impl<C> UpdateCore for BeltMacCore<C>
where
C: BlockCipher + BlockCipherEncrypt + Clone,
C: BlockCipherEncrypt + Clone,
{
#[inline]
fn update_blocks(&mut self, blocks: &[Block<Self>]) {
struct Ctx<'a, N: BlockSizes> {
struct Closure<'a, N: BlockSizes> {
state: &'a mut Block<Self>,
blocks: &'a [Block<Self>],
}

impl<'a, N: BlockSizes> BlockSizeUser for Ctx<'a, N> {
impl<'a, N: BlockSizes> BlockSizeUser for Closure<'a, N> {
type BlockSize = N;
}

impl<'a, N: BlockSizes> BlockClosure for Ctx<'a, N> {
impl<'a, N: BlockSizes> BlockCipherEncClosure for Closure<'a, N> {
#[inline(always)]
fn call<B: BlockBackend<BlockSize = Self::BlockSize>>(self, backend: &mut B) {
fn call<B: BlockCipherEncBackend<BlockSize = Self::BlockSize>>(self, backend: &B) {
for block in self.blocks {
xor(self.state, block);
backend.proc_block((self.state).into());
backend.encrypt_block((self.state).into());
}
}
}

let Self { cipher, state, .. } = self;
cipher.encrypt_with_backend(Ctx { state, blocks })
cipher.encrypt_with_backend(Closure { state, blocks })
}
}

impl<C> Reset for BeltMacCore<C>
where
C: BlockCipher + BlockCipherEncrypt + Clone,
C: BlockCipherEncrypt + Clone,
{
#[inline(always)]
fn reset(&mut self) {
Expand All @@ -129,7 +129,7 @@ where

impl<C> FixedOutputCore for BeltMacCore<C>
where
C: BlockCipher + BlockCipherEncrypt + Clone,
C: BlockCipherEncrypt + Clone,
C::BlockSize: IsLess<U256>,
Le<C::BlockSize, U256>: NonZero,
{
Expand Down Expand Up @@ -168,7 +168,7 @@ where

impl<C> AlgorithmName for BeltMacCore<C>
where
C: BlockCipher + BlockCipherEncrypt + Clone + AlgorithmName,
C: BlockCipherEncrypt + Clone + AlgorithmName,
{
fn write_alg_name(f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("BeltMac<")?;
Expand All @@ -179,7 +179,7 @@ where

impl<C> fmt::Debug for BeltMacCore<C>
where
C: BlockCipher + BlockCipherEncrypt + Clone + AlgorithmName,
C: BlockCipherEncrypt + Clone + AlgorithmName,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("BeltMacCore<")?;
Expand All @@ -192,7 +192,7 @@ where
#[cfg_attr(docsrs, doc(cfg(feature = "zeroize")))]
impl<C> Drop for BeltMacCore<C>
where
C: BlockCipher + BlockCipherEncrypt + Clone,
C: BlockCipherEncrypt + Clone,
{
fn drop(&mut self) {
self.state.zeroize();
Expand All @@ -201,10 +201,7 @@ where

#[cfg(feature = "zeroize")]
#[cfg_attr(docsrs, doc(cfg(feature = "zeroize")))]
impl<C> ZeroizeOnDrop for BeltMacCore<C> where
C: BlockCipher + BlockCipherEncrypt + Clone + ZeroizeOnDrop
{
}
impl<C> ZeroizeOnDrop for BeltMacCore<C> where C: BlockCipherEncrypt + Clone + ZeroizeOnDrop {}

#[inline(always)]
fn xor<N: ArraySize>(buf: &mut Array<u8, N>, data: &Array<u8, N>) {
Expand Down
7 changes: 4 additions & 3 deletions cbc-mac/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ repository = "https://github.com/RustCrypto/MACs"
keywords = ["crypto", "mac", "daa"]

[dependencies]
cipher = "=0.5.0-pre.6"
cipher = "=0.5.0-pre.7"
digest = { version = "=0.11.0-pre.9", features = ["mac"] }

[dev-dependencies]
aes = "0.9.0-pre.1"
des = "0.9.0-pre.1"
digest = { version = "=0.11.0-pre.9", features = ["dev"] }
hex-literal = "0.4"

aes = "0.9.0-pre.2"
des = "0.9.0-pre.2"

[features]
std = ["digest/std"]
zeroize = ["cipher/zeroize"]
Expand Down
2 changes: 1 addition & 1 deletion cbc-mac/benches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
extern crate test;

use aes::Aes128;
use cbc_mac::{CbcMac, Mac};
use cbc_mac::{CbcMac, KeyInit};
use des::Des;
use test::Bencher;

Expand Down
Loading

0 comments on commit 3c81905

Please sign in to comment.