From 22dd62eeeca7a8eb25d060e9bb2f08b79b31035e Mon Sep 17 00:00:00 2001 From: bunnie Date: Wed, 25 Jan 2023 22:41:03 +0800 Subject: [PATCH] refine the heuristic for detecting keys --- apps/vault/src/actions.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/vault/src/actions.rs b/apps/vault/src/actions.rs index 3f2533bf8..d9c75e056 100644 --- a/apps/vault/src/actions.rs +++ b/apps/vault/src/actions.rs @@ -502,9 +502,15 @@ impl<'a> ActionManager<'a> { if choice.is_none() { // we're dealing with FIDO stuff, use the custom code path - let dictionary = match entry.key_name.as_str().unwrap_or("UTF8-error").parse::() { - Ok(fido_key) => persistent_store::store::OPENSK2_DICT, - Err(_) => U2F_APP_DICT, + let dictionary = match usize::from_str_radix(entry.key_name.as_str().unwrap_or("UTF8-error"), 10) { + Ok(fido_key) => { + if vault::ctap::storage::key::CREDENTIALS.contains(&fido_key) { + persistent_store::store::OPENSK2_DICT // heuristic: all fido2 keys are simple integers + } else { + U2F_APP_DICT + } + } + Err(_) => U2F_APP_DICT, // u2f keys are long hex strings }; match self.pddb.borrow().get(dictionary, entry.key_name.as_str().unwrap_or("UTF8-error"), None, false, false, None, None::