From ea8e33b6d5cf194c3185c39a028d1cafa11c600b Mon Sep 17 00:00:00 2001 From: Heiko Schaefer Date: Fri, 27 Aug 2021 19:24:15 +0200 Subject: [PATCH] Return Err for unexpected cases. --- openpgp-card/src/card_app.rs | 4 +++- openpgp-card/src/keys.rs | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/openpgp-card/src/card_app.rs b/openpgp-card/src/card_app.rs index 08e05ce..5d7b34f 100644 --- a/openpgp-card/src/card_app.rs +++ b/openpgp-card/src/card_app.rs @@ -554,7 +554,9 @@ impl CardApp { let data = match algo { Algo::Rsa(rsa) => Self::rsa_algo_attrs(rsa)?, Algo::Ecc(ecc) => Self::ecc_algo_attrs(ecc.oid(), ecc.ecc_type()), - _ => unimplemented!(), + _ => { + return Err(anyhow!("Unexpected Algo {:?}", algo).into()); + } }; // Command to PUT the algorithm attributes diff --git a/openpgp-card/src/keys.rs b/openpgp-card/src/keys.rs index 4481815..11bfb7c 100644 --- a/openpgp-card/src/keys.rs +++ b/openpgp-card/src/keys.rs @@ -88,9 +88,11 @@ fn tlv_to_pubkey(tlv: &Tlv, algo: &Algo) -> Result { Ok(PublicKeyMaterial::E(ecc)) } - (_, _, _) => { - unimplemented!() - } + (_, _, _) => Err(anyhow!( + "Unexpected public key material from card {:?}", + tlv + ) + .into()), } }