crypto_core/error/
key_wrap.rs1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7#[non_exhaustive]
8pub enum KeyWrapAlgorithm {
9 Aes128Kw,
11 Aes192Kw,
13 Aes256Kw,
15}
16
17impl core::fmt::Display for KeyWrapAlgorithm {
18 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
19 let detail = match self {
20 KeyWrapAlgorithm::Aes128Kw => "AES-128-KW",
21 KeyWrapAlgorithm::Aes192Kw => "AES-192-KW",
22 KeyWrapAlgorithm::Aes256Kw => "AES-256-KW",
23 };
24 write!(f, "{detail}")
25 }
26}
27
28#[derive(Debug, Clone, Copy, PartialEq, Eq)]
30#[non_exhaustive]
31pub enum KeyWrapOperation {
32 Wrap,
34 Unwrap,
36}
37
38impl core::fmt::Display for KeyWrapOperation {
39 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
40 let op = match self {
41 KeyWrapOperation::Wrap => "wrap",
42 KeyWrapOperation::Unwrap => "unwrap",
43 };
44 write!(f, "{op}")
45 }
46}
47
48#[derive(Debug, Clone, Copy, PartialEq, Eq)]
50#[non_exhaustive]
51pub enum KeyWrapFailureKind {
52 InvalidKekLength,
54 InvalidPlaintextLength,
56 InvalidWrappedLength,
58 LengthOverflow,
60 IntegrityCheckFailed,
62 BackendFailure,
64}
65
66impl core::fmt::Display for KeyWrapFailureKind {
67 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
68 let detail = match self {
69 KeyWrapFailureKind::InvalidKekLength => "invalid key-encryption key length",
70 KeyWrapFailureKind::InvalidPlaintextLength => "invalid plaintext key length",
71 KeyWrapFailureKind::InvalidWrappedLength => "invalid wrapped key length",
72 KeyWrapFailureKind::LengthOverflow => "length overflow",
73 KeyWrapFailureKind::IntegrityCheckFailed => "integrity check failed",
74 KeyWrapFailureKind::BackendFailure => "backend failure",
75 };
76 write!(f, "{detail}")
77 }
78}