11//! SASL-based authentication support.
22
3- use generic_array:: typenum:: U32 ;
4- use generic_array:: GenericArray ;
53use hmac:: { Hmac , Mac } ;
64use rand:: { self , Rng } ;
75use sha2:: { Digest , Sha256 } ;
@@ -33,13 +31,13 @@ fn normalize(pass: &[u8]) -> Vec<u8> {
3331 }
3432}
3533
36- fn hi ( str : & [ u8 ] , salt : & [ u8 ] , i : u32 ) -> GenericArray < u8 , U32 > {
34+ fn hi ( str : & [ u8 ] , salt : & [ u8 ] , i : u32 ) -> [ u8 ; 32 ] {
3735 let mut hmac = Hmac :: < Sha256 > :: new_varkey ( str) . expect ( "HMAC is able to accept all key sizes" ) ;
3836 hmac. input ( salt) ;
3937 hmac. input ( & [ 0 , 0 , 0 , 1 ] ) ;
4038 let mut prev = hmac. result ( ) . code ( ) ;
4139
42- let mut hi = GenericArray :: < u8 , U32 > :: clone_from_slice ( & prev) ;
40+ let mut hi = prev;
4341
4442 for _ in 1 ..i {
4543 let mut hmac = Hmac :: < Sha256 > :: new_varkey ( str) . expect ( "already checked above" ) ;
@@ -51,7 +49,7 @@ fn hi(str: &[u8], salt: &[u8], i: u32) -> GenericArray<u8, U32> {
5149 }
5250 }
5351
54- hi
52+ hi. into ( )
5553}
5654
5755enum ChannelBindingInner {
@@ -103,7 +101,7 @@ enum State {
103101 channel_binding : ChannelBinding ,
104102 } ,
105103 Finish {
106- salted_password : GenericArray < u8 , U32 > ,
104+ salted_password : [ u8 ; 32 ] ,
107105 auth_message : String ,
108106 } ,
109107 Done ,
@@ -220,7 +218,7 @@ impl ScramSha256 {
220218 hmac. input ( auth_message. as_bytes ( ) ) ;
221219 let client_signature = hmac. result ( ) ;
222220
223- let mut client_proof = GenericArray :: < u8 , U32 > :: clone_from_slice ( & client_key) ;
221+ let mut client_proof = client_key;
224222 for ( proof, signature) in client_proof. iter_mut ( ) . zip ( client_signature. code ( ) ) {
225223 * proof ^= signature;
226224 }
0 commit comments