Add callback Fn for touch confirmation prompt to generate attestations.

This commit is contained in:
Heiko Schaefer 2022-05-31 01:14:56 +02:00
parent 374f9eec89
commit d96e56651b
No known key found for this signature in database
GPG key ID: 4A849A1904CCBD7D
2 changed files with 17 additions and 2 deletions

View file

@ -379,7 +379,20 @@ impl<'app, 'open> Sign<'app, 'open> {
} }
/// Generate Attestation (Yubico) /// Generate Attestation (Yubico)
pub fn generate_attestation(&mut self, key_type: KeyType) -> Result<(), Error> { pub fn generate_attestation(
&mut self,
key_type: KeyType,
touch_prompt: &'open (dyn Fn() + Send + Sync),
) -> Result<(), Error> {
// Touch is required if:
// - the card supports the feature
// - and the policy is set to a value other than 'Off'
if let Some(uif) = self.oc.ard.uif_attestation()? {
if uif.touch_policy().touch_required() {
(touch_prompt)();
}
}
self.oc.opt.generate_attestation(key_type) self.oc.opt.generate_attestation(key_type)
} }
} }

View file

@ -115,7 +115,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
return Err(anyhow!("Unexpected Key Type {}", key).into()); return Err(anyhow!("Unexpected Key Type {}", key).into());
} }
}; };
sign.generate_attestation(kt)?; sign.generate_attestation(kt, &|| {
println!("Touch confirmation needed to generate an attestation")
})?;
} }
cli::AttCommand::Statement { ident, key } => { cli::AttCommand::Statement { ident, key } => {
let mut card = pick_card_for_reading(ident)?; let mut card = pick_card_for_reading(ident)?;