1
1
//! SASL-based authentication support.
2
2
3
- use generic_array:: typenum:: U32 ;
4
- use generic_array:: GenericArray ;
5
3
use hmac:: { Hmac , Mac } ;
6
4
use rand:: { self , Rng } ;
7
5
use sha2:: { Digest , Sha256 } ;
@@ -33,13 +31,13 @@ fn normalize(pass: &[u8]) -> Vec<u8> {
33
31
}
34
32
}
35
33
36
- fn hi ( str : & [ u8 ] , salt : & [ u8 ] , i : u32 ) -> GenericArray < u8 , U32 > {
34
+ fn hi ( str : & [ u8 ] , salt : & [ u8 ] , i : u32 ) -> [ u8 ; 32 ] {
37
35
let mut hmac = Hmac :: < Sha256 > :: new_varkey ( str) . expect ( "HMAC is able to accept all key sizes" ) ;
38
36
hmac. input ( salt) ;
39
37
hmac. input ( & [ 0 , 0 , 0 , 1 ] ) ;
40
38
let mut prev = hmac. result ( ) . code ( ) ;
41
39
42
- let mut hi = GenericArray :: < u8 , U32 > :: clone_from_slice ( & prev) ;
40
+ let mut hi = prev;
43
41
44
42
for _ in 1 ..i {
45
43
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> {
51
49
}
52
50
}
53
51
54
- hi
52
+ hi. into ( )
55
53
}
56
54
57
55
enum ChannelBindingInner {
@@ -103,7 +101,7 @@ enum State {
103
101
channel_binding : ChannelBinding ,
104
102
} ,
105
103
Finish {
106
- salted_password : GenericArray < u8 , U32 > ,
104
+ salted_password : [ u8 ; 32 ] ,
107
105
auth_message : String ,
108
106
} ,
109
107
Done ,
@@ -220,7 +218,7 @@ impl ScramSha256 {
220
218
hmac. input ( auth_message. as_bytes ( ) ) ;
221
219
let client_signature = hmac. result ( ) ;
222
220
223
- let mut client_proof = GenericArray :: < u8 , U32 > :: clone_from_slice ( & client_key) ;
221
+ let mut client_proof = client_key;
224
222
for ( proof, signature) in client_proof. iter_mut ( ) . zip ( client_signature. code ( ) ) {
225
223
* proof ^= signature;
226
224
}
0 commit comments