Backends can only return a single public/private key from calls to Backend::find_(private|public)_key()
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- rust
- Domain
- backend-api-design, cryptography
Research direction
Start in native-pkcs11-traits/src/lib.rs at the Backend trait and the find_private_key() and find_public_key() methods. Trace their implementations and how FindObject populates and filters object_store. Done means key searches can return all matching public or private keys consistently, including when the store was not previously populated.
Written by the indexing model from the issue text.
Description
FindObject returns a list of objects, see https://github.com/google/native-pkcs11/blob/main/native-pkcs11-traits/src/lib.rs#L191. This is done in 2 stages, firstly call the backend to populate the object_store, then apply a filter to the object store to return requested objects.
However, the Backend trait only returns a single object from the find_(private|public)_key() methods.
https://github.com/google/native-pkcs11/blob/main/native-pkcs11-traits/src/lib.rs#L191
pub trait Backend: Send + Sync {
fn name(&self) -> String;
fn find_all_certificates(&self) -> Result<Vec<Box<dyn Certificate>>>;
fn find_private_key(&self, query: KeySearchOptions) -> Result<Option<Arc<dyn PrivateKey>>>;
fn find_public_key(&self, query: KeySearchOptions) -> Result<Option<Box<dyn PublicKey>>>;
fn find_all_private_keys(&self) -> Result<Vec<Arc<dyn PrivateKey>>>;
fn find_all_public_keys(&self) -> Result<Vec<Arc<dyn PublicKey>>>;
This means that a find for a public or private key will only return a single object.
However, to make this more confusing, if a caller has already requested all keys (via find_all_private_keys() or find_all_public_keys() , then multiple keys may be returned, as these methods populate the object_store with all objects.
A suggested fix is to change the find_private_key() and find_public_key() methods to return a Vec<>, as per the find_all_*() methods.
- Dominant language
- Rust
- Stars
- 75
- Forks
- 25
- Avg merge
- 14h 16m
- Merged PRs (30d)
- 1
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from google/native-pkcs11
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
google/native-pkcs11#492 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
google/native-pkcs11#470 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
google/native-pkcs11#445 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 52/100
google/native-pkcs11#392 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
google/native-pkcs11#303 ·
All issues in google/native-pkcs11
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Test connection's password prompt says the password is never saved, also for a keychain profileOpenbug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
area: settings bug Haiku review: no-score ui
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
MMFoundation/WallpaperMachine#346 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
rubys/roundhouse#2473 ·
-
bug mod: quantum info
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Qiskit/qiskit#17699 · 2 comments ·
Maintainers usually reply within 1 day