feat: add url, card holder, supported algo for pgp card list
This commit is contained in:
@@ -9,7 +9,7 @@ impl Command for CommandImpl {
|
||||
fn name(&self) -> &str { "pgp-card-decrypt" }
|
||||
|
||||
fn subcommand<'a>(&self) -> App<'a, 'a> {
|
||||
SubCommand::with_name(self.name()).about("OpenPGP Card List subcommand")
|
||||
SubCommand::with_name(self.name()).about("OpenPGP Card Decrypt subcommand")
|
||||
.arg(Arg::with_name("pass").short("p").long("pass").takes_value(true).default_value("123456").help("OpenPGP card password"))
|
||||
.arg(Arg::with_name("cipher").short("c").long("cipher").takes_value(true).help("Cipher text HEX"))
|
||||
.arg(Arg::with_name("cipher-base64").short("b").long("cipher-base64").takes_value(true).help("Cipher text base64"))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use clap::{ArgMatches, SubCommand, App, Arg};
|
||||
use crate::cmd::{Command, CommandError};
|
||||
use openpgp_card::{OpenPGPCard, DecryptMe, Hash};
|
||||
use openpgp_card::{OpenPGPCard, DecryptMe, Hash, KeyType};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
pub struct CommandImpl;
|
||||
@@ -26,20 +26,38 @@ impl Command for CommandImpl {
|
||||
information!("Found {} card(s)", list.len());
|
||||
for (i, card) in list.iter().enumerate() {
|
||||
success!("Found card {}: {:?}", i, card.get_aid());
|
||||
if let Ok(url) = card.get_url() {
|
||||
information!("URL: {}", iff!(url.is_empty(), "<empty>", &url));
|
||||
}
|
||||
if let Ok(card_holder) = card.get_cardholder_related_data() {
|
||||
information!("Card holder: {:?}", card_holder);
|
||||
}
|
||||
if let Ok(supported_algo) = card.list_supported_algo() {
|
||||
information!("Supported algo: {:?}", supported_algo);
|
||||
}
|
||||
if let Ok(fingerprints) = card.get_fingerprints() {
|
||||
if let Some(a) = fingerprints.authentication() {
|
||||
if let Ok(algo) = card.get_algorithm_attributes(KeyType::Authentication) {
|
||||
information!("Authentication algo: {:?}", algo);
|
||||
}
|
||||
information!("Authentication fingerprint: {}", a);
|
||||
if json_output {
|
||||
json.insert("authentication_fingerprint", a.to_string());
|
||||
}
|
||||
}
|
||||
if let Some(d) = fingerprints.decryption() {
|
||||
if let Ok(algo) = card.get_algorithm_attributes(KeyType::Decryption) {
|
||||
information!("Encryption algo: {:?}", algo);
|
||||
}
|
||||
information!("Encryption fingerprint: {}", d);
|
||||
if json_output {
|
||||
json.insert("encryption_fingerprint", d.to_string());
|
||||
}
|
||||
}
|
||||
if let Some(s) = fingerprints.signature() {
|
||||
if let Ok(algo) = card.get_algorithm_attributes(KeyType::Signing) {
|
||||
information!("Signature algo: {:?}", algo);
|
||||
}
|
||||
information!("Signature fingerprint: {}", s);
|
||||
if json_output {
|
||||
json.insert("signature_fingerprint", s.to_string());
|
||||
|
||||
@@ -10,7 +10,7 @@ impl Command for CommandImpl {
|
||||
fn name(&self) -> &str { "pgp-card-sign" }
|
||||
|
||||
fn subcommand<'a>(&self) -> App<'a, 'a> {
|
||||
SubCommand::with_name(self.name()).about("OpenPGP Card List subcommand")
|
||||
SubCommand::with_name(self.name()).about("OpenPGP Card Sign subcommand")
|
||||
.arg(Arg::with_name("pass").short("p").long("pass").takes_value(true).default_value("123456").help("OpenPGP card password"))
|
||||
.arg(Arg::with_name("sha256").short("2").long("sha256").takes_value(true).help("Digest SHA256 HEX"))
|
||||
.arg(Arg::with_name("sha384").short("3").long("sha384").takes_value(true).help("Digest SHA384 HEX"))
|
||||
|
||||
Reference in New Issue
Block a user