ehsm

Crates.ioehsm
lib.rsehsm
version0.1.1
sourcesrc
created_at2020-08-18 16:54:15.085914
updated_at2020-08-18 17:11:31.265924
descriptionRust integration library for libehsm
homepagehttps://github.com/ellipticSecure/ehsm-rust
repositoryhttps://github.com/ellipticSecure/ehsm-rust
max_upload_size
id277978
size29,404
Kobus Grobler (kobusgrobler)

documentation

README

This is a Rust library to interface with the eHSM and MIRkey Hardware Security Modules

Latest version Documentation License

Example usage

    ...
    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");
    let mut oh: CK_OBJECT_HANDLE = CK_INVALID_HANDLE;
    if ehsm.has_bitcoin_key(session, &mut oh).unwrap() {
        println!("already has btc key.");
    } else {
        ehsm.import_bitcoin_key(session,
                            &hex::decode("000102030405060708090a0b0c0d0e0f").unwrap())
        .expect("Failed to import key");
    }

    // empty index vector is the root key or "m"
    // for "m/0", just add 0 to indexes, i.e. indexes.push(0) etc. to build the BIP32 path
    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 xpub");
    ...
    // sign a 32 byte transaction hash
    let sig = ehsm.sign_bitcoin_hash(session,&vec![0;32],&indexes).expect("Failed to sign hash");

Also see the integration tests here:

Commit count: 3

cargo fmt