mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
fix PIN permissions; add support for autotest reset
This commit is contained in:
parent
29b92b7ba4
commit
f1f486e9fb
4 changed files with 22 additions and 8 deletions
|
|
@ -278,13 +278,13 @@ impl<S: Storage> Store<S> {
|
|||
match *update {
|
||||
StoreUpdate::Insert { key, ref value } => {
|
||||
// if it exists, remove the key; if it doesn't exist, ignore the error
|
||||
log::debug!("delete key: {}:{}", crate::store::OPENSK2_DICT, key.to_string());
|
||||
log::debug!("pre-delete key: {}:{}", crate::store::OPENSK2_DICT, key.to_string());
|
||||
self.pddb.delete_key(
|
||||
crate::store::OPENSK2_DICT,
|
||||
&key.to_string(),
|
||||
None
|
||||
).ok();
|
||||
log::debug!("access key: {}:{}", crate::store::OPENSK2_DICT, key.to_string());
|
||||
log::debug!("write key: {}:{}", crate::store::OPENSK2_DICT, key.to_string());
|
||||
match self.pddb.get(
|
||||
crate::store::OPENSK2_DICT,
|
||||
&key.to_string(),
|
||||
|
|
@ -308,11 +308,21 @@ impl<S: Storage> Store<S> {
|
|||
}
|
||||
}
|
||||
StoreUpdate::Remove { key } => {
|
||||
self.pddb.delete_key(
|
||||
log::debug!("remove key: {}:{}", crate::store::OPENSK2_DICT, key.to_string());
|
||||
match self.pddb.delete_key(
|
||||
crate::store::OPENSK2_DICT,
|
||||
&key.to_string(),
|
||||
None
|
||||
).map_err(|_|StoreError::StorageError)?
|
||||
) {
|
||||
Ok(_) => {},
|
||||
Err(e) => match e.kind() {
|
||||
std::io::ErrorKind::NotFound => {},
|
||||
_ => {
|
||||
log::warn!("Encountered error in StorageUpdate::Remove: {:?}", e);
|
||||
return Err(StoreError::StorageError)
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -363,6 +373,7 @@ impl<S: Storage> Store<S> {
|
|||
|
||||
/// Returns the value of an entry given its key.
|
||||
pub fn find(&self, key: usize) -> StoreResult<Option<Vec<u8>>> {
|
||||
log::debug!("find key: {}", key);
|
||||
match self.pddb.get(
|
||||
crate::store::OPENSK2_DICT,
|
||||
&key.to_string(),
|
||||
|
|
@ -453,14 +464,14 @@ impl<S: Storage> Store<S> {
|
|||
let attr = record.attributes().map_err(|_| StoreError::StorageError)?;
|
||||
Ok(attr.len)
|
||||
}
|
||||
_ => Err(StoreError::StorageError)
|
||||
_ => Err(StoreError::InvalidArgument) // key didn't exist
|
||||
}
|
||||
}
|
||||
|
||||
fn get_value(&self, handle: &StoreHandle) -> StoreResult<Vec<u8>> {
|
||||
self.find(
|
||||
handle.key
|
||||
).map(|val| val.ok_or(StoreError::StorageError))?
|
||||
).map(|val| val.ok_or(StoreError::InvalidArgument))?
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1385,6 +1385,7 @@ impl CtapState {
|
|||
env: &mut impl Env,
|
||||
channel: Channel,
|
||||
) -> Result<ResponseData, Ctap2StatusCode> {
|
||||
#[cfg(not(feature="autotest"))]
|
||||
match self.stateful_command_permission.get_command()? {
|
||||
StatefulCommand::Reset => (),
|
||||
_ => return Err(Ctap2StatusCode::CTAP2_ERR_NOT_ALLOWED),
|
||||
|
|
|
|||
4
apps/vault/src/env/xous/mod.rs
vendored
4
apps/vault/src/env/xous/mod.rs
vendored
|
|
@ -433,7 +433,7 @@ impl XousEnv {
|
|||
}
|
||||
Err(_) => panic!("Error sending KEEPALIVE packet"),
|
||||
Ok(SendOrRecvStatus::Sent) => {
|
||||
log::debug!("Sent KEEPALIVE packet");
|
||||
log::trace!("Sent KEEPALIVE packet");
|
||||
}
|
||||
Ok(SendOrRecvStatus::Received) => {
|
||||
// We only parse one packet, because we only care about CANCEL.
|
||||
|
|
@ -478,6 +478,7 @@ impl UserPresence for XousEnv {
|
|||
}
|
||||
/// Implements FIDO behavior (CTAP2 protocol)
|
||||
fn wait_with_timeout(&mut self, timeout: Duration, reason: Option::<String>, cid: [u8; 4]) -> UserPresenceResult {
|
||||
log::info!("{}VAULT.PERMISSION,{}", xous::BOOKEND_START, xous::BOOKEND_END);
|
||||
let reason = reason.unwrap_or(String::new());
|
||||
let kbhit = Arc::new(AtomicU32::new(0));
|
||||
let expiration = Instant::now().checked_add(timeout).expect("duration bug");
|
||||
|
|
@ -511,6 +512,7 @@ impl UserPresence for XousEnv {
|
|||
let mut request_str = String::from(&reason);
|
||||
let remaining = expiration.duration_since(Instant::now()).as_secs();
|
||||
if last_remaining != remaining {
|
||||
log::info!("countdown: {}", remaining);
|
||||
// only update the UX once per second
|
||||
request_str.push_str(
|
||||
&format!("\n\n⚠ {}{} ⚠\n",
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ const ERR_TIMEOUT_MS: usize = 5000;
|
|||
|
||||
fn main() -> ! {
|
||||
log_server::init_wait().unwrap();
|
||||
log::set_max_level(log::LevelFilter::Debug);
|
||||
log::set_max_level(log::LevelFilter::Info);
|
||||
log::info!("my PID is {}", xous::process::id());
|
||||
|
||||
let xns = xous_names::XousNames::new().unwrap();
|
||||
|
|
|
|||
Loading…
Reference in a new issue