@@ -33,15 +33,16 @@ fn normalize(pass: &[u8]) -> Vec<u8> {
3333}
3434
3535pub ( crate ) fn hi ( str : & [ u8 ] , salt : & [ u8 ] , i : u32 ) -> [ u8 ; 32 ] {
36- let mut hmac = Hmac :: < Sha256 > :: new_varkey ( str) . expect ( "HMAC is able to accept all key sizes" ) ;
36+ let mut hmac =
37+ Hmac :: < Sha256 > :: new_from_slice ( str) . expect ( "HMAC is able to accept all key sizes" ) ;
3738 hmac. update ( salt) ;
3839 hmac. update ( & [ 0 , 0 , 0 , 1 ] ) ;
3940 let mut prev = hmac. finalize ( ) . into_bytes ( ) ;
4041
4142 let mut hi = prev;
4243
4344 for _ in 1 ..i {
44- let mut hmac = Hmac :: < Sha256 > :: new_varkey ( str) . expect ( "already checked above" ) ;
45+ let mut hmac = Hmac :: < Sha256 > :: new_from_slice ( str) . expect ( "already checked above" ) ;
4546 hmac. update ( & prev) ;
4647 prev = hmac. finalize ( ) . into_bytes ( ) ;
4748
@@ -195,7 +196,7 @@ impl ScramSha256 {
195196
196197 let salted_password = hi ( & password, & salt, parsed. iteration_count ) ;
197198
198- let mut hmac = Hmac :: < Sha256 > :: new_varkey ( & salted_password)
199+ let mut hmac = Hmac :: < Sha256 > :: new_from_slice ( & salted_password)
199200 . expect ( "HMAC is able to accept all key sizes" ) ;
200201 hmac. update ( b"Client Key" ) ;
201202 let client_key = hmac. finalize ( ) . into_bytes ( ) ;
@@ -214,8 +215,8 @@ impl ScramSha256 {
214215
215216 let auth_message = format ! ( "n=,r={},{},{}" , client_nonce, message, self . message) ;
216217
217- let mut hmac =
218- Hmac :: < Sha256 > :: new_varkey ( & stored_key ) . expect ( "HMAC is able to accept all key sizes" ) ;
218+ let mut hmac = Hmac :: < Sha256 > :: new_from_slice ( & stored_key )
219+ . expect ( "HMAC is able to accept all key sizes" ) ;
219220 hmac. update ( auth_message. as_bytes ( ) ) ;
220221 let client_signature = hmac. finalize ( ) . into_bytes ( ) ;
221222
@@ -266,13 +267,13 @@ impl ScramSha256 {
266267 Err ( e) => return Err ( io:: Error :: new ( io:: ErrorKind :: InvalidInput , e) ) ,
267268 } ;
268269
269- let mut hmac = Hmac :: < Sha256 > :: new_varkey ( & salted_password)
270+ let mut hmac = Hmac :: < Sha256 > :: new_from_slice ( & salted_password)
270271 . expect ( "HMAC is able to accept all key sizes" ) ;
271272 hmac. update ( b"Server Key" ) ;
272273 let server_key = hmac. finalize ( ) . into_bytes ( ) ;
273274
274- let mut hmac =
275- Hmac :: < Sha256 > :: new_varkey ( & server_key ) . expect ( "HMAC is able to accept all key sizes" ) ;
275+ let mut hmac = Hmac :: < Sha256 > :: new_from_slice ( & server_key )
276+ . expect ( "HMAC is able to accept all key sizes" ) ;
276277 hmac. update ( auth_message. as_bytes ( ) ) ;
277278 hmac. verify ( & verifier)
278279 . map_err ( |_| io:: Error :: new ( io:: ErrorKind :: InvalidInput , "SCRAM verification error" ) )
0 commit comments