python-pkcs11 icon indicating copy to clipboard operation
python-pkcs11 copied to clipboard

Unable to generate key with Attribute.SENSITIVE False

Open maynardflies opened this issue 3 years ago • 1 comments

I am following the documentation to generate an exportable AES key, but when I use the below code snippet, I get the subsequent error stack.

I am using a Luna password-based HSM but am not sure of the version. Any help would be appreciated!

from pkcs11 import KeyType, Attribute

key = session.generate_key(KeyType.AES, 256, template={
    Attribute.SENSITIVE: False,
    Attribute.EXTRACTABLE: True,
})
print(key[Attribute.VALUE])

Traceback (most recent call last):
  File "create_key.py", line 33, in <module>
    key = session.generate_key(pkcs11.KeyType.AES, 256, store=False, label=args.keylabel, template={
  File "pkcs11/_pkcs11.pyx", line 488, in pkcs11._pkcs11.Session.generate_key
  File "pkcs11/_errors.pyx", line 88, in pkcs11._pkcs11.assertRV
pkcs11.exceptions.AttributeValueInvalid

maynardflies avatar Aug 13 '21 14:08 maynardflies

We are also facing same issue, we cannot unwarp a key to get the key value. Cannot set the attribute sensitive as false.

princykv avatar Jun 22 '23 10:06 princykv