PyKCS11 | PKCS # 11 Wrapper for Python | TLS library
kandi X-RAY | PyKCS11 Summary
kandi X-RAY | PyKCS11 Summary
PKCS#11 Wrapper for Python
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Get the value of an attribute
- Gets the attribute value of an object
- Get information about a specific token
- Return a list of objects matching the specified template
- Convert a template from a template template
- Check if the given type is an attribute list
- Return True if type is a binary type
- Decrypt data using the specified key
- Encrypt data with specified key
- Calculates a signature of the data
- Verify the signature
- Generate a key pair pair
- Return information about a slot
- Returns a list of slots
- Get information about the device
- Generate a random string
- Load a PKCS11 library
- Create a session
- Get information about the session
- Open a session
- Login a pin
- Wait for a slot event
- Dump bytes to string
- Login a user
- Convert flags to text format
- Print information about the mechanism
- Convert flags to text
PyKCS11 Key Features
PyKCS11 Examples and Code Snippets
Community Discussions
Trending Discussions on PyKCS11
QUESTION
I want to sign a Certificate Signing Request using the private key & the certificate stored in the PIV Digital Signature slot.
I'm using the latest release of OpenSC for MacOS(https://github.com/OpenSC/OpenSC/releases/tag/0.19.0).
I have tried the pkcs11-tool, pkcs15-tool & yubikey-piv-tool. All three tools provide a --sign API but they sign a digest generated from the data.
My requirement is to sign the Certificate Signing Request to generate a certificate.
The only option I have is to use the PKCS#11 engine for OpenSSL.
PKCS#11 engine: brew install engine_pkcs11
PKCS#11 Module: opensc-pkcs11.so
I will sign the CSR using the regular OpenSSL commands giving the key & the cert stored on the Yubikey using the engine option.(Probably using the PKCS#11 URI)
Using OpenSSL 1.0.2, I tried the following command.
...ANSWER
Answered 2019-Nov-12 at 01:24Your -CAkey 02
should be -CAkey slot_0-id_2
for slot 9c
/ index 02
on the yubikey, everything else there looks okay (though note there is an issue with pin requirements on slot 9c which may effect you).
For a working example of yubikeys with pkcs#11 you might like to check out https://github.com/ryankurte/pki
Good luck!
QUESTION
I have observed that both the bash command and what is probably a corresponding method from the Python PyKCS11 library seem to always find objects in the same order. My code relies on this being true, but have not read it anywhere, just observed it.
In the terminal:
...ANSWER
Answered 2019-Sep-20 at 21:20(Wanted to write a comment, but it got quite long...)
PKCS#11 does not guarantee any specific order of returned object handles so it is up to the particular implementation.
Even though your implementation might seem to be consistently giving the same order of objects there are some examples when this could unexpectedly change:
key renewal (keys do not last forever. You will need to generate some new keys in the future)
middleware upgrade (newer implementations might return objects in a different order)
HSM firmware upgrade (major upgrades might change the way objects are stored and change object enumeration order)
HSM recovery from backup (object order can change after HSM restore)
host OS data recovery (some implementatins store HSM objects encrypted in external folders and object search order might be the same as directory listing order which could change without a warning)
HSM change (are you sure that you will be using the same device for the whole lifetime of your application)
Relying on an undefined behaviour in general is a bad practice. Especially in security you should be very cautious.
It is definitely worth the time to stay on the safe side.
I would recommend to perform a separate search for each required object (using some strong identifier -- e.g. label) -- this way you can perform additional checks (e.g. enforce expected object type, ensure that object is unique etc.).
A similar example is Cryptoki object handle re-use. PKCS#11 states that object handle is bound to particular session (i.e. if you obtained object handle in session A you should not use it in session B -- even if both sessions are running in the same application).
There are implementations that preserve object handle for the same object across sessions. There are even implementations that preserve the same object handle in different applications (i.e. if you get object handle 123 in application A you will get object handle 123 in application B for the same object).
This behaviour is even described in the respective developer manual. But if you ask the vendor if you can rely on it you are told that there are some corner cases for some setups and that you must perform additional checks to be 100% sure that it will work as expected...
Good luck with your project!
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install PyKCS11
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page