feat: v1.1.6, pgp card make

This commit is contained in:
2022-04-09 00:26:52 +08:00
parent ebce55e76c
commit c7560e24f3
3 changed files with 26 additions and 22 deletions

2
Cargo.lock generated
View File

@@ -384,7 +384,7 @@ dependencies = [
[[package]] [[package]]
name = "card-cli" name = "card-cli"
version = "1.1.5" version = "1.1.6"
dependencies = [ dependencies = [
"authenticator", "authenticator",
"base64 0.13.0", "base64 0.13.0",

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "card-cli" name = "card-cli"
version = "1.1.5" version = "1.1.6"
authors = ["Hatter Jiang <jht5945@gmail.com>"] authors = ["Hatter Jiang <jht5945@gmail.com>"]
edition = "2018" edition = "2018"

View File

@@ -182,16 +182,17 @@ impl Command for CommandImpl {
} }
debugging!("Found PGP RSA private key set: {:?}", pgp_rsa_private_key_set); debugging!("Found PGP RSA private key set: {:?}", pgp_rsa_private_key_set);
if pgp_rsa_private_key_set.signing.is_none()
|| pgp_rsa_private_key_set.encryption.is_none()
|| pgp_rsa_private_key_set.authentication.is_none() {
warning!("PGP RSA private keys is not complete!");
}
success!("Found PGP RSA private keys, signing: {}, encryption: {}, authentication: {}", success!("Found PGP RSA private keys, signing: {}, encryption: {}, authentication: {}",
pgp_rsa_private_key_set.signing.is_some(), pgp_rsa_private_key_set.signing.is_some(),
pgp_rsa_private_key_set.encryption.is_some(), pgp_rsa_private_key_set.encryption.is_some(),
pgp_rsa_private_key_set.authentication.is_some()); pgp_rsa_private_key_set.authentication.is_some());
if pgp_rsa_private_key_set.signing.is_none() || pgp_rsa_private_key_set.encryption.is_none() || pgp_rsa_private_key_set.authentication.is_none() {
warning!("PGP RSA private keys is not complete!");
return Ok(None);
}
let force_make = sub_arg_matches.is_present("force-make"); let force_make = sub_arg_matches.is_present("force-make");
if !force_make { if !force_make {
warning!("Force make is OFF, skip write private keys to card!"); warning!("Force make is OFF, skip write private keys to card!");
@@ -206,23 +207,26 @@ impl Command for CommandImpl {
opt_result!(trans.verify_pw3(pin.as_ref()), "Admin pin verify failed: {}"); opt_result!(trans.verify_pw3(pin.as_ref()), "Admin pin verify failed: {}");
success!("Admin pin verify success!"); success!("Admin pin verify success!");
let signing_key = pgp_rsa_private_key_set.signing.unwrap(); if let Some(signing_key) = pgp_rsa_private_key_set.signing {
let signing_key_id = signing_key.key_id.clone(); let signing_key_id = signing_key.key_id.clone();
information!("Prepare write PGP signing key, key id: {}", signing_key_id); information!("Prepare write PGP signing key, key id: {}", signing_key_id);
opt_result!(trans.key_import(Box::new(signing_key), KeyType::Signing), "Write PGP signing key failed: {}"); opt_result!(trans.key_import(Box::new(signing_key), KeyType::Signing), "Write PGP signing key failed: {}");
success!("Write PGP signing key success, key id: {}", signing_key_id); success!("Write PGP signing key success, key id: {}", signing_key_id);
}
let encryption_key = pgp_rsa_private_key_set.encryption.unwrap(); if let Some(encryption_key) = pgp_rsa_private_key_set.encryption {
let encryption_key_id = encryption_key.key_id.clone(); let encryption_key_id = encryption_key.key_id.clone();
information!("Prepare write PGP encryption key, key id: {}", signing_key_id); information!("Prepare write PGP encryption key, key id: {}", signing_key_id);
opt_result!(trans.key_import(Box::new(encryption_key), KeyType::Decryption), "Write PGP encryption key failed: {}"); opt_result!(trans.key_import(Box::new(encryption_key), KeyType::Decryption), "Write PGP encryption key failed: {}");
success!("Write PGP encryption key success, key id: {}", encryption_key_id); success!("Write PGP encryption key success, key id: {}", encryption_key_id);
}
let authentication_key = pgp_rsa_private_key_set.authentication.unwrap(); if let Some(authentication_key) = pgp_rsa_private_key_set.authentication {
let authentication_key_id = authentication_key.key_id.clone(); let authentication_key_id = authentication_key.key_id.clone();
information!("Prepare write PGP authentication key, key id: {}", signing_key_id); information!("Prepare write PGP authentication key, key id: {}", signing_key_id);
opt_result!(trans.key_import(Box::new(authentication_key), KeyType::Authentication), "Write PGP authentication key failed: {}"); opt_result!(trans.key_import(Box::new(authentication_key), KeyType::Authentication), "Write PGP authentication key failed: {}");
success!("Write PGP authentication key success, key id: {}", authentication_key_id); success!("Write PGP authentication key success, key id: {}", authentication_key_id);
}
Ok(None) Ok(None)
} }