Skip to main content

nectar_primitives/chunk/encryption/
error.rs

1//! Encryption error types.
2
3use thiserror::Error;
4
5/// Errors from encryption operations.
6#[derive(Debug, Error)]
7pub enum EncryptionError {
8    /// Input data is shorter than the required minimum.
9    #[error("data too short: {len} bytes, minimum {min}")]
10    DataTooShort {
11        /// Actual length.
12        len: usize,
13        /// Minimum required length.
14        min: usize,
15    },
16
17    /// Input data exceeds the maximum allowed length.
18    #[error("data too long: {len} bytes, maximum {max}")]
19    DataTooLong {
20        /// Actual length.
21        len: usize,
22        /// Maximum allowed length.
23        max: usize,
24    },
25
26    /// Reference byte slice is not 32 or 64 bytes.
27    #[error("invalid reference length: {len} bytes (expected 32 or 64)")]
28    InvalidReferenceLength {
29        /// Actual length.
30        len: usize,
31    },
32
33    /// Key byte slice is not 32 bytes.
34    #[error("invalid key length: {len} bytes (expected 32)")]
35    InvalidKeyLength {
36        /// Actual length.
37        len: usize,
38    },
39
40    /// Output buffer is too small for decryption.
41    #[error("output buffer too small: {len} bytes, need {required}")]
42    OutputBufferTooSmall {
43        /// Actual buffer length.
44        len: usize,
45        /// Required buffer length.
46        required: usize,
47    },
48}