Crates.io | r2d2-cryptoki |
lib.rs | r2d2-cryptoki |
version | 0.3.0 |
source | src |
created_at | 2023-02-11 21:16:07.320063 |
updated_at | 2024-06-20 12:46:22.182219 |
description | r2d2 adaptor for cryptoki |
homepage | |
repository | https://github.com/spruceid/r2d2-cryptoki/ |
max_upload_size | |
id | 782706 |
size | 16,354 |
r2d2
adaptor for cryptoki
Session pool manager for cryptoki.
use r2d2_cryptoki::{*, cryptoki::{context::*, types::AuthPin}};
let 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(AuthPin::new("fedcba".to_string())));
let pool = r2d2::Pool::builder().build(manager).unwrap();
let session = pool.get().unwrap();
println!("{:?}", session.get_session_info().unwrap());