session.login(PIN)
print(pkcs11.getTokenInfo(theOnlySlot))
template = (CKA_CLASS, CKO_SECRET_KEY), (CKA_KEY_TYPE, CKK_AES), (CKA_VALUE_LEN
    , 32), (CKA_LABEL, label), (CKA_ID, '1244'), (CKA_PRIVATE, True), (
    CKA_SENSITIVE, True), (CKA_ENCRYPT, True), (CKA_DECRYPT, True), (CKA_TOKEN,
    True), (CKA_WRAP, True), (CKA_UNWRAP, True), (CKA_EXTRACTABLE, False)
ckattr = session._template2ckattrlist(template)
m = LowLevel.CK_MECHANISM()
m.mechanism = LowLevel.CKM_AES_KEY_GEN
key = LowLevel.CK_OBJECT_HANDLE()
returnValue = pkcs11.lib.C_GenerateKey(session.session, m, ckattr, key)
if returnValue != CKR_OK:
    raise PyKCS11Error(returnValue)
createTokenAES256('TestKey')
Smartcard PKCS11 AES Key Gen Failure