@@ -5,8 +5,6 @@ use super::{
55#[ cfg( feature = "mac" ) ]
66use crate :: MacMarker ;
77use crate :: { CollisionResistance , CustomizedInit , HashMarker , VarOutputCustomized } ;
8- #[ cfg( feature = "oid" ) ]
9- use const_oid:: { AssociatedOid , ObjectIdentifier } ;
108use core:: {
119 fmt,
1210 marker:: PhantomData ,
@@ -16,97 +14,82 @@ use crypto_common::{
1614 Block , BlockSizeUser , OutputSizeUser ,
1715 array:: { Array , ArraySize } ,
1816 hazmat:: { DeserializeStateError , SerializableState , SerializedState , SubSerializedStateSize } ,
19- typenum:: { IsLess , IsLessOrEqual , Le , LeEq , NonZero , Sum , U1 , U256 } ,
17+ typenum:: { IsLess , IsLessOrEqual , Le , NonZero , Sum , True , U1 , U256 } ,
2018} ;
2119
22- /// Dummy type used with [`CtVariableCoreWrapper`] in cases when
23- /// resulting hash does not have a known OID.
24- #[ derive( Copy , Clone , Debug , Eq , PartialEq , Hash ) ]
25- pub struct NoOid ;
26-
27- /// Wrapper around [`VariableOutputCore`] which selects output size
28- /// at compile time.
20+ /// Wrapper around [`VariableOutputCore`] which selects output size at compile time.
2921#[ derive( Clone ) ]
30- pub struct CtVariableCoreWrapper < T , OutSize , O = NoOid >
22+ pub struct CtOutWrapper < T , OutSize >
3123where
3224 T : VariableOutputCore ,
33- OutSize : ArraySize + IsLessOrEqual < T :: OutputSize > ,
34- LeEq < OutSize , T :: OutputSize > : NonZero ,
25+ OutSize : ArraySize + IsLessOrEqual < T :: OutputSize , Output = True > ,
3526{
3627 inner : T ,
37- _out : PhantomData < ( OutSize , O ) > ,
28+ _out : PhantomData < OutSize > ,
3829}
3930
40- impl < T , OutSize , O > HashMarker for CtVariableCoreWrapper < T , OutSize , O >
31+ impl < T , OutSize > HashMarker for CtOutWrapper < T , OutSize >
4132where
4233 T : VariableOutputCore + HashMarker ,
43- OutSize : ArraySize + IsLessOrEqual < T :: OutputSize > ,
44- LeEq < OutSize , T :: OutputSize > : NonZero ,
34+ OutSize : ArraySize + IsLessOrEqual < T :: OutputSize , Output = True > ,
4535{
4636}
4737
4838#[ cfg( feature = "mac" ) ]
49- impl < T , OutSize , O > MacMarker for CtVariableCoreWrapper < T , OutSize , O >
39+ impl < T , OutSize > MacMarker for CtOutWrapper < T , OutSize >
5040where
5141 T : VariableOutputCore + MacMarker ,
52- OutSize : ArraySize + IsLessOrEqual < T :: OutputSize > ,
53- LeEq < OutSize , T :: OutputSize > : NonZero ,
42+ OutSize : ArraySize + IsLessOrEqual < T :: OutputSize , Output = True > ,
5443{
5544}
5645
57- impl < T , OutSize > CollisionResistance for CtVariableCoreWrapper < T , OutSize >
46+ impl < T , OutSize > CollisionResistance for CtOutWrapper < T , OutSize >
5847where
5948 T : VariableOutputCore + CollisionResistance ,
60- OutSize : ArraySize + IsLessOrEqual < T :: OutputSize > ,
61- LeEq < OutSize , T :: OutputSize > : NonZero ,
49+ OutSize : ArraySize + IsLessOrEqual < T :: OutputSize , Output = True > ,
6250{
6351 type CollisionResistance = T :: CollisionResistance ;
6452}
6553
66- impl < T , OutSize , O > BlockSizeUser for CtVariableCoreWrapper < T , OutSize , O >
54+ impl < T , OutSize > BlockSizeUser for CtOutWrapper < T , OutSize >
6755where
6856 T : VariableOutputCore ,
69- OutSize : ArraySize + IsLessOrEqual < T :: OutputSize > ,
70- LeEq < OutSize , T :: OutputSize > : NonZero ,
57+ OutSize : ArraySize + IsLessOrEqual < T :: OutputSize , Output = True > ,
7158{
7259 type BlockSize = T :: BlockSize ;
7360}
7461
75- impl < T , OutSize , O > UpdateCore for CtVariableCoreWrapper < T , OutSize , O >
62+ impl < T , OutSize > UpdateCore for CtOutWrapper < T , OutSize >
7663where
7764 T : VariableOutputCore ,
78- OutSize : ArraySize + IsLessOrEqual < T :: OutputSize > ,
79- LeEq < OutSize , T :: OutputSize > : NonZero ,
65+ OutSize : ArraySize + IsLessOrEqual < T :: OutputSize , Output = True > ,
8066{
8167 #[ inline]
8268 fn update_blocks ( & mut self , blocks : & [ Block < Self > ] ) {
8369 self . inner . update_blocks ( blocks) ;
8470 }
8571}
8672
87- impl < T , OutSize , O > OutputSizeUser for CtVariableCoreWrapper < T , OutSize , O >
73+ impl < T , OutSize > OutputSizeUser for CtOutWrapper < T , OutSize >
8874where
8975 T : VariableOutputCore ,
90- OutSize : ArraySize + IsLessOrEqual < T :: OutputSize > ,
91- LeEq < OutSize , T :: OutputSize > : NonZero ,
76+ OutSize : ArraySize + IsLessOrEqual < T :: OutputSize , Output = True > ,
9277{
9378 type OutputSize = OutSize ;
9479}
9580
96- impl < T , OutSize , O > BufferKindUser for CtVariableCoreWrapper < T , OutSize , O >
81+ impl < T , OutSize > BufferKindUser for CtOutWrapper < T , OutSize >
9782where
9883 T : VariableOutputCore ,
99- OutSize : ArraySize + IsLessOrEqual < T :: OutputSize > ,
100- LeEq < OutSize , T :: OutputSize > : NonZero ,
84+ OutSize : ArraySize + IsLessOrEqual < T :: OutputSize , Output = True > ,
10185{
10286 type BufferKind = T :: BufferKind ;
10387}
10488
105- impl < T , OutSize , O > FixedOutputCore for CtVariableCoreWrapper < T , OutSize , O >
89+ impl < T , OutSize > FixedOutputCore for CtOutWrapper < T , OutSize >
10690where
10791 T : VariableOutputCore ,
108- OutSize : ArraySize + IsLessOrEqual < T :: OutputSize > ,
109- LeEq < OutSize , T :: OutputSize > : NonZero ,
92+ OutSize : ArraySize + IsLessOrEqual < T :: OutputSize , Output = True > ,
11093{
11194 #[ inline]
11295 fn finalize_fixed_core (
@@ -125,11 +108,10 @@ where
125108 }
126109}
127110
128- impl < T , OutSize , O > Default for CtVariableCoreWrapper < T , OutSize , O >
111+ impl < T , OutSize > Default for CtOutWrapper < T , OutSize >
129112where
130113 T : VariableOutputCore ,
131- OutSize : ArraySize + IsLessOrEqual < T :: OutputSize > ,
132- LeEq < OutSize , T :: OutputSize > : NonZero ,
114+ OutSize : ArraySize + IsLessOrEqual < T :: OutputSize , Output = True > ,
133115{
134116 #[ inline]
135117 fn default ( ) -> Self {
@@ -140,11 +122,10 @@ where
140122 }
141123}
142124
143- impl < T , OutSize , O > CustomizedInit for CtVariableCoreWrapper < T , OutSize , O >
125+ impl < T , OutSize > CustomizedInit for CtOutWrapper < T , OutSize >
144126where
145127 T : VariableOutputCore + VarOutputCustomized ,
146- OutSize : ArraySize + IsLessOrEqual < T :: OutputSize > ,
147- LeEq < OutSize , T :: OutputSize > : NonZero ,
128+ OutSize : ArraySize + IsLessOrEqual < T :: OutputSize , Output = True > ,
148129{
149130 #[ inline]
150131 fn new_customized ( customization : & [ u8 ] ) -> Self {
@@ -155,23 +136,21 @@ where
155136 }
156137}
157138
158- impl < T , OutSize , O > Reset for CtVariableCoreWrapper < T , OutSize , O >
139+ impl < T , OutSize > Reset for CtOutWrapper < T , OutSize >
159140where
160141 T : VariableOutputCore ,
161- OutSize : ArraySize + IsLessOrEqual < T :: OutputSize > ,
162- LeEq < OutSize , T :: OutputSize > : NonZero ,
142+ OutSize : ArraySize + IsLessOrEqual < T :: OutputSize , Output = True > ,
163143{
164144 #[ inline]
165145 fn reset ( & mut self ) {
166146 * self = Default :: default ( ) ;
167147 }
168148}
169149
170- impl < T , OutSize , O > AlgorithmName for CtVariableCoreWrapper < T , OutSize , O >
150+ impl < T , OutSize > AlgorithmName for CtOutWrapper < T , OutSize >
171151where
172152 T : VariableOutputCore + AlgorithmName ,
173- OutSize : ArraySize + IsLessOrEqual < T :: OutputSize > ,
174- LeEq < OutSize , T :: OutputSize > : NonZero ,
153+ OutSize : ArraySize + IsLessOrEqual < T :: OutputSize , Output = True > ,
175154{
176155 fn write_alg_name ( f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
177156 T :: write_alg_name ( f) ?;
@@ -180,61 +159,31 @@ where
180159 }
181160}
182161
183- #[ cfg( feature = "oid" ) ]
184- impl < T , OutSize , O > AssociatedOid for CtVariableCoreWrapper < T , OutSize , O >
185- where
186- T : VariableOutputCore ,
187- O : AssociatedOid ,
188- OutSize : ArraySize + IsLessOrEqual < T :: OutputSize > ,
189- LeEq < OutSize , T :: OutputSize > : NonZero ,
190- {
191- const OID : ObjectIdentifier = O :: OID ;
192- }
193-
194162#[ cfg( feature = "zeroize" ) ]
195- impl < T , OutSize , O > zeroize:: ZeroizeOnDrop for CtVariableCoreWrapper < T , OutSize , O >
163+ impl < T , OutSize > zeroize:: ZeroizeOnDrop for CtOutWrapper < T , OutSize >
196164where
197165 T : VariableOutputCore + zeroize:: ZeroizeOnDrop ,
198- OutSize : ArraySize + IsLessOrEqual < T :: OutputSize > ,
199- LeEq < OutSize , T :: OutputSize > : NonZero ,
166+ OutSize : ArraySize + IsLessOrEqual < T :: OutputSize , Output = True > ,
200167{
201168}
202169
203- impl < T , OutSize , O > fmt:: Debug for CtVariableCoreWrapper < T , OutSize , O >
170+ impl < T , OutSize > fmt:: Debug for CtOutWrapper < T , OutSize >
204171where
205172 T : VariableOutputCore + AlgorithmName ,
206- OutSize : ArraySize + IsLessOrEqual < T :: OutputSize > ,
207- LeEq < OutSize , T :: OutputSize > : NonZero ,
173+ OutSize : ArraySize + IsLessOrEqual < T :: OutputSize , Output = True > ,
208174{
209175 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
210176 Self :: write_alg_name ( f)
211177 }
212178}
213179
214- /// Implement dummy type with hidden docs which is used to "carry" hasher
215- /// OID for [`CtVariableCoreWrapper`].
216- #[ macro_export]
217- macro_rules! impl_oid_carrier {
218- ( $name: ident, $oid: literal) => {
219- #[ doc( hidden) ]
220- #[ derive( Copy , Clone , Debug , Eq , PartialEq , Hash ) ]
221- pub struct $name;
222-
223- #[ cfg( feature = "oid" ) ]
224- impl AssociatedOid for $name {
225- const OID : ObjectIdentifier = ObjectIdentifier :: new_unwrap( $oid) ;
226- }
227- } ;
228- }
229-
230180type CtVariableCoreWrapperSerializedStateSize < T > =
231181 Sum < <T as SerializableState >:: SerializedStateSize , U1 > ;
232182
233- impl < T , OutSize , O > SerializableState for CtVariableCoreWrapper < T , OutSize , O >
183+ impl < T , OutSize > SerializableState for CtOutWrapper < T , OutSize >
234184where
235185 T : VariableOutputCore + SerializableState ,
236- OutSize : ArraySize + IsLessOrEqual < T :: OutputSize > ,
237- LeEq < OutSize , T :: OutputSize > : NonZero ,
186+ OutSize : ArraySize + IsLessOrEqual < T :: OutputSize , Output = True > ,
238187 T :: BlockSize : IsLess < U256 > ,
239188 Le < T :: BlockSize , U256 > : NonZero ,
240189 T :: SerializedStateSize : Add < U1 > ,
0 commit comments