From 75a67fd06bb3cec6d702e36f55a645c943be5874 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Mon, 23 Dec 2019 16:12:28 -0800 Subject: [PATCH] Remove unneeded generic-array dependency --- postgres-protocol/Cargo.toml | 1 - postgres-protocol/src/authentication/sasl.rs | 12 +++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/postgres-protocol/Cargo.toml b/postgres-protocol/Cargo.toml index 155cf62a..ae45eb63 100644 --- a/postgres-protocol/Cargo.toml +++ b/postgres-protocol/Cargo.toml @@ -13,7 +13,6 @@ base64 = "0.11" byteorder = "1.0" bytes = "0.5" fallible-iterator = "0.2" -generic-array = "0.13" hmac = "0.7" md5 = "0.7" memchr = "2.0" diff --git a/postgres-protocol/src/authentication/sasl.rs b/postgres-protocol/src/authentication/sasl.rs index bcd2c4b6..af458bba 100644 --- a/postgres-protocol/src/authentication/sasl.rs +++ b/postgres-protocol/src/authentication/sasl.rs @@ -1,7 +1,5 @@ //! SASL-based authentication support. -use generic_array::typenum::U32; -use generic_array::GenericArray; use hmac::{Hmac, Mac}; use rand::{self, Rng}; use sha2::{Digest, Sha256}; @@ -33,13 +31,13 @@ fn normalize(pass: &[u8]) -> Vec { } } -fn hi(str: &[u8], salt: &[u8], i: u32) -> GenericArray { +fn hi(str: &[u8], salt: &[u8], i: u32) -> [u8; 32] { let mut hmac = Hmac::::new_varkey(str).expect("HMAC is able to accept all key sizes"); hmac.input(salt); hmac.input(&[0, 0, 0, 1]); let mut prev = hmac.result().code(); - let mut hi = GenericArray::::clone_from_slice(&prev); + let mut hi = prev; for _ in 1..i { let mut hmac = Hmac::::new_varkey(str).expect("already checked above"); @@ -51,7 +49,7 @@ fn hi(str: &[u8], salt: &[u8], i: u32) -> GenericArray { } } - hi + hi.into() } enum ChannelBindingInner { @@ -103,7 +101,7 @@ enum State { channel_binding: ChannelBinding, }, Finish { - salted_password: GenericArray, + salted_password: [u8; 32], auth_message: String, }, Done, @@ -220,7 +218,7 @@ impl ScramSha256 { hmac.input(auth_message.as_bytes()); let client_signature = hmac.result(); - let mut client_proof = GenericArray::::clone_from_slice(&client_key); + let mut client_proof = client_key; for (proof, signature) in client_proof.iter_mut().zip(client_signature.code()) { *proof ^= signature; }