jacknji11
jacknji11 copied to clipboard
can't export aeskey
Hi @primetomas ,
I could generate aes key. But can't export/extract it as Key from HSM. Can you help me to export aes key?
long aeskey = CE.GenerateKey(session, new CKM(CKM.AES_KEY_GEN), new CKA(CKA.VALUE_LEN, 32), new CKA(CKA.LABEL, "labelencaes"), new CKA(CKA.ID, "labelencaes"), new CKA(CKA.TOKEN, false), new CKA(CKA.SENSITIVE, false), new CKA(CKA.ENCRYPT, true), new CKA(CKA.DECRYPT, true), new CKA(CKA.DERIVE, true));
Regards Paul V
If you managed to create the key with CKA.SENSITIVE=false, you should be able to get the key in the plaintext form by calling CE.GetAttributeValue to get the CKA.VALUE attribute.
If that fails you might try setting the key as extractable (CKA.EXTRACTABLE) and create another wrapping key to wrap and then decrypt the wrapped original key.