Skip to main content

veracrypt/
error.rs

1//! Error type for VeraCrypt parsing and unlocking.
2
3use std::io;
4
5/// Result alias for `veracrypt-core`.
6pub type Result<T> = std::result::Result<T, VeraError>;
7
8/// A VeraCrypt parse or unlock failure.
9#[derive(Debug, thiserror::Error)]
10#[non_exhaustive]
11pub enum VeraError {
12    /// No PRF/cipher combination decrypted the header to a valid `VERA` signature
13    /// with matching CRCs — a wrong password, an unsupported cipher/PRF, or not a
14    /// VeraCrypt volume.
15    #[error("authentication failed: no PRF/cipher decrypted a valid VeraCrypt header (wrong password or unsupported cipher)")]
16    AuthenticationFailed,
17
18    /// The container is too small to hold a VeraCrypt header.
19    #[error("too small for a VeraCrypt header: {got} bytes (need at least 512)")]
20    TooSmall {
21        /// Bytes available.
22        got: usize,
23    },
24
25    /// A cryptographic precondition failed.
26    #[error("crypto error: {what}")]
27    Crypto {
28        /// What failed.
29        what: &'static str,
30    },
31
32    /// An I/O error reading the container.
33    #[error("I/O error: {0}")]
34    Io(#[from] io::Error),
35}