Implement CA Fingerprints

This commit is contained in:
Heiko Schaefer 2022-04-22 15:21:42 +02:00
parent 20ebac295d
commit 67e9f9b9a0
No known key found for this signature in database
GPG key ID: 4A849A1904CCBD7D
2 changed files with 40 additions and 9 deletions

View file

@ -150,11 +150,22 @@ impl ApplicationRelatedData {
} }
} }
// FIXME pub fn ca_fingerprints(&self) -> Result<[Option<Fingerprint>; 3], Error> {
// #[allow(dead_code)] let fp = self.0.find(&[0xc6].into());
// fn ca_fingerprints() {
// unimplemented!() if let Some(fp) = fp {
// } // FIXME: using a KeySet is a weird hack
let fp: KeySet<Fingerprint> = (&fp.serialize()[..]).try_into()?;
let fp = [fp.signature, fp.decryption, fp.authentication];
log::trace!("CA Fp: {:x?}", fp);
Ok(fp)
} else {
Err(Error::NotFound("Failed to get CA fingerprints.".into()))
}
}
/// Generation dates/times of key pairs /// Generation dates/times of key pairs
pub fn key_generation_times(&self) -> Result<KeySet<KeyGenerationTime>, crate::Error> { pub fn key_generation_times(&self) -> Result<KeySet<KeyGenerationTime>, crate::Error> {
@ -173,10 +184,9 @@ impl ApplicationRelatedData {
} }
} }
// #[allow(dead_code)] fn key_information() {
// fn key_information() { unimplemented!()
// unimplemented!() }
// }
pub fn uif_pso_cds(&self) -> Result<Option<UIF>, Error> { pub fn uif_pso_cds(&self) -> Result<Option<UIF>, Error> {
let uif = self.0.find(&[0xd6].into()); let uif = self.0.find(&[0xd6].into());

View file

@ -660,6 +660,27 @@ impl<'a> OpenPgpTransaction<'a> {
apdu::send_command(self.tx(), fp_cmd, false)?.try_into() apdu::send_command(self.tx(), fp_cmd, false)?.try_into()
} }
pub fn set_ca_fingerprint_1(&mut self, fp: Fingerprint) -> Result<(), Error> {
log::info!("OpenPgpTransaction: set_ca_fingerprint_1");
let fp_cmd = commands::put_data(&[0xCA], fp.as_bytes().to_vec());
apdu::send_command(self.tx(), fp_cmd, false)?.try_into()
}
pub fn set_ca_fingerprint_2(&mut self, fp: Fingerprint) -> Result<(), Error> {
log::info!("OpenPgpTransaction: set_ca_fingerprint_2");
let fp_cmd = commands::put_data(&[0xCB], fp.as_bytes().to_vec());
apdu::send_command(self.tx(), fp_cmd, false)?.try_into()
}
pub fn set_ca_fingerprint_3(&mut self, fp: Fingerprint) -> Result<(), Error> {
log::info!("OpenPgpTransaction: set_ca_fingerprint_3");
let fp_cmd = commands::put_data(&[0xCC], fp.as_bytes().to_vec());
apdu::send_command(self.tx(), fp_cmd, false)?.try_into()
}
/// Set PW Status Bytes. /// Set PW Status Bytes.
/// ///
/// If `long` is false, send 1 byte to the card, otherwise 4. /// If `long` is false, send 1 byte to the card, otherwise 4.