PrivateKey and PublicKey objects missing sign/verify with NetHSM PKCS#11 backend
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 170
- Forks
- 79
- PR merge metrics
- No merged PRs in 30d
Description
When using python-pkcs11 with a NetHSM PKCS#11 backend, PrivateKey and PublicKey objects retrieved via session.get_key() do not expose sign or verify at runtime, despite SignMixin and VerifyMixin existing in the type hierarchy.
Steps to Reproduce
import pkcs11
lib = pkcs11.lib("/path/to/nethsm-pkcs11.so")
token = lib.get_token(token_label="mytoken")
with token.open(user_pin="mypin") as session:
private_key = session.get_key(object_class=pkcs11.ObjectClass.PRIVATE_KEY, label="mykey")
private_key.sign(b"hello", mechanism=pkcs11.Mechanism.SHA256_RSA_PKCS_PSS)
Expected Behavior
PrivateKey objects returned by session.get_key() should support .sign() and PublicKey objects should support .verify(), consistent with how other backends (e.g. SoftHSM2) behave.
Actual Behavior
private_key.sign(digest, mechanism=mechanism, mechanism_param=mechanism_param)
^^^^^^^^^^^^^^^^
AttributeError: 'PrivateKey' object has no attribute 'sign'
public_key.verify(digest, signature, mechanism=mechanism, mechanism_param=mechanism_param)
^^^^^^^^^^^^^^^^^
AttributeError: 'PublicKey' object has no attribute 'verify'
Environment
- python-pkcs11: v0.9.4
- OS: Windows 11
- PKCS#11 backend: NetHSM v2.1.0 x86_64
Contributor guide
No contributing guide indexed for this repository
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.
Research direction
Start at session.get_key() and inspect how retrieved PrivateKey and PublicKey objects relate to the existing SignMixin and VerifyMixin. Reproduce the NetHSM behavior from the issue, then verify that retrieved keys expose sign() and verify() consistently with the expected backend behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend-api-design, cryptography
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100