Skip to content

Commit

Permalink
ssh-key: return encoding::Error::Length from Sk* constructors (#204)
Browse files Browse the repository at this point in the history
Uses an existing error type for these constructors, rather than adding a
new one.
  • Loading branch information
tarcieri authored Mar 10, 2024
1 parent 4d52699 commit 5cda911
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
7 changes: 0 additions & 7 deletions ssh-key/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,6 @@ pub enum Error {
/// Version number.
number: u32,
},

/// Byte array is longer than allowed.
TooLong {
/// Bad length that did not pass validation check.
bad_len: usize,
},
}

impl fmt::Display for Error {
Expand Down Expand Up @@ -117,7 +111,6 @@ impl fmt::Display for Error {
"unexpected trailing data at end of message ({remaining} bytes)",
),
Error::Version { number: version } => write!(f, "version unsupported: {version}"),
Error::TooLong { bad_len } => write!(f, "too long byte array: {bad_len}"),
}
}
}
Expand Down
8 changes: 2 additions & 6 deletions ssh-key/src/private/sk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ impl SkEcdsaSha2NistP256 {
reserved: Vec::<u8>::new(),
})
} else {
Err(Error::TooLong {
bad_len: key_handle.len(),
})
Err(encoding::Error::Length.into())
}
}

Expand Down Expand Up @@ -136,9 +134,7 @@ impl SkEd25519 {
reserved: Vec::<u8>::new(),
})
} else {
Err(Error::TooLong {
bad_len: key_handle.len(),
})
Err(encoding::Error::Length.into())
}
}

Expand Down

0 comments on commit 5cda911

Please sign in to comment.