Skip to content

Commit 79080bf

Browse files
committed
cms: ecc-kari support - add From<KeyWrapAlgorithm> for WrappingKey test
1 parent cf26d3b commit 79080bf

File tree

1 file changed

+17
-4
lines changed
  • cms/src/builder/utils

1 file changed

+17
-4
lines changed

cms/src/builder/utils/kw.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ impl From<KeyWrapper> for Vec<u8> {
222222
/// - Aes192
223223
/// - Aes256
224224
///
225-
#[derive(Debug, Clone, Copy)]
225+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
226226
enum WrappingKey {
227227
/// id-aes128-wrap
228228
Aes128([u8; 16]),
@@ -330,9 +330,6 @@ mod tests {
330330
assert_eq!(KeyWrapAlgorithm::Aes256.key_size_in_bits(), 256);
331331
}
332332

333-
#[test]
334-
fn test_wrappingkey_from_keywrapalgorithm() {}
335-
336333
#[test]
337334
fn test_algorithmidentifierowned_from_keywrapalgorithm() {
338335
assert_eq!(
@@ -491,6 +488,22 @@ mod tests {
491488
assert_eq!(vec[0], 0);
492489
}
493490

491+
#[test]
492+
fn test_wrappingkey_from_keywrapalgorithm() {
493+
assert_eq!(
494+
WrappingKey::from(&KeyWrapAlgorithm::Aes128),
495+
WrappingKey::Aes128([0u8; 16])
496+
);
497+
assert_eq!(
498+
WrappingKey::from(&KeyWrapAlgorithm::Aes192),
499+
WrappingKey::Aes192([0u8; 24])
500+
);
501+
assert_eq!(
502+
WrappingKey::from(&KeyWrapAlgorithm::Aes256),
503+
WrappingKey::Aes256([0u8; 32])
504+
);
505+
}
506+
494507
#[test]
495508
fn test_wrappingkey_as_mut() {
496509
let mut key_a128 = WrappingKey::Aes128([0; 16]);

0 commit comments

Comments
 (0)