我已经在我的HSM中创建了一个AES密钥,我想获得密钥值,我尝试了C_FindObjects,但它只返回密钥猎人。
public long Find_AES_Key(String label) {
long hkey = -1L;
try {
AESSecretKey keyTemplate = new AESSecretKey();
keyTemplate.getLabel().setCharArrayValue(label.toCharArray());
CK_ATTRIBUTE[] attributes = iaik.pkcs.pkcs11.objects.Object.getSetAttributes(keyTemplate);
cryptoki.C_FindObjectsInit(ckiSession, attributes, false);
long[] found = cryptoki.C_FindObjects(ckiSession, 1L);
cryptoki.C_FindObjectsFinal(ckiSession);
hkey = found[0];
// cryptoki.C_GetAttributeValue(ckiSession, hkey, attributes, true);
}catch(Exception e) {
e.printStackTrace();
}
return hkey;
}谢谢你的帮助。
发布于 2021-02-26 00:51:51
这取决于您的HSM,但在大多数情况下,如果密钥是在HSM中生成的,那么它们就不是“可读的”。
如果可能,您可以使用C_DeriveKey/C_WrapKey调用Wrap并导出它。
检查密钥的CKA_WRAP属性。
https://stackoverflow.com/questions/66370455
复制相似问题