From 3407cd3a39e72a6bb141de7d0758a859046cccd7 Mon Sep 17 00:00:00 2001 From: Heiko Schaefer Date: Tue, 26 Oct 2021 21:56:22 +0200 Subject: [PATCH] Add reset_user_pin() fn for Open and for Admin, as well as set_resetting_code() to Admin. --- openpgp-card-sequoia/src/card.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/openpgp-card-sequoia/src/card.rs b/openpgp-card-sequoia/src/card.rs index 22227ff..8262c4b 100644 --- a/openpgp-card-sequoia/src/card.rs +++ b/openpgp-card-sequoia/src/card.rs @@ -113,6 +113,15 @@ impl Open { self.card_app.change_pw1(old, new) } + pub fn reset_user_pin( + &mut self, + rst: &str, + new: &str, + ) -> Result { + self.card_app + .reset_retry_counter_pw1(new.into(), Some(rst.into())) + } + pub fn change_admin_pin( &mut self, old: &str, @@ -364,6 +373,17 @@ impl Admin<'_> { } } + pub fn set_resetting_code( + &mut self, + pin: &str, + ) -> Result { + self.oc.card_app.set_resetting_code(pin.into()) + } + + pub fn reset_user_pin(&mut self, new: &str) -> Result { + self.oc.card_app.reset_retry_counter_pw1(new.into(), None) + } + /// Upload a ValidErasedKeyAmalgamation to the card as a specific KeyType. /// /// (The caller needs to make sure that `vka` is suitable as `key_type`)