@@ -28,20 +28,10 @@ macro_rules! blake2_impl {
2828 /// make sure to compare codes in constant time! It can be done
2929 /// for example by using `subtle` crate.
3030 pub fn new_keyed( key: & [ u8 ] , output_size: usize ) -> Self {
31- Self :: with_params( key, & [ ] , & [ ] , output_size)
32- }
33-
34- /// Creates a new hashing context with the full set of sequential-mode parameters.
35- pub fn with_params( key: & [ u8 ] , salt: & [ u8 ] , persona: & [ u8 ] , output_size: usize ) -> Self {
3631 let mut upstream_params = <$upstream_params>:: new( ) ;
37- upstream_params
38- . key( key)
39- . salt( salt)
40- . personal( persona)
41- . hash_length( output_size) ;
42-
32+ upstream_params. key( key) ;
33+ upstream_params. hash_length( output_size) ;
4334 let upstream_state = upstream_params. to_state( ) ;
44-
4535 Self { upstream_params, upstream_state, output_size }
4636 }
4737
@@ -98,24 +88,11 @@ macro_rules! blake2_impl {
9888 upstream_state: $upstream_state,
9989 }
10090
101- impl $fix_state {
102- /// Creates a new hashing context with the full set of sequential-mode parameters.
103- pub fn with_params( key: & [ u8 ] , salt: & [ u8 ] , persona: & [ u8 ] ) -> Self {
104- let mut upstream_params = <$upstream_params>:: new( ) ;
105- upstream_params
106- . key( key)
107- . salt( salt)
108- . personal( persona) ;
109-
110- let upstream_state = upstream_params. to_state( ) ;
111-
112- Self { upstream_params, upstream_state }
113- }
114- }
115-
11691 impl Default for $fix_state {
11792 fn default ( ) -> Self {
118- Self :: with_params( & [ ] , & [ ] , & [ ] )
93+ let upstream_params = <$upstream_params>:: new( ) ;
94+ let upstream_state = upstream_params. to_state( ) ;
95+ Self { upstream_params, upstream_state }
11996 }
12097 }
12198
@@ -147,14 +124,20 @@ macro_rules! blake2_impl {
147124 type KeySize = $key_bytes_typenum;
148125
149126 fn new( key: & GenericArray <u8 , $key_bytes_typenum>) -> Self {
150- Self :: with_params( & key[ ..] , & [ ] , & [ ] )
127+ let mut upstream_params = <$upstream_params>:: new( ) ;
128+ upstream_params. key( & key[ ..] ) ;
129+ let upstream_state = upstream_params. to_state( ) ;
130+ Self { upstream_params, upstream_state }
151131 }
152132
153133 fn new_varkey( key: & [ u8 ] ) -> Result <Self , InvalidKeyLength > {
154134 if key. len( ) > <$key_bytes_typenum>:: to_usize( ) {
155135 Err ( InvalidKeyLength )
156136 } else {
157- Ok ( Self :: with_params( key, & [ ] , & [ ] ) )
137+ let mut upstream_params = <$upstream_params>:: new( ) ;
138+ upstream_params. key( key) ;
139+ let upstream_state = upstream_params. to_state( ) ;
140+ Ok ( Self { upstream_params, upstream_state } )
158141 }
159142 }
160143 }
0 commit comments