openpgp-card-sequoia: Login Data is a binary field
This commit is contained in:
parent
1de083e1b8
commit
f7936a75fd
2 changed files with 12 additions and 7 deletions
|
@ -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![])
|
||||
}
|
||||
|
|
|
@ -555,9 +555,14 @@ impl<'a> Card<Transaction<'a>> {
|
|||
|
||||
// --- optional private DOs (0101 - 0104) ---
|
||||
|
||||
// --- login data (5e) ---
|
||||
pub fn login_data(&mut self) -> Result<String, Error> {
|
||||
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<Vec<u8>, Error> {
|
||||
self.state.opt.login_data()
|
||||
}
|
||||
|
||||
// --- URL (5f50) ---
|
||||
|
@ -893,8 +898,8 @@ impl Card<Admin<'_, '_>> {
|
|||
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.
|
||||
|
|
Loading…
Reference in a new issue