Skip to content

Commit

Permalink
cms: ecc-kari support - add From<KeyWrapAlgorithm> for WrappingKey test
Browse files Browse the repository at this point in the history
  • Loading branch information
nemynm committed Oct 20, 2024
1 parent 457281c commit 4901a07
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions cms/src/builder/utils/kw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ impl From<KeyWrapper> for Vec<u8> {
/// - Aes192
/// - Aes256
///
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum WrappingKey {
/// id-aes128-wrap
Aes128([u8; 16]),
Expand Down Expand Up @@ -330,9 +330,6 @@ mod tests {
assert_eq!(KeyWrapAlgorithm::Aes256.key_size_in_bits(), 256);
}

#[test]
fn test_wrappingkey_from_keywrapalgorithm() {}

#[test]
fn test_algorithmidentifierowned_from_keywrapalgorithm() {
assert_eq!(
Expand Down Expand Up @@ -491,6 +488,22 @@ mod tests {
assert_eq!(vec[0], 0);
}

#[test]
fn test_wrappingkey_from_keywrapalgorithm() {
assert_eq!(
WrappingKey::from(&KeyWrapAlgorithm::Aes128),
WrappingKey::Aes128([0u8; 16])
);
assert_eq!(
WrappingKey::from(&KeyWrapAlgorithm::Aes192),
WrappingKey::Aes192([0u8; 24])
);
assert_eq!(
WrappingKey::from(&KeyWrapAlgorithm::Aes256),
WrappingKey::Aes256([0u8; 32])
);
}

#[test]
fn test_wrappingkey_as_mut() {
let mut key_a128 = WrappingKey::Aes128([0; 16]);
Expand Down

0 comments on commit 4901a07

Please sign in to comment.