keyfork-shard: parse cardholder name when using smartcards
This commit is contained in:
parent
4b4b85931f
commit
0768339487
|
@ -31,6 +31,17 @@ impl std::fmt::Display for SmartcardFailure {
|
|||
|
||||
impl std::error::Error for SmartcardFailure {}
|
||||
|
||||
fn format_name(input: impl AsRef<str>) -> String {
|
||||
let mut n = input
|
||||
.as_ref()
|
||||
.split("<<")
|
||||
.take(2)
|
||||
.map(|s| s.replace('>', " "))
|
||||
.collect::<Vec<_>>();
|
||||
n.reverse();
|
||||
n.join(" ")
|
||||
}
|
||||
|
||||
pub struct SmartcardManager {
|
||||
current_card: Option<Card<Open>>,
|
||||
root: Option<Cert>,
|
||||
|
@ -178,7 +189,7 @@ impl DecryptionHelper for &mut SmartcardManager {
|
|||
let Some(fp) = fp else {
|
||||
return Err(SmartcardFailure::SmartCardHasNoDecrypt.into());
|
||||
};
|
||||
let cardholder_name = transaction.cardholder_name()?;
|
||||
let cardholder_name = format_name(transaction.cardholder_name()?);
|
||||
let card_id = transaction.application_identifier()?.ident();
|
||||
let message = if cardholder_name.is_empty() {
|
||||
format!("Unlock card {card_id}")
|
||||
|
|
Loading…
Reference in New Issue