ehsm
is a rust integration library to use the non-PKCS11 functions from the
ehsm shared library. Use this crate in conjunction with the pkcs11
crate.
use ehsm::*;
let lib_name = ehsm_library_name();
let ehsm = EHSMContext::new(lib_name.as_path())
.expect("Failed to load ehsm library functions");
let session = get_logged_in_session(&ctx, SU_PIN,0,None,None)
.expect("Failed to get session");
ehsm.import_bitcoin_key(session,
&hex::decode("000102030405060708090a0b0c0d0e0f").unwrap())
.expect("Failed to import key");
let mut indexes: Vec<u32> = Vec::new();
let net: u32 = 0x0488B21Eu32;
let xpub = ehsm.get_bitcoin_pub(session, &indexes, net).expect("Failed to get btc pub");
let mut indexes: Vec<u32> = Vec::new();
let sig = ehsm.sign_bitcoin_hash(session,&vec![0;32],&indexes).expect("Failed to sign hash");
ehsm_library_name | A utility function to retrieve the library name from the EHSM_LIBRARY environment variable or default path
|
get_logged_in_session | A utility function to open a session and log-in
|