2
2
// https://github.com/sfackler/rust-postgres/
3
3
// SASL implementation.
4
4
5
+ use base64:: { engine:: general_purpose, Engine as _} ;
5
6
use bytes:: BytesMut ;
6
7
use hmac:: { Hmac , Mac } ;
7
8
use rand:: { self , Rng } ;
@@ -81,7 +82,7 @@ impl ScramSha256 {
81
82
return Err ( Error :: ProtocolSyncError ( format ! ( "SCRAM" ) ) ) ;
82
83
}
83
84
84
- let salt = match base64 :: decode ( & server_message. salt ) {
85
+ let salt = match general_purpose :: STANDARD . decode ( & server_message. salt ) {
85
86
Ok ( salt) => salt,
86
87
Err ( _) => return Err ( Error :: ProtocolSyncError ( format ! ( "SCRAM" ) ) ) ,
87
88
} ;
@@ -111,7 +112,7 @@ impl ScramSha256 {
111
112
let mut cbind_input = vec ! [ ] ;
112
113
cbind_input. extend ( "n,," . as_bytes ( ) ) ;
113
114
114
- let cbind_input = base64 :: encode ( & cbind_input) ;
115
+ let cbind_input = general_purpose :: STANDARD . encode ( & cbind_input) ;
115
116
116
117
self . message . clear ( ) ;
117
118
@@ -149,7 +150,11 @@ impl ScramSha256 {
149
150
* proof ^= signature;
150
151
}
151
152
152
- match write ! ( & mut self . message, ",p={}" , base64:: encode( & * client_proof) ) {
153
+ match write ! (
154
+ & mut self . message,
155
+ ",p={}" ,
156
+ general_purpose:: STANDARD . encode( & * client_proof)
157
+ ) {
153
158
Ok ( _) => ( ) ,
154
159
Err ( _) => return Err ( Error :: ServerError ) ,
155
160
} ;
@@ -161,7 +166,7 @@ impl ScramSha256 {
161
166
pub fn finish ( & mut self , message : & BytesMut ) -> Result < ( ) , Error > {
162
167
let final_message = FinalMessage :: parse ( message) ?;
163
168
164
- let verifier = match base64 :: decode ( & final_message. value ) {
169
+ let verifier = match general_purpose :: STANDARD . decode ( & final_message. value ) {
165
170
Ok ( verifier) => verifier,
166
171
Err ( _) => return Err ( Error :: ProtocolSyncError ( format ! ( "SCRAM" ) ) ) ,
167
172
} ;
0 commit comments