python-pkcs11
python-pkcs11 copied to clipboard
Question regarding get_keys()
I would appreciate a little guidance on the smart/correct way to get an object pointing to a previously generated key. The documentation shows how to generate or import a key and how to perform operations with keys, but not how to point to already existing keys. (I won't use the term "load" here or such as I do want the keys to remain inside the HSM when the crypto operation is done)
For a symmetric key, the label seems sufficient for specifying which key we want to use:
symmetricKey = session.get_key(label='symmetric')
but the generate_keypair() used for asymmetric key types leads to both public and private key having the same label so the best I have come up with so far is:
privateAsymmetricKey = session.get_key(label='asymmetric', object_class=pkcs11.ObjectClass.PRIVATE_KEY)
publicAsymmetricKey = session.get_key(label='asymmetric', object_class=pkcs11.ObjectClass.PUBLIC_KEY)
Apologies in advance if this is already documented somewhere I've failed to look (or read and failed to understand)