#pkcs11 #client-certificate #back-end #native #module #stores #credentials

native-pkcs11-traits

Traits for implementing and interactive with native-pkcs11 module backends

14 releases

0.2.17 Mar 13, 2024
0.2.15 Nov 14, 2023
0.2.12 Jun 21, 2023
0.2.7 Mar 22, 2023

#322 in Authentication

Download history 16/week @ 2023-12-28 5/week @ 2024-01-04 79/week @ 2024-02-15 18/week @ 2024-02-22 20/week @ 2024-02-29 55/week @ 2024-03-07 65/week @ 2024-03-14 11/week @ 2024-03-21 22/week @ 2024-03-28 18/week @ 2024-04-04 5/week @ 2024-04-11

61 downloads per month
Used in 4 crates

Apache-2.0

9KB
177 lines

native-pkcs11

pkcs11 module for native credential stores

native-pkcs11 is a crate for building PKCS#11 modules. Its primary use-case is authenticating with client certificates. native-pkcs11 aims to support native certificate stores (MacOS Keychain, Windows Platform Key Provider) out of the box. It can also be extended with a custom backend (see this section).

Host Software Compatibility

Software compatibility is a core goal of native-pkcs11. It is currently tested with

  • openssh
  • openvpn
  • Chrome
  • Firefox

If a native-pkcs11 module does not work for your software, please file an issue.

Building a Custom Backend

The native_pkcs11_traits::Backend trait can be implemented to add support for a new credential store. Backends are registered in the exported C_GetFunctionList function. In order to register your own backend, enable the custom-function-list feature on native-pkcs11 and export the method from your crate. For example:

use native_pkcs11::{CKR_OK, CK_FUNCTION_LIST_PTR_PTR, CK_RV, FUNC_LIST};
#[no_mangle]
pub extern "C" fn C_GetFunctionList(ppFunctionList: CK_FUNCTION_LIST_PTR_PTR) -> CK_RV {
    native_pkcs11_traits::register_backend(Box::new(backend::MyBackend {}));
    unsafe { *ppFunctionList = &mut FUNC_LIST };
    return CKR_OK;
}

Releasing

The cargo-ws tool can be used to version bump and release all crates in the workspace at once. It can be installed with cargo install cargo-workspaces.

# Bump the version of all crates in the workspace
cargo ws version --no-git-push
# Publish all crates to crates.io
cargo ws publish --no-git-push

Dependencies

~1.5–2MB
~42K SLoC