diff --git a/card-functionality/src/tests.rs b/card-functionality/src/tests.rs index e9c1293..f79cc68 100644 --- a/card-functionality/src/tests.rs +++ b/card-functionality/src/tests.rs @@ -62,7 +62,7 @@ pub fn test_decrypt(card: &mut dyn CardBackend, param: &[&str]) -> Result Result Result { @@ -564,7 +564,7 @@ pub fn test_change_pw( // ca.change_pw1("123456", "abcdef")?; println!("verify bad pw1"); - match pgpt.verify_pw1(b"123456ab") { + match pgpt.verify_pw1_user(b"123456ab") { Err(Error::CardStatus(StatusBytes::SecurityStatusNotSatisfied)) => { // this is expected } @@ -575,7 +575,7 @@ pub fn test_change_pw( } println!("verify good pw1"); - pgpt.verify_pw1(b"abcdef")?; + pgpt.verify_pw1_user(b"abcdef")?; println!("verify bad pw3"); match pgpt.verify_pw3(b"00000000") { @@ -616,10 +616,10 @@ pub fn test_reset_retry_counter( pgpt.change_pw1(b"123456", b"123456")?; println!("break pw1"); - let _ = pgpt.verify_pw1(b"wrong0"); - let _ = pgpt.verify_pw1(b"wrong0"); - let _ = pgpt.verify_pw1(b"wrong0"); - let res = pgpt.verify_pw1(b"wrong0"); + let _ = pgpt.verify_pw1_user(b"wrong0"); + let _ = pgpt.verify_pw1_user(b"wrong0"); + let _ = pgpt.verify_pw1_user(b"wrong0"); + let res = pgpt.verify_pw1_user(b"wrong0"); match res { Err(Error::CardStatus(StatusBytes::AuthenticationMethodBlocked)) => { @@ -648,10 +648,10 @@ pub fn test_reset_retry_counter( let _res = pgpt.reset_retry_counter_pw1(b"abcdef", Some(b"abcdefgh")); println!("verify good pw1"); - pgpt.verify_pw1(b"abcdef")?; + pgpt.verify_pw1_user(b"abcdef")?; println!("verify bad pw1"); - match pgpt.verify_pw1(b"00000000") { + match pgpt.verify_pw1_user(b"00000000") { Err(Error::CardStatus(StatusBytes::SecurityStatusNotSatisfied)) => { // this is expected } diff --git a/openpgp-card-sequoia/src/card.rs b/openpgp-card-sequoia/src/card.rs index 7212b83..a475688 100644 --- a/openpgp-card-sequoia/src/card.rs +++ b/openpgp-card-sequoia/src/card.rs @@ -65,7 +65,7 @@ impl<'a> Open<'a> { } pub fn verify_user(&mut self, pin: &str) -> Result<(), Error> { - let _ = self.opt.verify_pw1(pin.as_bytes())?; + let _ = self.opt.verify_pw1_user(pin.as_bytes())?; self.pw1 = true; Ok(()) } @@ -73,13 +73,13 @@ impl<'a> Open<'a> { pub fn verify_user_pinpad(&mut self, prompt: &dyn Fn()) -> Result<(), Error> { prompt(); - let _ = self.opt.verify_pw1_pinpad()?; + let _ = self.opt.verify_pw1_user_pinpad()?; self.pw1 = true; Ok(()) } pub fn verify_user_for_signing(&mut self, pin: &str) -> Result<(), Error> { - let _ = self.opt.verify_pw1_for_signing(pin.as_bytes())?; + let _ = self.opt.verify_pw1_sign(pin.as_bytes())?; // FIXME: depending on card mode, pw1_sign is only usable once @@ -90,7 +90,7 @@ impl<'a> Open<'a> { pub fn verify_user_for_signing_pinpad(&mut self, prompt: &dyn Fn()) -> Result<(), Error> { prompt(); - let _ = self.opt.verify_pw1_for_signing_pinpad()?; + let _ = self.opt.verify_pw1_sign_pinpad()?; // FIXME: depending on card mode, pw1_sign is only usable once @@ -116,7 +116,7 @@ impl<'a> Open<'a> { /// /// NOTE: on some cards this functionality seems broken. pub fn check_user_verified(&mut self) -> Result<(), Error> { - self.opt.check_pw1() + self.opt.check_pw1_user() } /// Ask the card if the admin password has been successfully verified. diff --git a/openpgp-card/src/openpgp.rs b/openpgp-card/src/openpgp.rs index 6a88bf3..328129a 100644 --- a/openpgp-card/src/openpgp.rs +++ b/openpgp-card/src/openpgp.rs @@ -313,7 +313,7 @@ impl<'a> OpenPgpTransaction<'a> { /// Depending on the PW1 status byte (see Extended Capabilities) this /// access condition is only valid for one PSO:CDS command or remains /// valid for several attempts. - pub fn verify_pw1_for_signing(&mut self, pin: &[u8]) -> Result<(), Error> { + pub fn verify_pw1_sign(&mut self, pin: &[u8]) -> Result<(), Error> { let verify = commands::verify_pw1_81(pin.to_vec()); apdu::send_command(self.tx(), verify, false)?.try_into() } @@ -325,7 +325,7 @@ impl<'a> OpenPgpTransaction<'a> { /// Depending on the PW1 status byte (see Extended Capabilities) this /// access condition is only valid for one PSO:CDS command or remains /// valid for several attempts. - pub fn verify_pw1_for_signing_pinpad(&mut self) -> Result<(), Error> { + pub fn verify_pw1_sign_pinpad(&mut self) -> Result<(), Error> { let res = self.tx().pinpad_verify(PinType::Sign)?; RawResponse::try_from(res)?.try_into() } @@ -338,14 +338,14 @@ impl<'a> OpenPgpTransaction<'a> { /// - some cards don't correctly implement this feature, e.g. YubiKey 5 /// - some cards that don't support this instruction may decrease the pin's error count, /// eventually requiring the user to reset the pin) - pub fn check_pw1_for_signing(&mut self) -> Result<(), Error> { + pub fn check_pw1_sign(&mut self) -> Result<(), Error> { let verify = commands::verify_pw1_81(vec![]); apdu::send_command(self.tx(), verify, false)?.try_into() } /// Verify PW1 (user). /// (For operations except signing, mode 82). - pub fn verify_pw1(&mut self, pin: &[u8]) -> Result<(), Error> { + pub fn verify_pw1_user(&mut self, pin: &[u8]) -> Result<(), Error> { let verify = commands::verify_pw1_82(pin.to_vec()); apdu::send_command(self.tx(), verify, false)?.try_into() } @@ -354,7 +354,7 @@ impl<'a> OpenPgpTransaction<'a> { /// using a pinpad on the card reader. If no usable pinpad is found, /// an error is returned. - pub fn verify_pw1_pinpad(&mut self) -> Result<(), Error> { + pub fn verify_pw1_user_pinpad(&mut self) -> Result<(), Error> { let res = self.tx().pinpad_verify(PinType::User)?; RawResponse::try_from(res)?.try_into() } @@ -368,7 +368,7 @@ impl<'a> OpenPgpTransaction<'a> { /// - some cards don't correctly implement this feature, e.g. YubiKey 5 /// - some cards that don't support this instruction may decrease the pin's error count, /// eventually requiring the user to reset the pin) - pub fn check_pw1(&mut self) -> Result<(), Error> { + pub fn check_pw1_user(&mut self) -> Result<(), Error> { let verify = commands::verify_pw1_82(vec![]); apdu::send_command(self.tx(), verify, false)?.try_into() }