From fbdb9e87b2f44b2c402de754787d176b09da5207 Mon Sep 17 00:00:00 2001 From: Heiko Schaefer Date: Thu, 21 Apr 2022 13:21:19 +0200 Subject: [PATCH] Adjust openpgp-card-sequoia API to take resetting code as &[u8] instead of &str. --- openpgp-card-sequoia/src/card.rs | 8 ++++---- tools/src/bin/opgpcard-pin/main.rs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/openpgp-card-sequoia/src/card.rs b/openpgp-card-sequoia/src/card.rs index 66bf735..3b2879f 100644 --- a/openpgp-card-sequoia/src/card.rs +++ b/openpgp-card-sequoia/src/card.rs @@ -395,12 +395,12 @@ impl Admin<'_, '_> { } } - pub fn set_resetting_code(&mut self, pin: &str) -> Result<(), Error> { - self.oc.opt.set_resetting_code(pin.as_bytes()) + pub fn set_resetting_code(&mut self, pin: &[u8]) -> Result<(), Error> { + self.oc.opt.set_resetting_code(pin) } - pub fn reset_user_pin(&mut self, new: &str) -> Result<(), Error> { - self.oc.opt.reset_retry_counter_pw1(new.as_bytes(), None) + pub fn reset_user_pin(&mut self, new: &[u8]) -> Result<(), Error> { + self.oc.opt.reset_retry_counter_pw1(new, None) } /// Upload a ValidErasedKeyAmalgamation to the card as a specific KeyType. diff --git a/tools/src/bin/opgpcard-pin/main.rs b/tools/src/bin/opgpcard-pin/main.rs index cf90e06..b2f31b4 100644 --- a/tools/src/bin/opgpcard-pin/main.rs +++ b/tools/src/bin/opgpcard-pin/main.rs @@ -114,7 +114,7 @@ fn main() -> Result<(), Box> { rpassword::read_password_from_tty(Some("Repeat the new resetting code: "))?; if newpin1 == newpin2 { - admin.set_resetting_code(&newpin1)?; + admin.set_resetting_code(newpin1.as_bytes())?; } else { return Err(anyhow::anyhow!("PINs do not match.").into()); } @@ -162,7 +162,7 @@ fn main() -> Result<(), Box> { // reset to new user pin open.reset_user_pin(rst.as_bytes(), newpin1.as_bytes()) } else if let Some(mut admin) = open.admin_card() { - admin.reset_user_pin(&newpin1) + admin.reset_user_pin(newpin1.as_bytes()) } else { return Err(anyhow::anyhow!("Failed to use card in admin-mode.").into()); };