Crate r2d2_cryptoki

source ·
Expand description

r2d2 adaptor for cryptoki

Crates.io Documentation

Session pool manager for cryptoki.

Example

use r2d2_cryptoki::*;
use cryptoki::context::*;

let mut pkcs11 = Pkcs11::new("libsofthsm2.so").unwrap();
pkcs11.initialize(CInitializeArgs::OsThreads).unwrap();
let slots = pkcs11.get_slots_with_token().unwrap();
let slot = slots.first().unwrap();
let manager = SessionManager::new(pkcs11, *slot, SessionType::RwUser(Pin::new("fedcba".to_string())));

let pool = r2d2::Pool::builder().build(manager).unwrap();

let session = pool.get().unwrap();
println!("{:?}", session.get_session_info().unwrap());

Re-exports

pub use cryptoki;
pub use r2d2;

Structs

Manager holding all information necessary for opening new connections

Enums

Session types, holding the pin for the authenticated sessions

Type Definitions

[Zeroize] wrapper for a PKCS#11 Pin
Alias for this crate’s instance of r2d2’s Pool
Alias for this crate’s instance of r2d2’s PooledSession