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