xipki / pkcs11wrapper

PKCS#11 Wrapper for Java. Deprecated. Please use xipki/ipkcs11wrapper (preferred) or xipki/jpkcs11wrapper instead.
Other
34 stars 13 forks source link

Pass CKA_VALUE into secretkey template #6

Closed armando-basile closed 4 years ago

armando-basile commented 4 years ago

Hi Xipki, i trying to pass CKA_VALUE for a CKK_DES2 test key but i receive always: Unsupported attribute 0x11 for iaik.pkcs.pkcs11.objects.SecretKey.

I use:

byte[] keyValue = new byte[] { ... };
SecretKey key_template = SecretKey();
((SecretKey) key_template).getLabel().setValue("TESTKEY-LABEL".toCharArray());
key_template.putAttribute(PKCS11Constants.CKA_TOKEN, true);
key_template.putAttribute(PKCS11Constants.CKA_KEY_TYPE, PKCS11Constants.CKK_DES2);
...
key_template.putAttribute(PKCS11Constants.CKA_VALUE, keyValue);

((Session) session).createObject(key_template);

Could you help me ?

armando-basile commented 4 years ago

Ops... i used ValuedSecretKey and it worked