Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
crypto: mark errors as `non_exhaustive`
Fintan Halpenny committed 7 months ago
commit 02b90c77c92ff61f1f3c84a8c6fac51e7e0e28c2
parent ee041d8d063dbb36722c4beb6a20e4a6dd36df28
3 files changed +9 -0
modified crates/radicle-crypto/src/lib.rs
@@ -28,6 +28,7 @@ pub type SharedSecret = [u8; 32];
/// Error returned if signing fails, eg. due to an HSM or KMS.
#[derive(Debug, Clone, Error)]
#[error(transparent)]
+
#[non_exhaustive]
pub struct SignerError {
    #[from]
    source: Arc<dyn std::error::Error + Send + Sync>,
@@ -93,6 +94,7 @@ impl fmt::Debug for Signature {
}

#[derive(Error, Debug)]
+
#[non_exhaustive]
pub enum SignatureError {
    #[error("invalid multibase string: {0}")]
    Multibase(#[from] multibase::Error),
@@ -273,6 +275,7 @@ impl Deref for SecretKey {
}

#[derive(Error, Debug)]
+
#[non_exhaustive]
pub enum PublicKeyError {
    #[error("invalid length {0}")]
    InvalidLength(usize),
modified crates/radicle-crypto/src/ssh.rs
@@ -16,6 +16,7 @@ use crate::PublicKey;
pub use keystore::{Keystore, Passphrase};

#[derive(Debug, Error)]
+
#[non_exhaustive]
pub enum ExtendedSignatureError {
    #[error(transparent)]
    Ssh(#[from] ssh_key::Error),
@@ -128,6 +129,7 @@ pub mod fmt {
}

#[derive(Debug, Error)]
+
#[non_exhaustive]
pub enum SignatureError {
    #[error(transparent)]
    Invalid(#[from] crypto::Error),
@@ -164,6 +166,7 @@ impl Encodable for crypto::Signature {
}

#[derive(Debug, Error)]
+
#[non_exhaustive]
pub enum PublicKeyError {
    #[error(transparent)]
    Invalid(#[from] crypto::Error),
@@ -199,6 +202,7 @@ impl Encodable for PublicKey {
}

#[derive(Debug, Error)]
+
#[non_exhaustive]
pub enum SecretKeyError {
    #[error(transparent)]
    Encoding(#[from] encoding::Error),
modified crates/radicle-crypto/src/ssh/keystore.rs
@@ -15,6 +15,7 @@ use super::ExtendedSignature;
pub type Passphrase = Zeroizing<String>;

#[derive(Debug, Error)]
+
#[non_exhaustive]
pub enum Error {
    #[error(transparent)]
    Io(#[from] io::Error),
@@ -227,6 +228,7 @@ impl Keystore {
}

#[derive(Debug, Error)]
+
#[non_exhaustive]
pub enum MemorySignerError {
    #[error(transparent)]
    Keystore(#[from] Error),