feat: v1.2.1, pgp-card-make print-*-keys

This commit is contained in:
2022-04-14 23:24:38 +08:00
parent d9a5b5c831
commit ef100c2921
5 changed files with 68 additions and 6 deletions

View File

@@ -132,6 +132,8 @@ impl Command for CommandImpl {
.arg(Arg::with_name("pass").long("pass").takes_value(true).required(false).help("Password for PGP secret key"))
.arg(Arg::with_name("in").long("in").takes_value(true).required(false).help("PGP file in"))
.arg(Arg::with_name("force-make").long("force-make").help("Force make OpenPGP card"))
.arg(Arg::with_name("print-public-keys").long("print-public-keys").help("Print public keys"))
.arg(Arg::with_name("print-private-keys").long("print-private-keys").help("Print private keys"))
}
fn run(&self, _arg_matches: &ArgMatches, sub_arg_matches: &ArgMatches) -> CommandError {
@@ -192,6 +194,39 @@ impl Command for CommandImpl {
pgp_rsa_private_key_set.encryption.is_some(),
pgp_rsa_private_key_set.authentication.is_some());
let print_private_keys = sub_arg_matches.is_present("print-private-keys");
let print_public_keys = sub_arg_matches.is_present("print-public-keys");
if let Some(signing_key) = &pgp_rsa_private_key_set.signing {
if print_private_keys {
let signing_key_pem = opt_result!(signing_key.rsa_private_key.to_pem(), "Signing private key to pem failed: {}");
information!("Signing key: {}", signing_key_pem);
}
if print_public_keys {
let signing_public_key_pem = opt_result!(signing_key.rsa_private_key.to_public_key_pem(), "Signing public key to pem failed: {}");
information!("Signing public key: {}", signing_public_key_pem);
}
}
if let Some(encryption_key) = &pgp_rsa_private_key_set.encryption {
if print_private_keys {
let encryption_key_pem = opt_result!(encryption_key.rsa_private_key.to_pem(), "Encryption private key to pem failed: {}");
information!("Encryption key: {}", encryption_key_pem);
}
if print_public_keys {
let encryption_public_key_pem = opt_result!(encryption_key.rsa_private_key.to_public_key_pem(), "Encryption public key to pem failed: {}");
information!("Encryption public key: {}", encryption_public_key_pem);
}
}
if let Some(authentication_key) = &pgp_rsa_private_key_set.authentication {
if print_private_keys {
let authentication_key_pem = opt_result!(authentication_key.rsa_private_key.to_pem(), "Authentication private key to pem failed: {}");
information!("Authentication key: {}", authentication_key_pem);
}
if print_public_keys {
let authentication_public_key_pem = opt_result!(authentication_key.rsa_private_key.to_public_key_pem(), "Authentication public key to pem failed: {}");
information!("Authentication public key: {}", authentication_public_key_pem);
}
}
let force_make = sub_arg_matches.is_present("force-make");
if !force_make {
warning!("Force make is OFF, add argument --force-make to open, skip write private keys to card!");