Add PrivateKey object for signing, only - #111
Conversation
|
Thank you @mandelsoft for your proposition, this is indeed a better approach for private keys in KMS. |
solcates
left a comment
There was a problem hiding this comment.
Looks good and safe to me. Thanks for the contribution.
|
However, the code is still in @mandelsoft can you fix this ? |
The four FindPrivateKey* methods have had no direct test coverage since they landed in #115 — the only exercise was one FindRSAPrivateKey subtest in rsa_test.go, which touches neither attribute matching nor argument validation. Port the tests proposed in PR #111, adapted to this branch's cryptoki binding: - TestFindKeysRequiresIdOrLabel gains assertions that FindPrivateKey and FindPrivateKeys reject a nil id *and* nil label. - TestFindingPrivateKeysWithAttributes covers matching on CkaLabel (single and shared) and filtering on CkaKeyType. Also add TestFindingPrivateKeyNotFound, which is not from #111. It pins the current not-found behaviour, where the singular lookups return an error while the plural ones return an empty slice. Note that this contradicts the doc comments on FindPrivateKey and FindPrivateKeyWithAttributes, which still promise "or nil if it cannot be found"; the test documents what the code does today rather than asserting it is correct. The tests are unchanged in intent from mandelsoft's original, which proposed them alongside a PrivateKey implementation that #115 has since superseded. #111 Co-Authored-By: Uwe Krueger <553075+mandelsoft@users.noreply.github.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Thanks for this, @mandelsoft — and apologies it sat open so long. In 2026 the big project for crypto11 is to add the support of PKCS#11 v3.2 and the support of the ML-KEM PQC algorithm:
The other big project for 2026 is giving + moving the crypto11 project under the Eclipse Foundation. So this is an opportunity to look back at PR and issues, like yours. Closing #111 as superseded by #115:
It also adds Two differences from your version, in the interest of full disclosure:
So we added your tests on 62bbca8 and we mention you as contributor. This targets The implementation is redundant now, but you framed the problem first and the result matches your proposal. |
Proposed Changes
Fully implementing
rsa.Signerrequires a private and public key. But if only signing is required, the private key would besufficient. Currently, the public key must be present and both must have the same Id. If one of those constraints is not satisfied signing with the private key is not possible.
Types of Changes
New Feature: introduce interface
PrivateKeywith sole signing method and provide appropriate context methods to find private keys.Verification
Create keys without Id and use new FindPrivateKey method flavors.
Testing
Tests are added.
Linked Issues
User-Facing Change
Further Comments