tor-proto: When relay IDs mismatch, the IDs are sensitive in errors

This commit is contained in:
Ian Jackson 2022-12-12 13:35:49 +00:00
parent b525fccfb0
commit 8c925499f8
4 changed files with 9 additions and 3 deletions

1
Cargo.lock generated
View File

@ -4051,6 +4051,7 @@ dependencies = [
"rand 0.8.5",
"rand_core 0.6.4",
"regex",
"safelog",
"statrs",
"subtle",
"thiserror",

View File

@ -38,6 +38,7 @@ hmac = "0.12.0"
pin-project = "1"
rand = "0.8"
rand_core = "0.6.2"
safelog = { path = "../safelog", version = "0.2.0" }
subtle = "2"
thiserror = "1"
tokio-crate = { package = "tokio", version = "1.7", optional = true }

View File

@ -71,6 +71,7 @@ use crate::util::err::ChannelClosed;
use crate::util::ts::OptTimestamp;
use crate::{circuit, ClockSkew};
use crate::{Error, Result};
use safelog::sv;
use std::pin::Pin;
use std::sync::{Mutex, MutexGuard};
use std::time::Duration;
@ -650,7 +651,8 @@ where
Some(actual) => {
return Err(Error::ChanMismatch(format!(
"Identity {} does not match target {}",
actual, desired
sv(actual),
sv(desired)
)));
}
None => {

View File

@ -958,7 +958,8 @@ pub(super) mod test {
.unwrap();
let re = Regex::new(
r"Identity .* does not match target ed25519:EBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBA",
// identities might be scrubbed by safelog
r"Identity .* does not match target .*",
).unwrap();
assert!(re.is_match(&format!("{}", err)));
@ -974,7 +975,8 @@ pub(super) mod test {
.unwrap();
let re = Regex::new(
r"Identity .* does not match target \$9999999999999999999999999999999999999999",
// identities might be scrubbed by safelog
r"Identity .* does not match target .*",
)
.unwrap();
assert!(re.is_match(&format!("{}", err)));