mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-10-02 15:25:32 +00:00
Upgrade hmac to 0.11 (#1443)
This commit is contained in:
parent
8b30f3059b
commit
c2e04a1f3c
8
Cargo.lock
generated
8
Cargo.lock
generated
@ -625,9 +625,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crypto-mac"
|
name = "crypto-mac"
|
||||||
version = "0.10.0"
|
version = "0.11.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4857fd85a0c34b3c3297875b747c1e02e06b6a0ea32dd892d8192b9ce0813ea6"
|
checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"generic-array",
|
"generic-array",
|
||||||
"subtle",
|
"subtle",
|
||||||
@ -1073,9 +1073,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hmac"
|
name = "hmac"
|
||||||
version = "0.10.1"
|
version = "0.11.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15"
|
checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crypto-mac",
|
"crypto-mac",
|
||||||
"digest",
|
"digest",
|
||||||
|
@ -124,7 +124,7 @@ futures-intrusive = "0.4.0"
|
|||||||
futures-util = { version = "0.3.5", default-features = false, features = ["alloc", "sink"] }
|
futures-util = { version = "0.3.5", default-features = false, features = ["alloc", "sink"] }
|
||||||
generic-array = { version = "0.14.4", default-features = false, optional = true }
|
generic-array = { version = "0.14.4", default-features = false, optional = true }
|
||||||
hex = "0.4.2"
|
hex = "0.4.2"
|
||||||
hmac = { version = "0.10.1", default-features = false, optional = true }
|
hmac = { version = "0.11.0", default-features = false, optional = true }
|
||||||
itoa = "0.4.5"
|
itoa = "0.4.5"
|
||||||
ipnetwork = { version = "0.17.0", default-features = false, optional = true }
|
ipnetwork = { version = "0.17.0", default-features = false, optional = true }
|
||||||
mac_address = { version = "1.1", default-features = false, optional = true }
|
mac_address = { version = "1.1", default-features = false, optional = true }
|
||||||
|
@ -98,7 +98,7 @@ pub(crate) async fn authenticate(
|
|||||||
)?;
|
)?;
|
||||||
|
|
||||||
// ClientKey := HMAC(SaltedPassword, "Client Key")
|
// ClientKey := HMAC(SaltedPassword, "Client Key")
|
||||||
let mut mac = Hmac::<Sha256>::new_varkey(&salted_password).map_err(Error::protocol)?;
|
let mut mac = Hmac::<Sha256>::new_from_slice(&salted_password).map_err(Error::protocol)?;
|
||||||
mac.update(b"Client Key");
|
mac.update(b"Client Key");
|
||||||
|
|
||||||
let client_key = mac.finalize().into_bytes();
|
let client_key = mac.finalize().into_bytes();
|
||||||
@ -122,7 +122,7 @@ pub(crate) async fn authenticate(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// ClientSignature := HMAC(StoredKey, AuthMessage)
|
// ClientSignature := HMAC(StoredKey, AuthMessage)
|
||||||
let mut mac = Hmac::<Sha256>::new_varkey(&stored_key).map_err(Error::protocol)?;
|
let mut mac = Hmac::<Sha256>::new_from_slice(&stored_key).map_err(Error::protocol)?;
|
||||||
mac.update(&auth_message.as_bytes());
|
mac.update(&auth_message.as_bytes());
|
||||||
|
|
||||||
let client_signature = mac.finalize().into_bytes();
|
let client_signature = mac.finalize().into_bytes();
|
||||||
@ -135,13 +135,13 @@ pub(crate) async fn authenticate(
|
|||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
// ServerKey := HMAC(SaltedPassword, "Server Key")
|
// ServerKey := HMAC(SaltedPassword, "Server Key")
|
||||||
let mut mac = Hmac::<Sha256>::new_varkey(&salted_password).map_err(Error::protocol)?;
|
let mut mac = Hmac::<Sha256>::new_from_slice(&salted_password).map_err(Error::protocol)?;
|
||||||
mac.update(b"Server Key");
|
mac.update(b"Server Key");
|
||||||
|
|
||||||
let server_key = mac.finalize().into_bytes();
|
let server_key = mac.finalize().into_bytes();
|
||||||
|
|
||||||
// ServerSignature := HMAC(ServerKey, AuthMessage)
|
// ServerSignature := HMAC(ServerKey, AuthMessage)
|
||||||
let mut mac = Hmac::<Sha256>::new_varkey(&server_key).map_err(Error::protocol)?;
|
let mut mac = Hmac::<Sha256>::new_from_slice(&server_key).map_err(Error::protocol)?;
|
||||||
mac.update(&auth_message.as_bytes());
|
mac.update(&auth_message.as_bytes());
|
||||||
|
|
||||||
// client-final-message = client-final-message-without-proof "," proof
|
// client-final-message = client-final-message-without-proof "," proof
|
||||||
@ -197,7 +197,7 @@ fn gen_nonce() -> String {
|
|||||||
|
|
||||||
// Hi(str, salt, i):
|
// Hi(str, salt, i):
|
||||||
fn hi<'a>(s: &'a str, salt: &'a [u8], iter_count: u32) -> Result<[u8; 32], Error> {
|
fn hi<'a>(s: &'a str, salt: &'a [u8], iter_count: u32) -> Result<[u8; 32], Error> {
|
||||||
let mut mac = Hmac::<Sha256>::new_varkey(s.as_bytes()).map_err(Error::protocol)?;
|
let mut mac = Hmac::<Sha256>::new_from_slice(s.as_bytes()).map_err(Error::protocol)?;
|
||||||
|
|
||||||
mac.update(&salt);
|
mac.update(&salt);
|
||||||
mac.update(&1u32.to_be_bytes());
|
mac.update(&1u32.to_be_bytes());
|
||||||
@ -206,7 +206,7 @@ fn hi<'a>(s: &'a str, salt: &'a [u8], iter_count: u32) -> Result<[u8; 32], Error
|
|||||||
let mut hi = u;
|
let mut hi = u;
|
||||||
|
|
||||||
for _ in 1..iter_count {
|
for _ in 1..iter_count {
|
||||||
let mut mac = Hmac::<Sha256>::new_varkey(s.as_bytes()).map_err(Error::protocol)?;
|
let mut mac = Hmac::<Sha256>::new_from_slice(s.as_bytes()).map_err(Error::protocol)?;
|
||||||
mac.update(u.as_slice());
|
mac.update(u.as_slice());
|
||||||
u = mac.finalize().into_bytes();
|
u = mac.finalize().into_bytes();
|
||||||
hi = hi.iter().zip(u.iter()).map(|(&a, &b)| a ^ b).collect();
|
hi = hi.iter().zip(u.iter()).map(|(&a, &b)| a ^ b).collect();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user