Skip to content

Commit 7724cae

Browse files
committed
feat: Add PK11_CheckUserPassword() and PK11_Logout() to Slot
1 parent 7cc1c33 commit 7724cae

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

bindings/bindings.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ functions = [
151151
"NSS_SetAlgorithmPolicy",
152152
"PK11_AEADOp",
153153
"PK11_Authenticate",
154+
"PK11_CheckUserPassword",
154155
"PK11_CipherOp",
155156
"PK11_CreateContextBySymKey",
156157
"PK11_Decrypt",
@@ -195,6 +196,7 @@ functions = [
195196
"PK11_ImportPublicKey",
196197
"PK11_ImportSymKey",
197198
"PK11_ListFixedKeysInSlot",
199+
"PK11_Logout",
198200
"PK11_PubDeriveWithKDF",
199201
"PK11_ReadRawAttribute",
200202
"PK11_ReferenceSlot",

src/p11.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,15 @@ impl Slot {
194194
secstatus_to_res(unsafe { PK11_Authenticate(self.ptr, PRBool::from(true), null_mut()) })
195195
}
196196

197+
pub fn check_user_password(&self, password: &str) -> Res<()> {
198+
let c_password = std::ffi::CString::new(password).map_err(|_| Error::String)?;
199+
secstatus_to_res(unsafe { PK11_CheckUserPassword(self.ptr, c_password.as_ptr()) })
200+
}
201+
202+
pub fn logout(&self) -> Res<()> {
203+
secstatus_to_res(unsafe { PK11_Logout(self.ptr) })
204+
}
205+
197206
/// Find a persistent symmetric key on this slot by nickname.
198207
/// Returns `None` if no key with the given nickname exists.
199208
#[must_use]

0 commit comments

Comments
 (0)