tor-cell: Use a match when checking auth_key_type

This commit is contained in:
Nick Mathewson 2023-03-01 11:34:49 -05:00
parent dbecdb53aa
commit 93a0b72105
1 changed files with 8 additions and 6 deletions

View File

@ -203,12 +203,14 @@ impl msg::Body for EstablishIntro {
let auth_key_type: AuthKeyType = r.take_u8()?.into();
// Only Ed25519 is recognized... and it *needs* to be recognized or else we
// can't verify the signature.
if auth_key_type != AuthKeyType::ED25519_SHA3_256 {
return Err(tor_bytes::Error::InvalidMessage(
format!("unrecognized authkey type {:?}", auth_key_type).into(),
));
}
let auth_key = r.read_nested_u16len(|r| r.extract())?;
let auth_key = match auth_key_type {
AuthKeyType::ED25519_SHA3_256 => r.read_nested_u16len(|r| r.extract())?,
_ => {
return Err(tor_bytes::Error::InvalidMessage(
format!("unrecognized authkey type {:?}", auth_key_type).into(),
))
}
};
let extensions = r.extract()?;
let cursor_mac = r.cursor();