Ability to capture login PIN (`C_Login`)
- Dominant language
- Rust
- Stars
- 74
- Forks
- 23
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 3
Description
Hi,
I'm trying out your excellent library and the one thing I'm missing is the ability to capture PIN as entered by the client (basically the `C_Login` function).
I'm currently using this workaround:
```rust
native_pkcs11_traits::register_backend(Box::new(Backend::default()));
unsafe {
info!("replacing login");
FUNC_LIST.C_Login = Some(C_Login_2);
FUNC_LIST.C_GetTokenInfo = Some(C_GetTokenInfo_2);
}
```
with:
```rust
#[unsafe(no_mangle)]
pub extern "C" fn C_Login_2(
_h_session: CK_SESSION_HANDLE,
user_type: CK_USER_TYPE,
p_pin: CK_UTF8CHAR_PTR,
ul_pin_len: CK_ULONG,
) -> CK_RV {
let pin = str::from_utf8(unsafe { slice::from_raw_parts(p_pin, ul_pin_len as usize) }).unwrap();
info!("got pin {user_type:?}, {pin}");
CKR_OK
}
```
which kind of works but sadly makes me deal with the low-level types.
Would support for capturing `C_Login` via high-level API (e.g. `native_pkcs11_traits::Backend`) be a good fit?
(I think it'd be possible to provide a default no-op function there so that the API stays stable).
Thanks for such a great library! 👋
Contributor guide
Assessment
This issue has not been assessed yet.