Skip to content

Commit fc69e6e

Browse files
committed
update
1 parent bdef41a commit fc69e6e

21 files changed

Lines changed: 130 additions & 58 deletions

File tree

Cargo.lock

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

ascon-hash/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ impl SerializableState for AsconXofCore {
283283
digest::newtype_fixed_hash!(
284284
/// Ascon-Hash256
285285
pub struct AsconHash256(AsconCore);
286+
impl: FixedHashTraits;
286287
);
287288

288289
digest::newtype_xof_hash!(

belt-hash/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ pub use block_api::{BeltHashCore, belt_compress};
1616
digest::newtype_fixed_hash!(
1717
/// BelT hasher state.
1818
pub struct BeltHash(BeltHashCore);
19-
oid: "1.2.112.0.2.0.34.101.31.81"
19+
oid: "1.2.112.0.2.0.34.101.31.81";
20+
impl: FixedHashTraits;
2021
);

blake2/src/lib.rs

Lines changed: 57 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,21 @@
1010
#![cfg_attr(feature = "simd", feature(platform_intrinsics, repr_simd))]
1111
#![cfg_attr(feature = "simd", allow(incomplete_features))]
1212

13-
#[cfg(feature = "std")]
14-
extern crate std;
15-
1613
pub use digest::{self, Digest};
1714

1815
use core::{fmt, marker::PhantomData, ops::Div};
1916
use digest::{
20-
FixedOutput, HashMarker, InvalidOutputSize, MacMarker, Output, Update, VarOutputCustomized,
17+
CustomizedInit, FixedOutput, HashMarker, InvalidOutputSize, MacMarker, Output, Update,
18+
VarOutputCustomized,
2119
array::{Array, ArraySize},
2220
block_buffer::{Lazy, LazyBuffer},
2321
consts::{U4, U16, U32, U64, U128},
2422
core_api::{
25-
AlgorithmName, Block, BlockSizeUser, Buffer, BufferKindUser, CoreWrapper, CtOutWrapper,
26-
OutputSizeUser, RtVariableCoreWrapper, TruncSide, UpdateCore, VariableOutputCore,
23+
AlgorithmName, Block, BlockSizeUser, Buffer, BufferKindUser, OutputSizeUser, TruncSide,
24+
UpdateCore, VariableOutputCore,
2725
},
2826
crypto_common::{InvalidLength, Key, KeyInit, KeySizeUser},
29-
typenum::{IsLessOrEqual, LeEq, NonZero, Unsigned},
27+
typenum::{IsLessOrEqual, LeEq, NonZero, True, Unsigned},
3028
};
3129
#[cfg(feature = "reset")]
3230
use digest::{FixedOutputReset, Reset};
@@ -62,12 +60,32 @@ blake2_impl!(
6260
"Blake2b instance with a fixed output.",
6361
);
6462

65-
/// BLAKE2b which allows to choose output size at runtime.
66-
pub type Blake2bVar = RtVariableCoreWrapper<Blake2bVarCore>;
67-
/// Core hasher state of BLAKE2b generic over output size.
68-
pub type Blake2bCore<OutSize> = CtOutWrapper<Blake2bVarCore, OutSize>;
69-
/// BLAKE2b generic over output size.
70-
pub type Blake2b<OutSize> = CoreWrapper<Blake2bCore<OutSize>>;
63+
digest::newtype_ct_variable_hash!(
64+
/// BLAKE2b generic over output size.
65+
pub struct Blake2b<OutSize>(Blake2bVarCore);
66+
exclude: SerializableState;
67+
max_size: U64;
68+
);
69+
70+
// TODO: impl in the macro
71+
impl<OutSize> CustomizedInit for Blake2b<OutSize>
72+
where
73+
OutSize: ArraySize + IsLessOrEqual<U64, Output = True>,
74+
{
75+
fn new_customized(customization: &[u8]) -> Self {
76+
Self {
77+
core: CustomizedInit::new_customized(customization),
78+
buffer: Default::default(),
79+
}
80+
}
81+
}
82+
83+
digest::newtype_rt_variable_hash!(
84+
/// BLAKE2b which allows to choose output size at runtime.
85+
pub struct Blake2bVar(Blake2bVarCore);
86+
exclude: SerializableState;
87+
);
88+
7189
/// BLAKE2b-128 hasher state.
7290
pub type Blake2b128 = Blake2b<U16>;
7391
/// BLAKE2b-256 hasher state.
@@ -96,12 +114,32 @@ blake2_impl!(
96114
"Blake2s instance with a fixed output.",
97115
);
98116

99-
/// BLAKE2s which allows to choose output size at runtime.
100-
pub type Blake2sVar = RtVariableCoreWrapper<Blake2sVarCore>;
101-
/// Core hasher state of BLAKE2s generic over output size.
102-
pub type Blake2sCore<OutSize> = CtOutWrapper<Blake2sVarCore, OutSize>;
103-
/// BLAKE2s generic over output size.
104-
pub type Blake2s<OutSize> = CoreWrapper<Blake2sCore<OutSize>>;
117+
digest::newtype_ct_variable_hash!(
118+
/// BLAKE2s generic over output size.
119+
pub struct Blake2s<OutSize>(Blake2sVarCore);
120+
exclude: SerializableState;
121+
max_size: U32;
122+
);
123+
124+
// TODO: impl in the macro
125+
impl<OutSize> CustomizedInit for Blake2s<OutSize>
126+
where
127+
OutSize: ArraySize + IsLessOrEqual<U32, Output = True>,
128+
{
129+
fn new_customized(customization: &[u8]) -> Self {
130+
Self {
131+
core: CustomizedInit::new_customized(customization),
132+
buffer: Default::default(),
133+
}
134+
}
135+
}
136+
137+
digest::newtype_rt_variable_hash!(
138+
/// BLAKE2s which allows to choose output size at runtime.
139+
pub struct Blake2sVar(Blake2sVarCore);
140+
exclude: SerializableState;
141+
);
142+
105143
/// BLAKE2s-128 hasher state.
106144
pub type Blake2s128 = Blake2s<U16>;
107145
/// BLAKE2s-256 hasher state.

fsb/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,25 @@ pub use block_api::{Fsb160Core, Fsb224Core, Fsb256Core, Fsb384Core, Fsb512Core};
1919
digest::newtype_fixed_hash!(
2020
/// FSB-160 hasher.
2121
pub struct Fsb160(Fsb160Core);
22+
impl: FixedHashTraits;
2223
);
2324
digest::newtype_fixed_hash!(
2425
/// FSB-224 hasher.
2526
pub struct Fsb224(Fsb224Core);
27+
impl: FixedHashTraits;
2628
);
2729
digest::newtype_fixed_hash!(
2830
/// FSB-256 hasher.
2931
pub struct Fsb256(Fsb256Core);
32+
impl: FixedHashTraits;
3033
);
3134
digest::newtype_fixed_hash!(
3235
/// FSB-384 hasher.
3336
pub struct Fsb384(Fsb384Core);
37+
impl: FixedHashTraits;
3438
);
3539
digest::newtype_fixed_hash!(
3640
/// FSB-512 hasher.
3741
pub struct Fsb512(Fsb512Core);
42+
impl: FixedHashTraits;
3843
);

gost94/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use params::Gost94Params;
1919
digest::newtype_fixed_hash!(
2020
/// GOST94 hash function generic over parameters.
2121
pub struct Gost94<P: Gost94Params>(Gost94Core<P>);
22+
impl: FixedHashTraits;
2223
);
2324

2425
/// GOST94 hash function with CryptoPro parameters.

jh/src/block_api.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use digest::{
66
AlgorithmName, Block, BlockSizeUser, Buffer, BufferKindUser, Eager, OutputSizeUser,
77
TruncSide, UpdateCore, VariableOutputCore,
88
},
9-
crypto_common::hazmat::{DeserializeStateError, SerializableState, SerializedState},
109
typenum::{U64, Unsigned},
1110
};
1211

@@ -108,17 +107,3 @@ impl Drop for JhCore {
108107

109108
#[cfg(feature = "zeroize")]
110109
impl digest::zeroize::ZeroizeOnDrop for JhCore {}
111-
112-
impl SerializableState for JhCore {
113-
type SerializedStateSize = U64;
114-
115-
fn serialize(&self) -> SerializedState<Self> {
116-
todo!()
117-
}
118-
119-
fn deserialize(
120-
_serialized_state: &SerializedState<Self>,
121-
) -> Result<Self, DeserializeStateError> {
122-
todo!()
123-
}
124-
}

jh/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,20 @@ use digest::{
2323
digest::newtype_fixed_hash!(
2424
/// JH-224 hasher.
2525
pub struct Jh224(CtOutWrapper<JhCore, U28>);
26+
impl: BaseFixedTraits Default Clone HashMarker Reset FixedOutputReset;
2627
);
2728
digest::newtype_fixed_hash!(
2829
/// JH-256 hasher.
2930
pub struct Jh256(CtOutWrapper<JhCore, U32>);
31+
impl: BaseFixedTraits Default Clone HashMarker Reset FixedOutputReset;
3032
);
3133
digest::newtype_fixed_hash!(
3234
/// JH-384 hasher.
3335
pub struct Jh384(CtOutWrapper<JhCore, U48>);
36+
impl: BaseFixedTraits Default Clone HashMarker Reset FixedOutputReset;
3437
);
3538
digest::newtype_fixed_hash!(
3639
/// JH-512 hasher.
3740
pub struct Jh512(CtOutWrapper<JhCore, U64>);
41+
impl: BaseFixedTraits Default Clone HashMarker Reset FixedOutputReset;
3842
);

md2/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ pub use block_api::Md2Core;
1818
digest::newtype_fixed_hash!(
1919
/// MD2 hasher.
2020
pub struct Md2(Md2Core);
21-
oid: "1.2.840.113549.2.2"
21+
oid: "1.2.840.113549.2.2";
22+
impl: FixedHashTraits;
2223
);

md4/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ pub use block_api::Md4Core;
1717
digest::newtype_fixed_hash!(
1818
/// MD4 hash.
1919
pub struct Md4(Md4Core);
20-
oid: "1.2.840.113549.2.4"
20+
oid: "1.2.840.113549.2.4";
21+
impl: FixedHashTraits;
2122
);

0 commit comments

Comments
 (0)