Skip to content

Commit 470c789

Browse files
authored
blake2: add missing types of common digest sizes (#564)
Adds the following fixed digest sizes: `BLAKE2s-128`, `BLAKE2b-128`, and `BLAKE2b-256`.
1 parent e766aec commit 470c789

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

blake2/src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use core::{fmt, marker::PhantomData, ops::Div};
1818
use digest::{
1919
array::{Array, ArraySize},
2020
block_buffer::{Lazy, LazyBuffer},
21-
consts::{U128, U32, U4, U64},
21+
consts::{U128, U16, U32, U4, U64},
2222
core_api::{
2323
AlgorithmName, Block, BlockSizeUser, Buffer, BufferKindUser, CoreWrapper,
2424
CtVariableCoreWrapper, OutputSizeUser, RtVariableCoreWrapper, TruncSide, UpdateCore,
@@ -68,6 +68,10 @@ pub type Blake2bVar = RtVariableCoreWrapper<Blake2bVarCore>;
6868
pub type Blake2bCore<OutSize> = CtVariableCoreWrapper<Blake2bVarCore, OutSize>;
6969
/// BLAKE2b generic over output size.
7070
pub type Blake2b<OutSize> = CoreWrapper<Blake2bCore<OutSize>>;
71+
/// BLAKE2b-128 hasher state.
72+
pub type Blake2b128 = Blake2b<U16>;
73+
/// BLAKE2b-256 hasher state.
74+
pub type Blake2b256 = Blake2b<U32>;
7175
/// BLAKE2b-512 hasher state.
7276
pub type Blake2b512 = Blake2b<U64>;
7377

@@ -98,6 +102,8 @@ pub type Blake2sVar = RtVariableCoreWrapper<Blake2sVarCore>;
98102
pub type Blake2sCore<OutSize> = CtVariableCoreWrapper<Blake2sVarCore, OutSize>;
99103
/// BLAKE2s generic over output size.
100104
pub type Blake2s<OutSize> = CoreWrapper<Blake2sCore<OutSize>>;
105+
/// BLAKE2s-128 hasher state.
106+
pub type Blake2s128 = Blake2s<U16>;
101107
/// BLAKE2s-256 hasher state.
102108
pub type Blake2s256 = Blake2s<U32>;
103109

0 commit comments

Comments
 (0)