chromium_crypto/
error.rs

1#[derive(Debug)]
2#[derive(thiserror::Error)]
3#[non_exhaustive]
4#[cfg(target_os = "linux")]
5pub enum CryptoError {
6    #[error(transparent)]
7    GetPass(#[from] secret_service::Error),
8    #[error("Not exists: {0}")]
9    NoPass(String),
10    #[error("Crypt unpad error: {0}")]
11    Unpadding(aes::cipher::block_padding::UnpadError),
12}
13
14#[derive(Debug)]
15#[derive(thiserror::Error)]
16#[non_exhaustive]
17#[cfg(target_os = "macos")]
18pub enum CryptoError {
19    #[error(transparent)]
20    Keyring(#[from] keyring::Error),
21    #[error("Crypt unpad error: {0}")]
22    Unpadding(aes::cipher::block_padding::UnpadError),
23    #[error(transparent)]
24    Task(#[from] tokio::task::JoinError),
25}
26
27#[derive(Debug)]
28#[derive(thiserror::Error)]
29#[non_exhaustive]
30#[cfg(target_os = "windows")]
31pub enum CryptoError {
32    #[error("{source}, path: {path}")]
33    IO {
34        path: std::path::PathBuf,
35        #[source]
36        source: std::io::Error,
37    },
38    #[error(transparent)]
39    Serde(#[from] serde_json::Error),
40    #[error(transparent)]
41    Base64(#[from] base64::DecodeError),
42    #[error(transparent)]
43    Task(#[from] tokio::task::JoinError),
44    #[error("{0}")]
45    AesGcm(aes_gcm::Error),
46    #[error(transparent)]
47    CryptUnprotectData(#[from] windows::core::Error),
48    #[error("CryptUnprotectData returned a null pointer")]
49    CryptUnprotectDataNull,
50    #[error("{0}")]
51    ChaCha(chacha20poly1305::Error),
52    #[error("{0}")]
53    Context(winnow::error::ContextError),
54    #[error(r#"app_bound_encrypted_key not start with "APPB""#)]
55    APPB,
56    #[error("Get process path failed")]
57    ProcessPath,
58    #[error("Invalid status from RtlAdjustPrivilege")]
59    Privilege,
60    #[error("No such Process lsass.exe or winlogon.exe")]
61    NotFoundProcess,
62}
63
64pub type Result<T> = std::result::Result<T, CryptoError>;