1
1
//! SASL-based authentication support.
2
2
3
+ use base64:: display:: Base64Display ;
4
+ use base64:: engine:: general_purpose:: STANDARD ;
5
+ use base64:: Engine ;
3
6
use hmac:: { Hmac , Mac } ;
4
7
use rand:: { self , Rng } ;
5
8
use sha2:: digest:: FixedOutput ;
@@ -189,7 +192,7 @@ impl ScramSha256 {
189
192
return Err ( io:: Error :: new ( io:: ErrorKind :: InvalidInput , "invalid nonce" ) ) ;
190
193
}
191
194
192
- let salt = match base64 :: decode ( parsed. salt ) {
195
+ let salt = match STANDARD . decode ( parsed. salt ) {
193
196
Ok ( salt) => salt,
194
197
Err ( e) => return Err ( io:: Error :: new ( io:: ErrorKind :: InvalidInput , e) ) ,
195
198
} ;
@@ -208,7 +211,7 @@ impl ScramSha256 {
208
211
let mut cbind_input = vec ! [ ] ;
209
212
cbind_input. extend ( channel_binding. gs2_header ( ) . as_bytes ( ) ) ;
210
213
cbind_input. extend ( channel_binding. cbind_data ( ) ) ;
211
- let cbind_input = base64 :: encode ( & cbind_input) ;
214
+ let cbind_input = STANDARD . encode ( & cbind_input) ;
212
215
213
216
self . message . clear ( ) ;
214
217
write ! ( & mut self . message, "c={},r={}" , cbind_input, parsed. nonce) . unwrap ( ) ;
@@ -225,7 +228,12 @@ impl ScramSha256 {
225
228
* proof ^= signature;
226
229
}
227
230
228
- write ! ( & mut self . message, ",p={}" , base64:: encode( & * client_proof) ) . unwrap ( ) ;
231
+ write ! (
232
+ & mut self . message,
233
+ ",p={}" ,
234
+ Base64Display :: new( & client_proof, & STANDARD )
235
+ )
236
+ . unwrap ( ) ;
229
237
230
238
self . state = State :: Finish {
231
239
salted_password,
@@ -262,7 +270,7 @@ impl ScramSha256 {
262
270
ServerFinalMessage :: Verifier ( verifier) => verifier,
263
271
} ;
264
272
265
- let verifier = match base64 :: decode ( verifier) {
273
+ let verifier = match STANDARD . decode ( verifier) {
266
274
Ok ( verifier) => verifier,
267
275
Err ( e) => return Err ( io:: Error :: new ( io:: ErrorKind :: InvalidInput , e) ) ,
268
276
} ;
0 commit comments