|
20 | 20 | //! and revoked markers. See "FIXME" comments littered in this file. |
21 | 21 |
|
22 | 22 | use crate::util::config::{Config, Definition, Value}; |
| 23 | +use base64::engine::general_purpose::STANDARD; |
| 24 | +use base64::engine::general_purpose::STANDARD_NO_PAD; |
| 25 | +use base64::Engine as _; |
23 | 26 | use git2::cert::{Cert, SshHostKeyType}; |
24 | 27 | use git2::CertificateCheckStatus; |
25 | 28 | use hmac::Mac; |
@@ -344,7 +347,7 @@ fn check_ssh_known_hosts( |
344 | 347 | .collect(); |
345 | 348 | for (patterns, key_type, key) in BUNDLED_KEYS { |
346 | 349 | if !configured_hosts.contains(*patterns) { |
347 | | - let key = base64::decode(key).unwrap(); |
| 350 | + let key = STANDARD.decode(key).unwrap(); |
348 | 351 | known_hosts.push(KnownHost { |
349 | 352 | location: KnownHostLocation::Bundled, |
350 | 353 | patterns: patterns.to_string(), |
@@ -382,9 +385,8 @@ fn check_ssh_known_hosts_loaded( |
382 | 385 | // support SHA256. |
383 | 386 | let mut remote_fingerprint = cargo_util::Sha256::new(); |
384 | 387 | remote_fingerprint.update(remote_host_key.clone()); |
385 | | - let remote_fingerprint = |
386 | | - base64::encode_config(remote_fingerprint.finish(), base64::STANDARD_NO_PAD); |
387 | | - let remote_host_key_encoded = base64::encode(remote_host_key); |
| 388 | + let remote_fingerprint = STANDARD_NO_PAD.encode(remote_fingerprint.finish()); |
| 389 | + let remote_host_key_encoded = STANDARD.encode(remote_host_key); |
388 | 390 |
|
389 | 391 | for known_host in known_hosts { |
390 | 392 | // The key type from libgit2 needs to match the key type from the host file. |
@@ -583,8 +585,8 @@ impl KnownHost { |
583 | 585 |
|
584 | 586 | fn hashed_hostname_matches(host: &str, hashed: &str) -> bool { |
585 | 587 | let Some((b64_salt, b64_host)) = hashed.split_once('|') else { return false; }; |
586 | | - let Ok(salt) = base64::decode(b64_salt) else { return false; }; |
587 | | - let Ok(hashed_host) = base64::decode(b64_host) else { return false; }; |
| 588 | + let Ok(salt) = STANDARD.decode(b64_salt) else { return false; }; |
| 589 | + let Ok(hashed_host) = STANDARD.decode(b64_host) else { return false; }; |
588 | 590 | let Ok(mut mac) = hmac::Hmac::<sha1::Sha1>::new_from_slice(&salt) else { return false; }; |
589 | 591 | mac.update(host.as_bytes()); |
590 | 592 | let result = mac.finalize().into_bytes(); |
@@ -636,7 +638,7 @@ fn parse_known_hosts_line(line: &str, location: KnownHostLocation) -> Option<Kno |
636 | 638 |
|
637 | 639 | let patterns = parts.next()?; |
638 | 640 | let key_type = parts.next()?; |
639 | | - let key = parts.next().map(base64::decode)?.ok()?; |
| 641 | + let key = parts.next().map(|p| STANDARD.decode(p))?.ok()?; |
640 | 642 | Some(KnownHost { |
641 | 643 | line_type, |
642 | 644 | location, |
|
0 commit comments