Skip to content

Commit 2e2dbcd

Browse files
authored
chore(deps): bump digest to master (#123)
1 parent b1d7fe6 commit 2e2dbcd

6 files changed

Lines changed: 33 additions & 60 deletions

File tree

Cargo.lock

Lines changed: 8 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,15 @@ members = [
1010

1111
[profile.dev]
1212
opt-level = 2
13+
14+
[patch.crates-io]
15+
cipher = { git = "https://github.com/RustCrypto/traits.git" }
16+
crypto-common = { git = "https://github.com/RustCrypto/traits.git" }
17+
digest = { git = "https://github.com/RustCrypto/traits.git" }
18+
19+
cmac = { git = "https://github.com/RustCrypto/MACs.git" }
20+
hmac = { git = "https://github.com/RustCrypto/MACs.git" }
21+
22+
belt-hash = { git = "https://github.com/RustCrypto/hashes.git" }
23+
sha1 = { git = "https://github.com/RustCrypto/hashes.git" }
24+
sha2 = { git = "https://github.com/RustCrypto/hashes.git" }

bake-kdf/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#![warn(missing_docs, rust_2018_idioms)]
1111

1212
use belt_hash::digest::FixedOutput;
13-
use belt_hash::{BeltHash, Digest, belt_compress};
13+
use belt_hash::{BeltHash, Digest, block_api::belt_compress};
1414

1515
/// `belt-keyexpand` key expansion algorithm described in STB 34.101.34-2020 8.1.2.
1616
///

hkdf/src/lib.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,11 @@ where
170170
impl<H, I> fmt::Debug for HkdfExtract<H, I>
171171
where
172172
H: OutputSizeUser,
173-
I: HmacImpl<H>,
174-
I::Core: AlgorithmName,
173+
I: HmacImpl<H> + AlgorithmName,
175174
{
176175
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
177176
f.write_str("HkdfExtract<")?;
178-
<I::Core as AlgorithmName>::write_alg_name(f)?;
177+
<I as AlgorithmName>::write_alg_name(f)?;
179178
f.write_str("> { ... }")
180179
}
181180
}
@@ -185,7 +184,7 @@ where
185184
/// [crate root](index.html#usage).
186185
#[derive(Clone)]
187186
pub struct Hkdf<H: OutputSizeUser, I: HmacImpl<H> = Hmac<H>> {
188-
hmac: I::Core,
187+
hmac: I,
189188
_pd: PhantomData<H>,
190189
}
191190

@@ -206,7 +205,7 @@ impl<H: OutputSizeUser, I: HmacImpl<H>> Hkdf<H, I> {
206205
return Err(InvalidPrkLength);
207206
}
208207
Ok(Self {
209-
hmac: I::new_core(prk),
208+
hmac: I::new_from_slice(prk),
210209
_pd: PhantomData,
211210
})
212211
}
@@ -235,7 +234,7 @@ impl<H: OutputSizeUser, I: HmacImpl<H>> Hkdf<H, I> {
235234
}
236235

237236
for (block_n, block) in okm.chunks_mut(chunk_len).enumerate() {
238-
let mut hmac = I::from_core(&self.hmac);
237+
let mut hmac = self.hmac.clone();
239238

240239
if let Some(ref prev) = prev {
241240
hmac.update(prev)
@@ -272,16 +271,16 @@ impl<H, I> fmt::Debug for Hkdf<H, I>
272271
where
273272
H: OutputSizeUser,
274273
I: HmacImpl<H>,
275-
I::Core: AlgorithmName,
274+
I: AlgorithmName,
276275
{
277276
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
278277
f.write_str("Hkdf<")?;
279-
<I::Core as AlgorithmName>::write_alg_name(f)?;
278+
<I as AlgorithmName>::write_alg_name(f)?;
280279
f.write_str("> { ... }")
281280
}
282281
}
283282

284283
/// Sealed trait implemented for [`Hmac`] and [`SimpleHmac`].
285-
pub trait HmacImpl<H: OutputSizeUser>: sealed::Sealed<H> {}
284+
pub trait HmacImpl<H: OutputSizeUser>: sealed::Sealed<H> + Clone {}
286285

287-
impl<H: OutputSizeUser, T: sealed::Sealed<H>> HmacImpl<H> for T {}
286+
impl<H: OutputSizeUser, T: sealed::Sealed<H> + Clone> HmacImpl<H> for T {}

hkdf/src/sealed.rs

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
use hmac::digest::{
22
Digest, FixedOutput, KeyInit, Output, Update,
3-
core_api::{BlockSizeUser, CoreWrapper, OutputSizeUser},
3+
block_api::{BlockSizeUser, OutputSizeUser},
44
};
5-
use hmac::{EagerHash, Hmac, HmacCore, SimpleHmac};
5+
use hmac::{Hmac, SimpleHmac, block_api::EagerHash};
66

77
pub trait Sealed<H: OutputSizeUser> {
8-
type Core: Clone;
9-
108
fn new_from_slice(key: &[u8]) -> Self;
119

12-
fn new_core(key: &[u8]) -> Self::Core;
13-
14-
fn from_core(core: &Self::Core) -> Self;
15-
1610
fn update(&mut self, data: &[u8]);
1711

1812
fn finalize(self) -> Output<H>;
@@ -22,23 +16,11 @@ impl<H> Sealed<H> for Hmac<H>
2216
where
2317
H: EagerHash + OutputSizeUser,
2418
{
25-
type Core = HmacCore<H>;
26-
2719
#[inline(always)]
2820
fn new_from_slice(key: &[u8]) -> Self {
2921
KeyInit::new_from_slice(key).expect("HMAC can take a key of any size")
3022
}
3123

32-
#[inline(always)]
33-
fn new_core(key: &[u8]) -> Self::Core {
34-
HmacCore::new_from_slice(key).expect("HMAC can take a key of any size")
35-
}
36-
37-
#[inline(always)]
38-
fn from_core(core: &Self::Core) -> Self {
39-
CoreWrapper::from_core(core.clone())
40-
}
41-
4224
#[inline(always)]
4325
fn update(&mut self, data: &[u8]) {
4426
Update::update(self, data);
@@ -54,23 +36,11 @@ where
5436
}
5537

5638
impl<H: Digest + BlockSizeUser + Clone> Sealed<H> for SimpleHmac<H> {
57-
type Core = Self;
58-
5939
#[inline(always)]
6040
fn new_from_slice(key: &[u8]) -> Self {
6141
KeyInit::new_from_slice(key).expect("HMAC can take a key of any size")
6242
}
6343

64-
#[inline(always)]
65-
fn new_core(key: &[u8]) -> Self::Core {
66-
KeyInit::new_from_slice(key).expect("HMAC can take a key of any size")
67-
}
68-
69-
#[inline(always)]
70-
fn from_core(core: &Self::Core) -> Self {
71-
core.clone()
72-
}
73-
7444
#[inline(always)]
7545
fn update(&mut self, data: &[u8]) {
7646
Update::update(self, data);

hkdf/tests/rfc5869.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use hex_literal::hex;
2-
use hkdf::{Hkdf, hmac::EagerHash};
2+
use hkdf::{Hkdf, hmac::block_api::EagerHash};
33
use sha1::Sha1;
44
use sha2::{Sha256, digest::OutputSizeUser};
55

0 commit comments

Comments
 (0)