skf-rs 0.8.1

Rust wrapper for GM/T 0016-2012(Smart token cryptography application interface specification).
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use skf_rs::helper::auth::encrypt_auth_key_sm1_ecb;
use skf_rs::{Engine, LibLoader};

fn main() {
    let engine = Engine::new(LibLoader::env_lookup().unwrap());
    let manager = engine.device_manager().unwrap();
    let device = manager.connect_selected(|list| Some(list[0])).unwrap();
    let auth_key = encrypt_auth_key_sm1_ecb(
        device.as_ref(),
        &[
            0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36,
            0x37, 0x38,
        ],
    )
    .unwrap();
    let ret = device.device_auth(auth_key.as_slice());
    println!("device auth result: {:?}", ret);
}