Skip to content

Commit 5967c11

Browse files
committed
Fix StartDate conversion
Signed-off-by: Ionut Mihalcea <ionut.mihalcea@arm.com>
1 parent a78d2be commit 5967c11

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

cryptoki/src/object.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ impl TryFrom<CK_ATTRIBUTE> for Attribute {
908908
}
909909
AttributeType::StartDate => {
910910
if val.is_empty() {
911-
Ok(Attribute::EndDate(Date::new_empty()))
911+
Ok(Attribute::StartDate(Date::new_empty()))
912912
} else {
913913
let date = val.as_ptr() as *const CK_DATE;
914914
unsafe {

cryptoki/tests/basic.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,8 +706,20 @@ fn aes_key_attributes_test() -> Result<()> {
706706
// generate a key pair
707707
let key = session.generate_key(&mechanism, &key_template)?;
708708

709-
let _attributes_result =
709+
let mut attributes_result =
710710
session.get_attributes(key, &[AttributeType::EndDate, AttributeType::StartDate])?;
711711

712+
if let Some(Attribute::StartDate(date)) = attributes_result.pop() {
713+
assert!(date.is_empty());
714+
} else {
715+
panic!("Last attribute was not a start date");
716+
}
717+
718+
if let Some(Attribute::EndDate(date)) = attributes_result.pop() {
719+
assert!(date.is_empty());
720+
} else {
721+
panic!("First attribute was not an end date");
722+
}
723+
712724
Ok(())
713725
}

0 commit comments

Comments
 (0)