#[derive(Default, Debug, Clone, Copy, PartialEq)]
pub enum ProtectionProfile {
#[default]
NullCipherHmacSha180,
Aes128CmHmacSha180,
Aes128CmHmacSha132,
Aes128CmNullAuth,
Aes192CmHmacSha180,
Aes192CmHmacSha132,
Aes192CmNullAuth,
Aes256CmHmacSha180,
Aes256CmHmacSha132,
Aes256CmNullAuth,
AeadAes128Gcm,
AeadAes256Gcm,
}
impl ProtectionProfile {
pub fn tag_len(&self) -> usize {
match self {
ProtectionProfile::NullCipherHmacSha180
| ProtectionProfile::Aes128CmHmacSha180
| ProtectionProfile::Aes192CmHmacSha180
| ProtectionProfile::Aes256CmHmacSha180 => 10,
ProtectionProfile::Aes128CmHmacSha132
| ProtectionProfile::Aes192CmHmacSha132
| ProtectionProfile::Aes256CmHmacSha132 => 4,
ProtectionProfile::Aes128CmNullAuth
| ProtectionProfile::Aes192CmNullAuth
| ProtectionProfile::Aes256CmNullAuth => 0,
ProtectionProfile::AeadAes128Gcm | ProtectionProfile::AeadAes256Gcm => 0,
}
}
pub fn key_len(&self) -> usize {
match self {
ProtectionProfile::NullCipherHmacSha180 => 0,
ProtectionProfile::Aes128CmNullAuth
| ProtectionProfile::Aes128CmHmacSha132
| ProtectionProfile::Aes128CmHmacSha180
| ProtectionProfile::AeadAes128Gcm => 16,
ProtectionProfile::Aes192CmNullAuth
| ProtectionProfile::Aes192CmHmacSha132
| ProtectionProfile::Aes192CmHmacSha180 => 24,
ProtectionProfile::Aes256CmNullAuth
| ProtectionProfile::Aes256CmHmacSha132
| ProtectionProfile::Aes256CmHmacSha180
| ProtectionProfile::AeadAes256Gcm => 32,
}
}
pub fn salt_len(&self) -> usize {
match self {
ProtectionProfile::NullCipherHmacSha180
| ProtectionProfile::Aes128CmNullAuth
| ProtectionProfile::Aes128CmHmacSha132
| ProtectionProfile::Aes128CmHmacSha180
| ProtectionProfile::Aes192CmNullAuth
| ProtectionProfile::Aes192CmHmacSha132
| ProtectionProfile::Aes192CmHmacSha180
| ProtectionProfile::Aes256CmNullAuth
| ProtectionProfile::Aes256CmHmacSha132
| ProtectionProfile::Aes256CmHmacSha180 => 14,
ProtectionProfile::AeadAes128Gcm | ProtectionProfile::AeadAes256Gcm => 12,
}
}
}