1use core::fmt;
2
3#[derive(Copy, Clone, Hash, Debug, PartialEq, Eq)]
5pub enum Error {
6 InvalidDataSize,
8
9 InvalidOutputSize {
11 expected_len: usize,
13 },
14
15 IntegrityCheckFailed,
17}
18
19impl fmt::Display for Error {
20 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
21 match self {
22 Error::InvalidDataSize => f.write_str("data must be a multiple of 64 bits for AES-KW and less than 2^32 bytes for AES-KWP"),
23 Error::InvalidOutputSize { expected_len: expected } => {
24 write!(f, "invalid output buffer size: expected {}", expected)
25 }
26 Error::IntegrityCheckFailed => f.write_str("integrity check failed"),
27 }
28 }
29}
30
31impl core::error::Error for Error {}
32
33#[derive(Clone, Copy, Debug)]
35pub struct IntegrityCheckFailed;
36
37impl fmt::Display for IntegrityCheckFailed {
38 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
39 f.write_str("integrity check failed")
40 }
41}
42
43impl core::error::Error for IntegrityCheckFailed {}