Remove asserts for password lengths (running the command and returning the card's error, if any, seems more appropriate)

This commit is contained in:
Heiko Schaefer 2021-09-06 12:27:44 +02:00
parent ad929598ce
commit 5ccd6be1bb

View file

@ -295,9 +295,6 @@ impl CardApp {
let resp = apdu::send_command(&mut self.card_client, act, false)?; let resp = apdu::send_command(&mut self.card_client, act, false)?;
resp.check_ok()?; resp.check_ok()?;
// FIXME: does the connection need to be re-opened on some cards,
// after reset?!
Ok(()) Ok(())
} }
@ -311,8 +308,6 @@ impl CardApp {
&mut self, &mut self,
pin: &str, pin: &str,
) -> Result<Response, Error> { ) -> Result<Response, Error> {
assert!(pin.len() >= 6); // FIXME: Err
let verify = commands::verify_pw1_81(pin.as_bytes().to_vec()); let verify = commands::verify_pw1_81(pin.as_bytes().to_vec());
apdu::send_command(&mut self.card_client, verify, false)?.try_into() apdu::send_command(&mut self.card_client, verify, false)?.try_into()
} }
@ -331,8 +326,6 @@ impl CardApp {
/// Verify PW1 (user) and set an appropriate access status. /// Verify PW1 (user) and set an appropriate access status.
/// (For operations except signing, mode 82). /// (For operations except signing, mode 82).
pub fn verify_pw1(&mut self, pin: &str) -> Result<Response, Error> { pub fn verify_pw1(&mut self, pin: &str) -> Result<Response, Error> {
assert!(pin.len() >= 6); // FIXME: Err
let verify = commands::verify_pw1_82(pin.as_bytes().to_vec()); let verify = commands::verify_pw1_82(pin.as_bytes().to_vec());
apdu::send_command(&mut self.card_client, verify, false)?.try_into() apdu::send_command(&mut self.card_client, verify, false)?.try_into()
} }
@ -351,8 +344,6 @@ impl CardApp {
/// Verify PW3 (admin) and set an appropriate access status. /// Verify PW3 (admin) and set an appropriate access status.
pub fn verify_pw3(&mut self, pin: &str) -> Result<Response, Error> { pub fn verify_pw3(&mut self, pin: &str) -> Result<Response, Error> {
assert!(pin.len() >= 8); // FIXME: Err
let verify = commands::verify_pw3(pin.as_bytes().to_vec()); let verify = commands::verify_pw3(pin.as_bytes().to_vec());
apdu::send_command(&mut self.card_client, verify, false)?.try_into() apdu::send_command(&mut self.card_client, verify, false)?.try_into()
} }