Skip to content

Commit dfc1c2d

Browse files
committed
rustfmt
Applied using: `rustfmt 1.2.2-stable (5274b49c 2019-04-24)`
1 parent 4efeabe commit dfc1c2d

File tree

11 files changed

+121
-82
lines changed

11 files changed

+121
-82
lines changed

cmac/benches/aes128_cmac.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![feature(test)]
22
#[macro_use]
33
extern crate crypto_mac;
4-
extern crate cmac;
54
extern crate aes;
5+
extern crate cmac;
66

77
bench!(cmac::Cmac::<aes::Aes128>);

cmac/benches/aes256_cmac.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![feature(test)]
22
#[macro_use]
33
extern crate crypto_mac;
4-
extern crate cmac;
54
extern crate aes;
5+
extern crate cmac;
66

77
bench!(cmac::Cmac::<aes::Aes256>);

cmac/src/lib.rs

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,16 @@
4646
//! # }
4747
//! ```
4848
#![no_std]
49-
#![doc(html_logo_url =
50-
"https://raw.githubusercontent.com/RustCrypto/meta/master/logo_small.png")]
49+
#![doc(html_logo_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo_small.png")]
5150
extern crate block_cipher_trait;
52-
extern crate dbl;
5351
pub extern crate crypto_mac;
52+
extern crate dbl;
5453

54+
use block_cipher_trait::generic_array::typenum::Unsigned;
55+
use block_cipher_trait::generic_array::{ArrayLength, GenericArray};
56+
use block_cipher_trait::BlockCipher;
5557
pub use crypto_mac::Mac;
5658
use crypto_mac::{InvalidKeyLength, MacResult};
57-
use block_cipher_trait::BlockCipher;
58-
use block_cipher_trait::generic_array::{GenericArray, ArrayLength};
59-
use block_cipher_trait::generic_array::typenum::Unsigned;
6059
use dbl::Dbl;
6160

6261
use core::fmt;
@@ -65,23 +64,37 @@ type Block<N> = GenericArray<u8, N>;
6564

6665
/// Generic CMAC instance
6766
#[derive(Clone)]
68-
pub struct Cmac<C> where C: BlockCipher + Clone, Block<C::BlockSize>: Dbl {
67+
pub struct Cmac<C>
68+
where
69+
C: BlockCipher + Clone,
70+
Block<C::BlockSize>: Dbl,
71+
{
6972
cipher: C,
7073
key1: Block<C::BlockSize>,
7174
key2: Block<C::BlockSize>,
7275
buffer: Block<C::BlockSize>,
7376
pos: usize,
7477
}
7578

76-
impl<C> Cmac<C> where C: BlockCipher + Clone, Block<C::BlockSize>: Dbl {
79+
impl<C> Cmac<C>
80+
where
81+
C: BlockCipher + Clone,
82+
Block<C::BlockSize>: Dbl,
83+
{
7784
fn from_cipher(cipher: C) -> Self {
7885
let mut subkey = GenericArray::default();
7986
cipher.encrypt_block(&mut subkey);
8087

8188
let key1 = subkey.dbl();
8289
let key2 = key1.clone().dbl();
8390

84-
Cmac { cipher, key1, key2, buffer: Default::default(), pos: 0 }
91+
Cmac {
92+
cipher,
93+
key1,
94+
key2,
95+
buffer: Default::default(),
96+
pos: 0,
97+
}
8598
}
8699
}
87100

@@ -92,8 +105,11 @@ fn xor<L: ArrayLength<u8>>(buf: &mut Block<L>, data: &Block<L>) {
92105
}
93106
}
94107

95-
impl <C> Mac for Cmac<C>
96-
where C: BlockCipher + Clone, Block<C::BlockSize>: Dbl, C::BlockSize: Clone
108+
impl<C> Mac for Cmac<C>
109+
where
110+
C: BlockCipher + Clone,
111+
Block<C::BlockSize>: Dbl,
112+
C::BlockSize: Clone,
97113
{
98114
type OutputSize = C::BlockSize;
99115
type KeySize = C::KeySize;
@@ -131,9 +147,7 @@ impl <C> Mac for Cmac<C>
131147
self.cipher.encrypt_block(&mut self.buffer);
132148

133149
let (l, r) = data.split_at(n);
134-
let block = unsafe {
135-
& *(l.as_ptr() as *const Block<C::BlockSize>)
136-
};
150+
let block = unsafe { &*(l.as_ptr() as *const Block<C::BlockSize>) };
137151
data = r;
138152

139153
xor(&mut self.buffer, block);
@@ -169,7 +183,9 @@ impl <C> Mac for Cmac<C>
169183
}
170184

171185
impl<C> fmt::Debug for Cmac<C>
172-
where C: BlockCipher + fmt::Debug + Clone, Block<C::BlockSize>: Dbl
186+
where
187+
C: BlockCipher + fmt::Debug + Clone,
188+
Block<C::BlockSize>: Dbl,
173189
{
174190
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
175191
write!(f, "Cmac-{:?}", self.cipher)

cmac/tests/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ extern crate crypto_mac;
66
extern crate aes;
77
extern crate cmac;
88

9-
use cmac::Cmac;
109
use aes::{Aes128, Aes192, Aes256};
10+
use cmac::Cmac;
1111

1212
new_test!(cmac_aes128, "aes128", Cmac<Aes128>);
1313
new_test!(cmac_aes192, "aes192", Cmac<Aes192>);

daa/src/lib.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,16 @@
1616
//! mac.verify(&correct).unwrap();
1717
//! ```
1818
#![no_std]
19-
#![doc(html_logo_url =
20-
"https://raw.githubusercontent.com/RustCrypto/meta/master/logo_small.png")]
21-
extern crate des;
19+
#![doc(html_logo_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo_small.png")]
2220
pub extern crate crypto_mac;
21+
extern crate des;
2322

