#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum KeyWrapAlgorithm {
Aes128Kw,
Aes192Kw,
Aes256Kw,
}
impl core::fmt::Display for KeyWrapAlgorithm {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let detail = match self {
KeyWrapAlgorithm::Aes128Kw => "AES-128-KW",
KeyWrapAlgorithm::Aes192Kw => "AES-192-KW",
KeyWrapAlgorithm::Aes256Kw => "AES-256-KW",
};
write!(f, "{detail}")
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum KeyWrapOperation {
Wrap,
Unwrap,
}
impl core::fmt::Display for KeyWrapOperation {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let op = match self {
KeyWrapOperation::Wrap => "wrap",
KeyWrapOperation::Unwrap => "unwrap",
};
write!(f, "{op}")
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum KeyWrapFailureKind {
InvalidKekLength,
InvalidPlaintextLength,
InvalidWrappedLength,
LengthOverflow,
IntegrityCheckFailed,
BackendFailure,
}
impl core::fmt::Display for KeyWrapFailureKind {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let detail = match self {
KeyWrapFailureKind::InvalidKekLength => "invalid key-encryption key length",
KeyWrapFailureKind::InvalidPlaintextLength => "invalid plaintext key length",
KeyWrapFailureKind::InvalidWrappedLength => "invalid wrapped key length",
KeyWrapFailureKind::LengthOverflow => "length overflow",
KeyWrapFailureKind::IntegrityCheckFailed => "integrity check failed",
KeyWrapFailureKind::BackendFailure => "backend failure",
};
write!(f, "{detail}")
}
}