Skip to content

Commit

Permalink
Fix fetching individual certificate attributes
Browse files Browse the repository at this point in the history
Signed-off-by: Simo Sorce <[email protected]>
  • Loading branch information
simo5 committed Nov 25, 2024
1 parent 713bf54 commit d4a9746
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/storage/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,15 @@ impl Storage for StdStorageFormat {
/* the values don't matter, only the type */
let dnm: CK_ULONG = 0;
let mut attrs = CkAttrs::from(attributes);
/* we need CKA_CLASS and CKA_KEY_TYPE to be present in
/* we need object defining attributes to be present in
* order to get sensitive attrs from the factory later */
if attributes.len() != 0 {
attrs.add_missing_ulong(CKA_CLASS, &dnm);
/* it is safe to add CKA_KEY_TYPE even if the object
* is not a key, the attribute will simply not be returned
* in that case */
/* it is safe to add attributes even if the objects
* are not of the correct type, the attribute will simply
* not be returned in that case */
attrs.add_missing_ulong(CKA_KEY_TYPE, &dnm);
attrs.add_missing_ulong(CKA_CERTIFICATE_TYPE, &dnm);
}

let mut obj = self.store.fetch_by_uid(&uid, attrs.as_slice())?;
Expand Down

0 comments on commit d4a9746

Please sign in to comment.