1use thiserror::Error;
2
3use crate::Fingerprint;
4use crate::message::MessageDesc;
5
6#[non_exhaustive]
11#[derive(Error, Debug)]
12pub enum CryptoError {
13 #[error("Base64 decoding error.")]
15 DecodingError(#[from] base64::DecodeError),
16 #[error("Memory error. The available memory is insufficient or corrupted.")]
18 InsufficientMemory,
19 #[error("Certificate {0} is not a recipient of the message.")]
21 NotARecipient(Fingerprint),
22 #[error("The message is not decrypted, cannot verify the signature.")]
24 NotDecrypted,
25 #[error("The certificate does not contain secret keys.")]
27 NotSecret,
28 #[error("The message is not {0}")]
30 NotType(MessageDesc),
31 #[error("Serialization error.")]
33 SerializationError(#[from] postcard::Error),
34 #[error("Unauthentic cipher. AAD is not authentic, the message had been tampered with.")]
36 UnauthenticCipher,
37 #[error("Unknown error. Something wierd had to happen for this one.")]
39 Unknown,
40}
41
42pub type Result<T> = std::result::Result<T, CryptoError>;