#[non_exhaustive]pub enum Error {
InvalidKey {
expected: usize,
actual: usize,
},
InvalidCiphertext(String),
AuthenticationFailed,
AlgorithmNotEnabled(&'static str),
RandomFailure(&'static str),
}Expand description
The error type for all crypt-io operations.
Authentication failures are deliberately collapsed into a single variant — distinguishing “wrong key” from “tampered ciphertext” would leak which failure mode an attacker is closer to, which is a side-channel.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
InvalidKey
The supplied key was not the correct size for the selected algorithm (ChaCha20-Poly1305 and AES-256-GCM both require exactly 32 bytes).
InvalidCiphertext(String)
The ciphertext was malformed (too short to contain a nonce + tag, or the embedded length fields were inconsistent).
AuthenticationFailed
Authentication of the ciphertext failed. This is the single observable outcome of any corruption: wrong key, tampered bytes, truncated message, or wrong associated data. The variant is opaque by design.
AlgorithmNotEnabled(&'static str)
The requested algorithm is not enabled at compile time. Re-build with the appropriate Cargo feature.
RandomFailure(&'static str)
The OS random source failed to produce a nonce. This is rare and
almost always indicates a misconfigured sandbox or exhausted
getrandom entropy on a freshly-booted VM.
Trait Implementations§
Source§impl Error for Error
Available on crate feature std only.
impl Error for Error
std only.1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()