Skip to content

Commit

Permalink
key deletion: delete first the faster volatile storage and test publi…
Browse files Browse the repository at this point in the history
…c keys first

Most key deletions are for volatile public keys (temporary keys for FIDO pin protocol, PIN keys from trussed-auth etc...).
In any cases, persistent keys are more rarely deleted, and volatile is the fastest storage,
so it being first is overall a performance improvement.

I think long term (once we have the builder-pattern based syscall implementation maybe?)
we should add optional location and secrecy arguments to the syscall. It is rare that the caller
would not know the kind of key it is deleting.
  • Loading branch information
sosthene-nitrokey committed Aug 5, 2024
1 parent 8b8beee commit 3e03100
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/store/keystore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ impl<S: Store> Keystore for ClientKeystore<S> {

// TODO: is this an Oracle?
fn delete_key(&self, id: &KeyId) -> bool {
let secrecies = [key::Secrecy::Secret, key::Secrecy::Public];
let secrecies = [key::Secrecy::Public, key::Secrecy::Secret];

let locations = [Location::Internal, Location::External, Location::Volatile];
let locations = [Location::Volatile, Location::Internal, Location::External];

secrecies.iter().any(|secrecy| {
let path = self.key_path(*secrecy, id);
locations
.iter()
.any(|location| store::delete(self.store, *location, &path))
locations.iter().any(|location| {
secrecies.iter().any(|secrecy| {
let path = self.key_path(*secrecy, id);
store::delete(self.store, *location, &path)
})
})
}

Expand Down

0 comments on commit 3e03100

Please sign in to comment.