#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum ClientError {
#[error("the sigul server replied with an error: {0}")]
Sigul(#[from] Sigul),
#[error("failed to serialize to or deserialize from sigul: {0}")]
Serde(#[from] crate::serdes::Error),
#[error("the Sigul server signature on its response was invalid")]
InvalidSignature,
#[error("connection error with Sigul bridge or server: {0}")]
Connection(#[from] ConnectionError),
#[error("an I/O error occurred: {0}")]
Io(#[from] std::io::Error),
#[error("openssl could not be configured: {0}")]
Openssl(#[from] openssl::error::ErrorStack),
#[error(transparent)]
Fatal(#[from] anyhow::Error),
}
#[derive(Debug, thiserror::Error)]
#[allow(clippy::exhaustive_enums)]
pub enum Sigul {
#[error("unknown protocol version")]
UnknownVersion,
#[error("unknown operation")]
UnknownOp,
#[error("authentication failed")]
AuthenticationFailed,
#[error("the specified object already exists")]
AlreadyExists,
#[error("the specified user was not found")]
UserNotFound,
#[error("the specified user can access one or more keys")]
UserHasKeyAccess,
#[error("the specified user cannot access this key")]
KeyUserNotFound,
#[error("the specified key was not found")]
KeyNotFound,
#[error("An unknown error occurred")]
UnknownError,
#[error("this is the only user with access to this key")]
OnlyOneKeyUser,
#[error("the RPM file is corrupt")]
CorruptRpm,
#[error("missing RPM file authentication by client")]
UnauthenticatedRpm,
#[error("invalid import file")]
InvalidImport,
#[error("import passphrase does not match")]
ImportPassphraseError,
#[error("decryption failed")]
DecryptFailed,
#[error("unsupported key type for operation")]
UnsupportedKeyType,
#[error("An unexpected error occurred: error code {0}")]
Unexpected(u32),
}
impl From<u32> for Sigul {
fn from(value: u32) -> Self {
match value {
1 => Self::UnknownVersion,
2 => Self::UnknownOp,
3 => Self::AuthenticationFailed,
4 => Self::AlreadyExists,
5 => Self::UserNotFound,
6 => Self::UserHasKeyAccess,
7 => Self::KeyUserNotFound,
8 => Self::KeyNotFound,
9 => Self::UnknownError,
10 => Self::OnlyOneKeyUser,
11 => Self::CorruptRpm,
12 => Self::UnauthenticatedRpm,
13 => Self::InvalidImport,
14 => Self::ImportPassphraseError,
15 => Self::DecryptFailed,
16 => Self::UnsupportedKeyType,
other => Self::Unexpected(other),
}
}
}
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum ConnectionError {
#[error("an I/O error occurred: {0}")]
Io(#[from] std::io::Error),
#[error("one or more openssl errors occurred: {0}")]
SslErrors(#[from] openssl::error::ErrorStack),
#[error("an SSL error occurred: {0}")]
Ssl(#[from] openssl::ssl::Error),
#[error("a Sigul protocol violation occurred: {0}")]
ProtocolViolation(String),
}