23+
use crypto_mac::generic_array::typenum::Unsigned;
24+
use crypto_mac::generic_array::GenericArray;
2425
pub use crypto_mac::Mac;
2526
use crypto_mac::MacResult;
26-
use crypto_mac::generic_array::GenericArray;
27-
use crypto_mac::generic_array::typenum::Unsigned;
28-
use des::Des;
2927
use des::block_cipher_trait::BlockCipher;
28+
use des::Des;
3029

3130
use core::fmt;
3231

@@ -46,7 +45,11 @@ impl Mac for Daa {
4645

4746
fn new(key: &GenericArray<u8, Self::KeySize>) -> Self {
4847
let cipher = Des::new(key);
49-
Self { cipher, buffer: Default::default(), pos: 0 }
48+
Self {
49+
cipher,
50+
buffer: Default::default(),
51+
pos: 0,
52+
}
5053
}
5154

5255
#[inline]

hmac/src/lib.rs

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -61,35 +61,36 @@
6161
//! to remove potential panic scenario. This is done by truncating hash output
6262
//! to the hash block size if needed.
6363
#![no_std]
64-
#![doc(html_logo_url =
65-
"https://raw.githubusercontent.com/RustCrypto/meta/master/logo_small.png")]
66-
pub extern crate digest;
64+
#![doc(html_logo_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo_small.png")]
6765
pub extern crate crypto_mac;
66+
pub extern crate digest;
6867

68+
use core::cmp::min;
69+
use core::fmt;
6970
pub use crypto_mac::Mac;
7071
use crypto_mac::{InvalidKeyLength, MacResult};
71-
use digest::{Input, BlockInput, FixedOutput, Reset};
72-
use digest::generic_array::{ArrayLength, GenericArray};
7372
use digest::generic_array::sequence::GenericSequence;
74-
use core::cmp::min;
75-
use core::fmt;
73+
use digest::generic_array::{ArrayLength, GenericArray};
74+
use digest::{BlockInput, FixedOutput, Input, Reset};
7675

7776
const IPAD: u8 = 0x36;
7877
const OPAD: u8 = 0x5C;
7978

8079
/// The `Hmac` struct represents an HMAC using a given hash function `D`.
8180
pub struct Hmac<D>
82-
where D: Input + BlockInput + FixedOutput + Reset + Default + Clone,
83-
D::BlockSize: ArrayLength<u8>
81+
where
82+
D: Input + BlockInput + FixedOutput + Reset + Default + Clone,
83+
D::BlockSize: ArrayLength<u8>,
8484
{
8585
digest: D,
8686
i_key_pad: GenericArray<u8, D::BlockSize>,
8787
opad_digest: D,
8888
}
8989

9090
impl<D> Clone for Hmac<D>
91-
where D: Input + BlockInput + FixedOutput + Reset + Default + Clone,
92-
D::BlockSize: ArrayLength<u8>
91+
where
92+
D: Input + BlockInput + FixedOutput + Reset + Default + Clone,
93+
D::BlockSize: ArrayLength<u8>,
9394
{
9495
fn clone(&self) -> Hmac<D> {
9596
Hmac {
@@ -101,22 +102,24 @@ impl<D> Clone for Hmac<D>
101102
}
102103

103104
impl<D> fmt::Debug for Hmac<D>
104-
where D: Input + BlockInput + FixedOutput + Reset + Default + Clone + fmt::Debug,
105-
D::BlockSize: ArrayLength<u8>
105+
where
106+
D: Input + BlockInput + FixedOutput + Reset + Default + Clone + fmt::Debug,
107+
D::BlockSize: ArrayLength<u8>,
106108
{
107109
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
108110
f.debug_struct("Hmac")
109-
.field("digest", &self.digest)
110-
.field("i_key_pad", &self.i_key_pad)
111-
.field("opad_digest", &self.opad_digest)
112-
.finish()
111+
.field("digest", &self.digest)
112+
.field("i_key_pad", &self.i_key_pad)
113+
.field("opad_digest", &self.opad_digest)
114+
.finish()
113115
}
114116
}
115117

116-
impl <D> Mac for Hmac<D>
117-
where D: Input + BlockInput + FixedOutput + Reset + Default + Clone,
118-
D::BlockSize: ArrayLength<u8>,
119-
D::OutputSize: ArrayLength<u8>
118+
impl<D> Mac for Hmac<D>
119+
where
120+
D: Input + BlockInput + FixedOutput + Reset + Default + Clone,
121+
D::BlockSize: ArrayLength<u8>,
122+
D::OutputSize: ArrayLength<u8>,
120123
{
121124
type OutputSize = D::OutputSize;
122125
type KeySize = D::BlockSize;

hmac/tests/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
#![no_std]
55
#[macro_use]
66
extern crate crypto_mac;
7+
extern crate hmac;
78
extern crate md5;
89
extern crate sha2;
9-
extern crate hmac;
1010

1111
use hmac::Hmac;
1212

pmac/benches/aes128_pmac.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![feature(test)]
22
#[macro_use]
33
extern crate crypto_mac;
4-
extern crate pmac;
54
extern crate aes;
5+
extern crate pmac;
66

77
bench!(pmac::Pmac::<aes::Aes128>);

pmac/benches/aes256_pmac.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![feature(test)]
22
#[macro_use]
33
extern crate crypto_mac;
4-
extern crate pmac;
54
extern crate aes;
5+
extern crate pmac;
66

77
bench!(pmac::Pmac::<aes::Aes256>);

0 commit comments

Comments
 (0)