Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions src/authenticator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,10 @@ where
path
}

fn user_present(&mut self) -> Result {
syscall!(self.trussed.confirm_user_present(15000)).result.map_err(|_| Status::ConditionsOfUseNotSatisfied)
}

// 71 <- Tag::Name
// 12
// 74 6F 74 70 2E 64 61 6E 68 65 72 73 61 6D 2E 63 6F 6D
Expand All @@ -436,12 +440,22 @@ where
None
)).data;

let mut touch_result: Option<Result> = None;

while let Some(serialized_credential) = maybe_credential {
// info_now!("serialized credential: {}", hex_str!(&serialized_credential));
// check if there's more
maybe_credential = syscall!(self.trussed.read_dir_files_next()).data;

// deserialize
let credential: Credential = postcard_deserialize(&serialized_credential).unwrap();

if credential.touch_required {
let result = touch_result.get_or_insert_with(|| self.user_present());
if result.is_err() {
continue;
}
}

// add to response
reply.push(0x71).unwrap();
reply.push(credential.label.len() as u8).unwrap();
Expand All @@ -463,9 +477,6 @@ where
reply.push(0x77).unwrap();
reply.push(0).unwrap();
};

// check if there's more
maybe_credential = syscall!(self.trussed.read_dir_files_next()).data;
}

// ran to completion
Expand All @@ -481,6 +492,10 @@ where

let mut credential = self.load_credential(&calculate.label).ok_or(Status::NotFound)?;

if credential.touch_required {
self.user_present()?
}

let truncated_digest = match credential.kind {
oath::Kind::Totp => crate::calculate::calculate(
&mut self.trussed,
Expand Down