De-duplicate parsing recipients from SubjectPublicKeyInfo

This commit is contained in:
Jack Grigg
2022-12-31 12:49:44 +00:00
parent d4f8993988
commit 493479344c
4 changed files with 38 additions and 42 deletions
+4 -5
View File
@@ -15,7 +15,7 @@ use std::iter;
use std::thread::sleep;
use std::time::{Duration, Instant, SystemTime};
use yubikey::{
certificate::{Certificate, PublicKeyInfo},
certificate::Certificate,
piv::{decrypt_data, AlgorithmId, RetiredSlotId, SlotId},
reader::{Context, Reader},
MgmKey, PinPolicy, Serial, TouchPolicy, YubiKey,
@@ -459,11 +459,10 @@ impl Stub {
// Read the pubkey from the YubiKey slot and check it still matches.
let (cert, pk) = match Certificate::read(&mut yubikey, SlotId::Retired(self.slot))
.ok()
.and_then(|cert| match cert.subject_pki() {
PublicKeyInfo::EcP256(pubkey) => Recipient::from_encoded(pubkey)
.and_then(|cert| {
Recipient::from_certificate(&cert)
.filter(|pk| pk.tag() == self.tag)
.map(|pk| (cert, pk)),
_ => None,
.map(|pk| (cert, pk))
}) {
Some(pk) => pk,
None => {