doc
This commit is contained in:
parent
ae96d3ba5d
commit
24a06b9085
@ -87,9 +87,9 @@ pub fn extend_creds_device(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_password_pin_prefixed(
|
pub fn read_password_pin_prefixed(
|
||||||
reader: impl Fn() -> Fido2LuksResult<String>,
|
prefixed: impl Fn() -> Fido2LuksResult<String>,
|
||||||
) -> Fido2LuksResult<(Option<String>, [u8; 32])> {
|
) -> Fido2LuksResult<(Option<String>, [u8; 32])> {
|
||||||
let read = reader()?;
|
let read = prefixed()?;
|
||||||
let separator = ':';
|
let separator = ':';
|
||||||
let mut parts = read.split(separator);
|
let mut parts = read.split(separator);
|
||||||
let pin = parts.next().filter(|p| p.len() > 0).map(|p| p.to_string());
|
let pin = parts.next().filter(|p| p.len() > 0).map(|p| p.to_string());
|
||||||
@ -601,14 +601,17 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_read_password_pin_prefixed() {
|
fn test_read_password_pin_prefixed() {
|
||||||
|
// 1234:test -> PIN: 1234, password: test
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
read_password_pin_prefixed(|| Ok("1234:test".into())).unwrap(),
|
read_password_pin_prefixed(|| Ok("1234:test".into())).unwrap(),
|
||||||
(Some("1234".to_string()), util::sha256(&["test".as_bytes()]))
|
(Some("1234".to_string()), util::sha256(&["test".as_bytes()]))
|
||||||
);
|
);
|
||||||
|
// :test -> PIN: None, password: test
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
read_password_pin_prefixed(|| Ok(":test".into())).unwrap(),
|
read_password_pin_prefixed(|| Ok(":test".into())).unwrap(),
|
||||||
(None, util::sha256(&["test".as_bytes()]))
|
(None, util::sha256(&["test".as_bytes()]))
|
||||||
);
|
);
|
||||||
|
// 1234::test -> PIN: 1234, password: :test
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
read_password_pin_prefixed(|| Ok("1234::test".into())).unwrap(),
|
read_password_pin_prefixed(|| Ok("1234::test".into())).unwrap(),
|
||||||
(
|
(
|
||||||
@ -616,10 +619,12 @@ mod test {
|
|||||||
util::sha256(&[":test".as_bytes()])
|
util::sha256(&[":test".as_bytes()])
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
// 1234 -> PIN: 1234, password: empty
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
read_password_pin_prefixed(|| Ok("1234".into())).unwrap(),
|
read_password_pin_prefixed(|| Ok("1234".into())).unwrap(),
|
||||||
(Some("1234".to_string()), util::sha256(&["".as_bytes()]))
|
(Some("1234".to_string()), util::sha256(&["".as_bytes()]))
|
||||||
);
|
);
|
||||||
|
// 1234:test -> PIN: None, password: test
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
read_password_pin_prefixed(|| Ok(":test".into())).unwrap(),
|
read_password_pin_prefixed(|| Ok(":test".into())).unwrap(),
|
||||||
(None, util::sha256(&["test".as_bytes()]))
|
(None, util::sha256(&["test".as_bytes()]))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user