1use core::fmt;
2
3pub type Result<T> = core::result::Result<T, Error>;
5
6#[derive(Debug)]
8pub enum Error {
9 InvalidDataSize,
11
12 InvalidKekSize {
14 size: usize,
16 },
17
18 InvalidOutputSize {
20 expected: usize,
22 },
23
24 IntegrityCheckFailed,
26}
27
28impl fmt::Display for Error {
29 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
30 match self {
31 Error::InvalidDataSize => write!(f, "data must be a multiple of 64 bits for AES-KW and less than 2^32 bytes for AES-KWP"),
32 Error::InvalidKekSize { size } => {
33 write!(f, "invalid AES KEK size: {}", size)
34 }
35 Error::InvalidOutputSize { expected } => {
36 write!(f, "invalid output buffer size: expected {}", expected)
37 }
38 Error::IntegrityCheckFailed => {
39 write!(f, "integrity check failed")
40 }
41 }
42 }
43}
44
45#[cfg(feature = "std")]
46impl std::error::Error for Error {}