Skip to content

Commit

Permalink
Include source of decoding error
Browse files Browse the repository at this point in the history
This should make for better error messages when support for certain
keys is disabled.

Fixes #2971.
  • Loading branch information
thomaseizinger committed Oct 3, 2022
1 parent e1c80e3 commit 3c15f9f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions transports/noise/src/io/handshake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,7 @@ where
let pb = pb_result?;

if !pb.identity_key.is_empty() {
let pk = identity::PublicKey::from_protobuf_encoding(&pb.identity_key)
.map_err(|_| NoiseError::InvalidKey)?;
let pk = identity::PublicKey::from_protobuf_encoding(&pb.identity_key)?;
if let Some(ref k) = state.id_remote_pubkey {
if k != &pk {
return Err(NoiseError::UnexpectedKey);
Expand Down
2 changes: 1 addition & 1 deletion transports/noise/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ pub enum NoiseError {
#[error(transparent)]
Noise(#[from] snow::Error),
#[error("Invalid public key")]
InvalidKey,
InvalidKey(#[from] identity::error::DecodingError),
#[error("Only keys of length 32 bytes are supported")]
InvalidLength,
#[error("Remote authenticated with an unexpected public key")]
Expand Down

0 comments on commit 3c15f9f

Please sign in to comment.