sequoia-cryptoki 0.2.0

Library for working with PKCS#11 devices (cryptokis) from Sequoia
Documentation
use crate::integration::common::*;

#[test]
fn token_init_random_token_label() -> Result<()> {
    let sqc = SqCryptoki::new();

    let slot = sqc.allocate_slot();

    // This will only succeed if the token is initialized.
    let algo = sequoia_openpgp::crypto::PublicKeyAlgorithm::Ed25519;
    let _ = sqc.try_key_generate(slot, None, algo, true, Default::default(), USER_PIN);

    // Initialize the token.
    sqc.token_init(slot, None, SO_PIN, USER_PIN);

    // This will now always succeed.
    sqc.key_generate(slot, None, algo, true, Default::default(), USER_PIN);

    Ok(())
}