| 1 | use core::fmt; |
| 2 | |
| 3 | /// Error type for signaling failed MAC verification |
| 4 | #[derive(Default, Debug, Copy, Clone, Eq, PartialEq)] |
| 5 | pub struct MacError; |
| 6 | |
| 7 | /// Error type for signaling invalid key length for MAC initialization |
| 8 | #[derive(Default, Debug, Copy, Clone, Eq, PartialEq)] |
| 9 | pub struct InvalidKeyLength; |
| 10 | |
| 11 | impl fmt::Display for MacError { |
| 12 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 13 | f.write_str("failed MAC verification") |
| 14 | } |
| 15 | } |
| 16 | |
| 17 | impl fmt::Display for InvalidKeyLength { |
| 18 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 19 | f.write_str("invalid key length") |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | #[cfg(feature = "std")] |
| 24 | impl std::error::Error for MacError {} |
| 25 | |
| 26 | #[cfg(feature = "std")] |
| 27 | impl std::error::Error for InvalidKeyLength {} |