Skip to content

Commit cb6eba1

Browse files
committed
tests: Explicitly set attributes that are checked for KBKDF
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
1 parent 27fce37 commit cb6eba1

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

cryptoki/tests/basic.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2517,6 +2517,8 @@ fn kbkdf_additional_keys_counter_mode() -> TestResult {
25172517
Attribute::ValueLen((AES128_BLOCK_SIZE as u64).into()),
25182518
Attribute::Sign(true),
25192519
Attribute::Verify(true),
2520+
Attribute::Encrypt(false),
2521+
Attribute::Decrypt(false),
25202522
],
25212523
vec![
25222524
Attribute::Token(true),
@@ -2525,6 +2527,8 @@ fn kbkdf_additional_keys_counter_mode() -> TestResult {
25252527
Attribute::KeyType(KeyType::GENERIC_SECRET),
25262528
Attribute::ValueLen(1.into()),
25272529
Attribute::Derive(true),
2530+
Attribute::Encrypt(false),
2531+
Attribute::Decrypt(false),
25282532
],
25292533
];
25302534

@@ -2601,6 +2605,8 @@ fn kbkdf_additional_keys_counter_mode() -> TestResult {
26012605
Attribute::Sign(true),
26022606
Attribute::Verify(true),
26032607
Attribute::Derive(false),
2608+
Attribute::Encrypt(false),
2609+
Attribute::Decrypt(false),
26042610
],
26052611
vec![
26062612
Attribute::Class(ObjectClass::SECRET_KEY),
@@ -2611,14 +2617,19 @@ fn kbkdf_additional_keys_counter_mode() -> TestResult {
26112617
Attribute::Sign(false),
26122618
Attribute::Verify(false),
26132619
Attribute::Derive(true),
2620+
Attribute::Encrypt(false),
2621+
Attribute::Decrypt(false),
26142622
],
26152623
];
26162624

26172625
for (key, wanted_attributes) in derived_keys.iter().zip(wanted_attributes.iter().cycle()) {
26182626
let have_attributes = session.get_attributes(*key, &attributes_to_check)?;
26192627

26202628
for (value_wanted, value_have) in wanted_attributes.iter().zip(have_attributes.iter()) {
2621-
assert_eq!(value_wanted, value_have);
2629+
assert_eq!(
2630+
value_wanted, value_have,
2631+
"The generated key {key} has unexpected attribute value"
2632+
);
26222633
}
26232634
}
26242635

@@ -2673,6 +2684,8 @@ fn kbkdf_additional_keys_feedback_mode() -> TestResult {
26732684
Attribute::ValueLen((AES128_BLOCK_SIZE as u64).into()),
26742685
Attribute::Sign(true),
26752686
Attribute::Verify(true),
2687+
Attribute::Encrypt(false),
2688+
Attribute::Decrypt(false),
26762689
],
26772690
vec![
26782691
Attribute::Token(true),
@@ -2681,6 +2694,8 @@ fn kbkdf_additional_keys_feedback_mode() -> TestResult {
26812694
Attribute::KeyType(KeyType::GENERIC_SECRET),
26822695
Attribute::ValueLen(1.into()),
26832696
Attribute::Derive(true),
2697+
Attribute::Encrypt(false),
2698+
Attribute::Decrypt(false),
26842699
],
26852700
];
26862701

0 commit comments

Comments
 (0)