From 93a0b721056af60f702006edea6be290d67b4799 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 1 Mar 2023 11:34:49 -0500 Subject: [PATCH] tor-cell: Use a match when checking auth_key_type --- crates/tor-cell/src/relaycell/hs/est_intro.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/tor-cell/src/relaycell/hs/est_intro.rs b/crates/tor-cell/src/relaycell/hs/est_intro.rs index 0207eaa18..028a4693c 100644 --- a/crates/tor-cell/src/relaycell/hs/est_intro.rs +++ b/crates/tor-cell/src/relaycell/hs/est_intro.rs @@ -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();