Skip to content

Commit

Permalink
Update crypto-mac to v0.9 (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov authored Aug 12, 2020
1 parent b34d711 commit d2e6f95
Show file tree
Hide file tree
Showing 24 changed files with 135 additions and 158 deletions.
121 changes: 56 additions & 65 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions cmac/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.4.0 (2020-08-12)
### Changed
- Bump `crypto-mac` dependency to v0.9, implement the `FromBlockCipher` trait ([#57])

[#57]: https://github.com/RustCrypto/MACs/pull/57

## 0.3.0 (2020-06-06)
### Changed
- Bump `aes` crate dependency to v0.4 ([#40])
Expand Down
13 changes: 6 additions & 7 deletions cmac/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cmac"
version = "0.3.1"
version = "0.4.0"
description = "Generic implementation of Cipher-based Message Authentication Code"
authors = ["RustCrypto Developers"]
license = "MIT OR Apache-2.0"
Expand All @@ -12,16 +12,15 @@ readme = "README.md"
edition = "2018"

[dependencies]
crypto-mac = "0.8"
block-cipher = "0.7"
crypto-mac = { version = "0.9.1", features = ["block-cipher"] }
dbl = "0.3"

[dev-dependencies]
hex-literal = "0.2"
crypto-mac = { version = "0.8", features = ["dev"] }
aes = "0.4"
kuznyechik = "0.4"
magma = "0.4"
crypto-mac = { version = "0.9.1", features = ["dev"] }
aes = "0.5"
kuznyechik = "0.5"
magma = "0.5"

[features]
std = ["crypto-mac/std"]
37 changes: 11 additions & 26 deletions cmac/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@
#[cfg(feature = "std")]
extern crate std;

pub use crypto_mac::{self, Mac, NewMac};

use block_cipher::generic_array::typenum::Unsigned;
use block_cipher::generic_array::{ArrayLength, GenericArray};
use block_cipher::{BlockCipher, NewBlockCipher};
use crypto_mac::{InvalidKeyLength, Output};
use dbl::Dbl;
pub use crypto_mac::{self, FromBlockCipher, Mac, NewMac};

use core::fmt;
use crypto_mac::{
block_cipher::BlockCipher,
generic_array::{typenum::Unsigned, ArrayLength, GenericArray},
Output,
};
use dbl::Dbl;

type Block<N> = GenericArray<u8, N>;

Expand All @@ -76,12 +76,14 @@ where
pos: usize,
}

impl<C: BlockCipher> From<C> for Cmac<C>
impl<C> FromBlockCipher for Cmac<C>
where
C: BlockCipher + Clone,
Block<C::BlockSize>: Dbl,
{
fn from(cipher: C) -> Self {
type Cipher = C;

fn from_cipher(cipher: C) -> Self {
let mut subkey = GenericArray::default();
cipher.encrypt_block(&mut subkey);

Expand All @@ -98,23 +100,6 @@ where
}
}

impl<C> NewMac for Cmac<C>
where
C: BlockCipher + NewBlockCipher + Clone,
Block<C::BlockSize>: Dbl,
{
type KeySize = C::KeySize;

fn new(key: &GenericArray<u8, Self::KeySize>) -> Self {
Self::from(C::new(key))
}

fn new_varkey(key: &[u8]) -> Result<Self, InvalidKeyLength> {
let cipher = C::new_varkey(key).map_err(|_| InvalidKeyLength)?;
Ok(Self::from(cipher))
}
}

impl<C> Mac for Cmac<C>
where
C: BlockCipher + Clone,
Expand Down
Binary file modified cmac/tests/data/aes128.blb
Binary file not shown.
Binary file modified cmac/tests/data/aes192.blb
Binary file not shown.
Binary file modified cmac/tests/data/aes256.blb
Binary file not shown.
6 changes: 6 additions & 0 deletions daa/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.3.0 (2020-08-12)
### Changed
- Bump `crypto-mac` dependency to v0.9, implement the `FromBlockCipher` trait ([#57])

[#57]: https://github.com/RustCrypto/MACs/pull/57

## 0.2.0 (2020-06-08)
### Changed
- Bump `daa` crate to v0.4 release ([#43])
Expand Down
Loading

0 comments on commit d2e6f95

Please sign in to comment.