@@ -33,15 +33,16 @@ fn normalize(pass: &[u8]) -> Vec<u8> {
33
33
}
34
34
35
35
pub ( 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" ) ;
37
38
hmac. update ( salt) ;
38
39
hmac. update ( & [ 0 , 0 , 0 , 1 ] ) ;
39
40
let mut prev = hmac. finalize ( ) . into_bytes ( ) ;
40
41
41
42
let mut hi = prev;
42
43
43
44
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" ) ;
45
46
hmac. update ( & prev) ;
46
47
prev = hmac. finalize ( ) . into_bytes ( ) ;
47
48
@@ -195,7 +196,7 @@ impl ScramSha256 {
195
196
196
197
let salted_password = hi ( & password, & salt, parsed. iteration_count ) ;
197
198
198
- let mut hmac = Hmac :: < Sha256 > :: new_varkey ( & salted_password)
199
+ let mut hmac = Hmac :: < Sha256 > :: new_from_slice ( & salted_password)
199
200
. expect ( "HMAC is able to accept all key sizes" ) ;
200
201
hmac. update ( b"Client Key" ) ;
201
202
let client_key = hmac. finalize ( ) . into_bytes ( ) ;
@@ -214,8 +215,8 @@ impl ScramSha256 {
214
215
215
216
let auth_message = format ! ( "n=,r={},{},{}" , client_nonce, message, self . message) ;
216
217
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" ) ;
219
220
hmac. update ( auth_message. as_bytes ( ) ) ;
220
221
let client_signature = hmac. finalize ( ) . into_bytes ( ) ;
221
222
@@ -266,13 +267,13 @@ impl ScramSha256 {
266
267
Err ( e) => return Err ( io:: Error :: new ( io:: ErrorKind :: InvalidInput , e) ) ,
267
268
} ;
268
269
269
- let mut hmac = Hmac :: < Sha256 > :: new_varkey ( & salted_password)
270
+ let mut hmac = Hmac :: < Sha256 > :: new_from_slice ( & salted_password)
270
271
. expect ( "HMAC is able to accept all key sizes" ) ;
271
272
hmac. update ( b"Server Key" ) ;
272
273
let server_key = hmac. finalize ( ) . into_bytes ( ) ;
273
274
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" ) ;
276
277
hmac. update ( auth_message. as_bytes ( ) ) ;
277
278
hmac. verify ( & verifier)
278
279
. map_err ( |_| io:: Error :: new ( io:: ErrorKind :: InvalidInput , "SCRAM verification error" ) )
0 commit comments