Skip to content

Commit 4e8b907

Browse files
committed
fix build
1 parent 83616fa commit 4e8b907

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

postgres-protocol/src/authentication/sasl.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,16 @@ fn normalize(pass: &[u8]) -> Vec<u8> {
3333
}
3434

3535
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");
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"))

postgres-protocol/src/password/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ pub(crate) fn scram_sha_256_salt(password: &[u8], salt: [u8; SCRAM_DEFAULT_SALT_
6161
let salted_password = sasl::hi(&prepared, &salt, SCRAM_DEFAULT_ITERATIONS);
6262

6363
// client key
64-
let mut hmac =
65-
Hmac::<Sha256>::new_varkey(&salted_password).expect("HMAC is able to accept all key sizes");
64+
let mut hmac = Hmac::<Sha256>::new_from_slice(&salted_password)
65+
.expect("HMAC is able to accept all key sizes");
6666
hmac.update(b"Client Key");
6767
let client_key = hmac.finalize().into_bytes();
6868

@@ -72,8 +72,8 @@ pub(crate) fn scram_sha_256_salt(password: &[u8], salt: [u8; SCRAM_DEFAULT_SALT_
7272
let stored_key = hash.finalize_fixed();
7373

7474
// server key
75-
let mut hmac =
76-
Hmac::<Sha256>::new_varkey(&salted_password).expect("HMAC is able to accept all key sizes");
75+
let mut hmac = Hmac::<Sha256>::new_from_slice(&salted_password)
76+
.expect("HMAC is able to accept all key sizes");
7777
hmac.update(b"Server Key");
7878
let server_key = hmac.finalize().into_bytes();
7979

0 commit comments

Comments
 (0)