From 4181c2d66c1cca197b40100c57d6770ada46bea2 Mon Sep 17 00:00:00 2001 From: Heiko Schaefer Date: Mon, 17 Oct 2022 15:15:11 +0200 Subject: [PATCH] Clean up error handing for unexpected length of 'Digital signature counter' DO --- openpgp-card/src/openpgp.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/openpgp-card/src/openpgp.rs b/openpgp-card/src/openpgp.rs index d3026be..c69374f 100644 --- a/openpgp-card/src/openpgp.rs +++ b/openpgp-card/src/openpgp.rs @@ -128,7 +128,12 @@ impl<'a> OpenPgpTransaction<'a> { if let Value::S(data) = res { let mut data = data.to_vec(); - assert_eq!(data.len(), 3); + if data.len() != 3 { + return Err(Error::ParseError(format!( + "Unexpected length {} for 'Digital signature counter' DO", + data.len() + ))); + } data.insert(0, 0); // prepend a zero let data: [u8; 4] = data.try_into().unwrap();