Skip to content

Commit 56fb0d0

Browse files
authored
Merge pull request sfackler#981 from sfackler/dependabot/cargo/base64-0.21
Update base64 requirement from 0.20 to 0.21
2 parents c359026 + 10bf271 commit 56fb0d0

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

Diff for: postgres-protocol/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ repository = "https://github.com/sfackler/rust-postgres"
99
readme = "../README.md"
1010

1111
[dependencies]
12-
base64 = "0.20"
12+
base64 = "0.21"
1313
byteorder = "1.0"
1414
bytes = "1.0"
1515
fallible-iterator = "0.2"

Diff for: postgres-protocol/src/authentication/sasl.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
//! SASL-based authentication support.
22
3+
use base64::display::Base64Display;
4+
use base64::engine::general_purpose::STANDARD;
5+
use base64::Engine;
36
use hmac::{Hmac, Mac};
47
use rand::{self, Rng};
58
use sha2::digest::FixedOutput;
@@ -189,7 +192,7 @@ impl ScramSha256 {
189192
return Err(io::Error::new(io::ErrorKind::InvalidInput, "invalid nonce"));
190193
}
191194

192-
let salt = match base64::decode(parsed.salt) {
195+
let salt = match STANDARD.decode(parsed.salt) {
193196
Ok(salt) => salt,
194197
Err(e) => return Err(io::Error::new(io::ErrorKind::InvalidInput, e)),
195198
};
@@ -208,7 +211,7 @@ impl ScramSha256 {
208211
let mut cbind_input = vec![];
209212
cbind_input.extend(channel_binding.gs2_header().as_bytes());
210213
cbind_input.extend(channel_binding.cbind_data());
211-
let cbind_input = base64::encode(&cbind_input);
214+
let cbind_input = STANDARD.encode(&cbind_input);
212215

213216
self.message.clear();
214217
write!(&mut self.message, "c={},r={}", cbind_input, parsed.nonce).unwrap();
@@ -225,7 +228,12 @@ impl ScramSha256 {
225228
*proof ^= signature;
226229
}
227230

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();
229237

230238
self.state = State::Finish {
231239
salted_password,
@@ -262,7 +270,7 @@ impl ScramSha256 {
262270
ServerFinalMessage::Verifier(verifier) => verifier,
263271
};
264272

265-
let verifier = match base64::decode(verifier) {
273+
let verifier = match STANDARD.decode(verifier) {
266274
Ok(verifier) => verifier,
267275
Err(e) => return Err(io::Error::new(io::ErrorKind::InvalidInput, e)),
268276
};

Diff for: postgres-protocol/src/password/mod.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
//! end up in logs pg_stat displays, etc.
88
99
use crate::authentication::sasl;
10+
use base64::display::Base64Display;
11+
use base64::engine::general_purpose::STANDARD;
1012
use hmac::{Hmac, Mac};
1113
use md5::Md5;
1214
use rand::RngCore;
@@ -80,9 +82,9 @@ pub(crate) fn scram_sha_256_salt(password: &[u8], salt: [u8; SCRAM_DEFAULT_SALT_
8082
format!(
8183
"SCRAM-SHA-256${}:{}${}:{}",
8284
SCRAM_DEFAULT_ITERATIONS,
83-
base64::encode(salt),
84-
base64::encode(stored_key),
85-
base64::encode(server_key)
85+
Base64Display::new(&salt, &STANDARD),
86+
Base64Display::new(&stored_key, &STANDARD),
87+
Base64Display::new(&server_key, &STANDARD)
8688
)
8789
}
8890

0 commit comments

Comments
 (0)