From c0088c4eae0b74eb8c70ec8364d8fc0ccf7aa11c Mon Sep 17 00:00:00 2001 From: Heiko Schaefer Date: Mon, 20 Sep 2021 20:36:37 +0200 Subject: [PATCH] Hack for SmartPGP applet (use the last of the suitable algorithm variants from the Algorithm Information list). --- openpgp-card/src/keys.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openpgp-card/src/keys.rs b/openpgp-card/src/keys.rs index 18987de..4ed766a 100644 --- a/openpgp-card/src/keys.rs +++ b/openpgp-card/src/keys.rs @@ -320,7 +320,10 @@ fn get_card_algo_rsa( // Did we find a suitable algorithm entry? if !algo.is_empty() { - Ok((*algo[0]).clone()) + // HACK: The SmartPGP applet reports two variants of RSA (import + // format 1 and 3), but in fact only supports the second variant. + // Using the last option happens to work better, in that case. + Ok((**algo.last().unwrap()).clone()) } else { // RSA with this bit length is not in algo_list return Err(anyhow!(