Skip to content

Commit

Permalink
Added CertStore::find_by_key_id function
Browse files Browse the repository at this point in the history
  • Loading branch information
ancwrd1 committed Oct 13, 2024
1 parent 82ed658 commit 81801b4
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,23 @@ impl CertStore {
unsafe { self.do_find(CERT_FIND_HASH, &hash_blob as *const _ as _) }
}

/// Find list of certificates matching the key identifier
pub fn find_by_key_id<D>(&self, key_id: D) -> Result<Vec<CertContext>>
where
D: AsRef<[u8]>,
{
let cert_id = CERT_ID {
dwIdChoice: CERT_ID_KEY_IDENTIFIER,
Anonymous: CERT_ID_0 {
KeyId: CRYPT_INTEGER_BLOB {
cbData: key_id.as_ref().len() as u32,
pbData: key_id.as_ref().as_ptr() as _,
},
},
};
unsafe { self.do_find(CERT_FIND_CERT_ID, &cert_id as *const _ as _) }
}

/// Get all certificates
pub fn find_all(&self) -> Result<Vec<CertContext>> {
unsafe { self.do_find(CERT_FIND_ANY, ptr::null()) }
Expand Down

0 comments on commit 81801b4

Please sign in to comment.