opgpcard: in 'status', handle 'pkm' parameter analogously to 'verbose'
This commit is contained in:
parent
5f715647c9
commit
3a9d40454f
2 changed files with 23 additions and 23 deletions
|
@ -43,6 +43,7 @@ pub fn print_status(
|
|||
) -> Result<()> {
|
||||
let mut output = output::Status::default();
|
||||
output.verbose(command.verbose);
|
||||
output.pkm(command.pkm);
|
||||
|
||||
let backend = pick_card_for_reading(command.ident)?;
|
||||
let mut open: Card<Open> = backend.into();
|
||||
|
@ -100,10 +101,8 @@ pub fn print_status(
|
|||
signature_key.status(format!("{}", ks));
|
||||
}
|
||||
|
||||
if command.pkm {
|
||||
if let Ok(pkm) = card.public_key_material(KeyType::Signing) {
|
||||
signature_key.public_key_material(pkm.to_string());
|
||||
}
|
||||
if let Ok(pkm) = card.public_key_material(KeyType::Signing) {
|
||||
signature_key.public_key_material(pkm.to_string());
|
||||
}
|
||||
|
||||
output.signature_key(signature_key);
|
||||
|
@ -129,10 +128,8 @@ pub fn print_status(
|
|||
if let Some(ks) = ki.as_ref().map(|ki| ki.dec_status()) {
|
||||
decryption_key.status(format!("{}", ks));
|
||||
}
|
||||
if command.pkm {
|
||||
if let Ok(pkm) = card.public_key_material(KeyType::Decryption) {
|
||||
decryption_key.public_key_material(pkm.to_string());
|
||||
}
|
||||
if let Ok(pkm) = card.public_key_material(KeyType::Decryption) {
|
||||
decryption_key.public_key_material(pkm.to_string());
|
||||
}
|
||||
output.decryption_key(decryption_key);
|
||||
|
||||
|
@ -154,10 +151,8 @@ pub fn print_status(
|
|||
if let Some(ks) = ki.as_ref().map(|ki| ki.aut_status()) {
|
||||
authentication_key.status(format!("{}", ks));
|
||||
}
|
||||
if command.pkm {
|
||||
if let Ok(pkm) = card.public_key_material(KeyType::Authentication) {
|
||||
authentication_key.public_key_material(pkm.to_string());
|
||||
}
|
||||
if let Ok(pkm) = card.public_key_material(KeyType::Authentication) {
|
||||
authentication_key.public_key_material(pkm.to_string());
|
||||
}
|
||||
output.authentication_key(authentication_key);
|
||||
|
||||
|
@ -177,10 +172,8 @@ pub fn print_status(
|
|||
}
|
||||
|
||||
// TODO: get public key data for the attestation key from the card
|
||||
// if command.pkm {
|
||||
// if let Ok(pkm) = card.public_key(KeyType::Attestation) {
|
||||
// attestation_key.public_key_material(pkm.to_string());
|
||||
// }
|
||||
// if let Ok(pkm) = card.public_key(KeyType::Attestation) {
|
||||
// attestation_key.public_key_material(pkm.to_string());
|
||||
// }
|
||||
|
||||
// TODO: clarify how to reliably map `card.key_information()` output into this field (see below)
|
||||
|
|
|
@ -8,7 +8,8 @@ use crate::{OutputBuilder, OutputFormat, OutputVariant, OutputVersion};
|
|||
|
||||
#[derive(Debug, Default, Serialize)]
|
||||
pub struct Status {
|
||||
verbose: bool,
|
||||
verbose: bool, // show verbose text output?
|
||||
pkm: bool, // include public key material in text output?
|
||||
ident: String,
|
||||
card_version: String,
|
||||
cardholder_name: Option<String>,
|
||||
|
@ -32,6 +33,10 @@ impl Status {
|
|||
self.verbose = verbose;
|
||||
}
|
||||
|
||||
pub fn pkm(&mut self, pkm: bool) {
|
||||
self.pkm = pkm;
|
||||
}
|
||||
|
||||
pub fn ident(&mut self, ident: String) {
|
||||
self.ident = ident;
|
||||
}
|
||||
|
@ -132,7 +137,7 @@ impl Status {
|
|||
}
|
||||
|
||||
s.push_str("Signature key:\n");
|
||||
for line in self.signature_key.format(self.verbose) {
|
||||
for line in self.signature_key.format(self.verbose, self.pkm) {
|
||||
s.push_str(&format!(" {}\n", line));
|
||||
}
|
||||
if self.verbose {
|
||||
|
@ -146,13 +151,13 @@ impl Status {
|
|||
s.push('\n');
|
||||
|
||||
s.push_str("Decryption key:\n");
|
||||
for line in self.decryption_key.format(self.verbose) {
|
||||
for line in self.decryption_key.format(self.verbose, self.pkm) {
|
||||
s.push_str(&format!(" {}\n", line));
|
||||
}
|
||||
s.push('\n');
|
||||
|
||||
s.push_str("Authentication key:\n");
|
||||
for line in self.authentication_key.format(self.verbose) {
|
||||
for line in self.authentication_key.format(self.verbose, self.pkm) {
|
||||
s.push_str(&format!(" {}\n", line));
|
||||
}
|
||||
s.push('\n');
|
||||
|
@ -161,7 +166,7 @@ impl Status {
|
|||
if let Some(attestation_key) = &self.attestation_key {
|
||||
if attestation_key.touch_policy.is_some() || attestation_key.algorithm.is_some() {
|
||||
s.push_str("Attestation key:\n");
|
||||
for line in attestation_key.format(self.verbose) {
|
||||
for line in attestation_key.format(self.verbose, self.pkm) {
|
||||
s.push_str(&format!(" {}\n", line));
|
||||
}
|
||||
s.push('\n');
|
||||
|
@ -322,8 +327,10 @@ impl KeySlotInfo {
|
|||
lines.push(format!("Key Status: {}", status));
|
||||
}
|
||||
}
|
||||
if let Some(material) = &self.public_key_material {
|
||||
lines.push(format!("Public key material: {}", material));
|
||||
if pkm {
|
||||
if let Some(material) = &self.public_key_material {
|
||||
lines.push(format!("Public key material: {}", material));
|
||||
}
|
||||
}
|
||||
|
||||
lines
|
||||
|
|
Loading…
Reference in a new issue