45 lines
1.5 KiB
Rust
45 lines
1.5 KiB
Rust
use base64::engine::general_purpose::STANDARD;
|
|
use base64::Engine;
|
|
use swift_secure_enclave_tool_rs::{
|
|
generate_ecdsa_keypair, is_secure_enclave_supported, KeyMaterial, KeyPurpose,
|
|
};
|
|
|
|
fn main() {
|
|
println!(
|
|
"Secure Enclave supported: {}",
|
|
is_secure_enclave_supported().unwrap()
|
|
);
|
|
|
|
let ecdsa_key_material_require_bio = generate_ecdsa_keypair(KeyPurpose::Signing, true).unwrap();
|
|
print_key_material("Signing key [require bio]", &ecdsa_key_material_require_bio);
|
|
|
|
let ecdsa_key_material_no_bio = generate_ecdsa_keypair(KeyPurpose::Signing, true).unwrap();
|
|
print_key_material("Signing key [no bio]", &ecdsa_key_material_no_bio);
|
|
|
|
let ecdsa_key_material_require_bio =
|
|
generate_ecdsa_keypair(KeyPurpose::KeyAgreement, true).unwrap();
|
|
print_key_material(
|
|
"Key agreement key [require bio]",
|
|
&ecdsa_key_material_require_bio,
|
|
);
|
|
|
|
let ecdsa_key_material_no_bio = generate_ecdsa_keypair(KeyPurpose::KeyAgreement, true).unwrap();
|
|
print_key_material("Key agreement key [no bio]", &ecdsa_key_material_no_bio);
|
|
}
|
|
|
|
fn print_key_material(prefix: &str, key_material: &KeyMaterial) {
|
|
println!("\n{}", prefix);
|
|
println!(
|
|
"Public key point:\n{}",
|
|
hex::encode(&key_material.public_key_point)
|
|
);
|
|
println!(
|
|
"\nPublic key:\n{}",
|
|
STANDARD.encode(&key_material.public_key_der)
|
|
);
|
|
println!(
|
|
"\nPrivate key representation:\n{}",
|
|
STANDARD.encode(&key_material.private_key_representation)
|
|
);
|
|
}
|