diff --git a/card-functionality/src/tests.rs b/card-functionality/src/tests.rs index e7561e6..8fa01d3 100644 --- a/card-functionality/src/tests.rs +++ b/card-functionality/src/tests.rs @@ -357,12 +357,12 @@ pub fn test_set_login_data( let mut admin = tx.to_admin_card("12345678")?; let test_login = "someone@somewhere.com"; - admin.set_login_data(test_login)?; + admin.set_login_data(test_login.as_bytes())?; // Read the previously set login data let read_login_data = tx.login_data()?; - assert_eq!(read_login_data, test_login); + assert_eq!(&read_login_data, test_login.as_bytes()); Ok(vec![]) } diff --git a/openpgp-card-sequoia/src/lib.rs b/openpgp-card-sequoia/src/lib.rs index 3c27656..07c7298 100644 --- a/openpgp-card-sequoia/src/lib.rs +++ b/openpgp-card-sequoia/src/lib.rs @@ -555,9 +555,14 @@ impl<'a> Card> { // --- optional private DOs (0101 - 0104) --- - // --- login data (5e) --- - pub fn login_data(&mut self) -> Result { - Ok(String::from_utf8_lossy(&self.state.opt.login_data()?).to_string()) + /// Login Data + /// + /// This DO can be used to store any information used for the Log-In + /// process in a client/server authentication (e.g. user name of a + /// network). + /// The maximum length of this DO is announced in Extended Capabilities. + pub fn login_data(&mut self) -> Result, Error> { + self.state.opt.login_data() } // --- URL (5f50) --- @@ -893,8 +898,8 @@ impl Card> { self.card().set_sex(sex) } - pub fn set_login_data(&mut self, login_data: &str) -> Result<(), Error> { - self.card().set_login(login_data.as_bytes()) + pub fn set_login_data(&mut self, login_data: &[u8]) -> Result<(), Error> { + self.card().set_login(login_data) } /// Set "hardholder" URL on the card.