Skip to content

Commit

Permalink
fetch_all_keys: Do not filter by kind
Browse files Browse the repository at this point in the history
fetch_all_keys fills a cache. This cache is expected to contain all objects,
not just the kind that was first fetched.
  • Loading branch information
sosthene-nitrokey committed Feb 1, 2024
1 parent a878cfb commit 1defba0
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions pkcs11/src/backend/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ impl Session {
Ok(results)
}

None => self.fetch_all_keys(requirements.kind),
None => self.fetch_all_keys(),
}?;

if let Some(kind) = requirements.kind {
Expand All @@ -485,10 +485,7 @@ impl Session {
Ok(result.iter().map(|(handle, _)| *handle).collect())
}

fn fetch_all_keys(
&mut self,
kind: Option<ObjectKind>,
) -> Result<Vec<(CK_OBJECT_HANDLE, Object)>, Error> {
fn fetch_all_keys(&mut self) -> Result<Vec<(CK_OBJECT_HANDLE, Object)>, Error> {
{
let db = self.db.lock()?;

Expand Down Expand Up @@ -520,11 +517,11 @@ impl Session {
let results: Result<Vec<_>, _> = if THREADS_ALLOWED.load(Ordering::Relaxed) {
use rayon::prelude::*;
keys.par_iter()
.map(|k| super::key::fetch_one(k, &self.db, &self.login_ctx, kind))
.map(|k| super::key::fetch_one(k, &self.db, &self.login_ctx, None))
.collect()
} else {
keys.iter()
.map(|k| super::key::fetch_one(k, &self.db, &self.login_ctx, kind))
.map(|k| super::key::fetch_one(k, &self.db, &self.login_ctx, None))

Check warning on line 524 in pkcs11/src/backend/session.rs

View check run for this annotation

Codecov / codecov/patch

pkcs11/src/backend/session.rs#L524

Added line #L524 was not covered by tests
.collect()
};

Expand Down

0 comments on commit 1defba0

Please sign in to comment.