Skip to main content

dpapi_core/
error.rs

1//! Error type shared across the DPAPI blob parser, decryptor, and Chrome cookie
2//! unwrapper.
3
4#[derive(Debug, thiserror::Error)]
5pub enum DpapiError {
6    #[error("data too short: need at least {needed} bytes, got {got}")]
7    TooShort { needed: usize, got: usize },
8    #[error("unsupported version: {0}")]
9    UnsupportedVersion(u32),
10    #[error("not a DPAPI blob: provider GUID {0} != the DPAPI provider")]
11    NotDpapiProvider(String),
12    #[error("unsupported algorithm ID: {0:#010x}")]
13    UnsupportedAlgId(u32),
14    #[error("invalid key or IV length")]
15    InvalidKeyLength,
16    #[error("decryption failed")]
17    DecryptionFailed,
18    #[error("HMAC verification failed")]
19    HmacMismatch,
20    #[error("UTF-16 decode error")]
21    Utf16Error,
22    #[error("domain RSA backup-key path is not implemented")]
23    DomainBackupUnsupported,
24    #[error("base64 decode error in Local State encrypted_key")]
25    Base64Error,
26    #[error("Local State encrypted_key missing the 5-byte 'DPAPI' prefix (first bytes: {0})")]
27    MissingDpapiPrefix(String),
28    #[error("recovered cookie key has unexpected length: expected {expected} bytes, got {got}")]
29    UnexpectedKeyLength { expected: usize, got: usize },
30    #[error("invalid hex in WLAN keyMaterial: {0}")]
31    InvalidHex(String),
32}