Skip to main content

asjeeves_encryption/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum Error {
5    #[error("an unexpected decryption error, {source}")]
6    AesDecryptionError { source: aes_gcm::Error },
7    #[error("an unexpected decryption error, {source}")]
8    DecryptionError { source: rsa::Error },
9    #[error("an unexpected encryption error, {source}")]
10    AesEncryptionError { source: aes_gcm::Error },
11    #[error("an unexpected encryption error, {source}")]
12    EncryptionError { source: rsa::Error },
13    #[error("invalid key format, {source}")]
14    InvalidKeyFormat {
15        #[from]
16        source: rsa::pkcs8::Error,
17    },
18    #[error("invalid signature, {source}")]
19    InvalidSignature {
20        #[from]
21        source: rsa::signature::Error,
22    },
23    #[error("unable to serialize jwk, {source}")]
24    JwkSerializationError {
25        #[from]
26        source: serde_json::Error,
27    },
28    #[error("unable to serialize token, {source}")]
29    JwtSerializationError {
30        source: json_web_tolkien::error::Error,
31    },
32    #[error("unable to generate key, {source}")]
33    KeyGenError { source: rsa::Error },
34    #[error("unsupported algorithm")]
35    UnsupportedAlgorithm,
36}