Skip to content

Commit

Permalink
pkcs11: handle CKA_{DECRYPT,ENCRYPT} when generating wrap keys
Browse files Browse the repository at this point in the history
The translation of the CKA_{DECRYPT,ENCRYPT} attributes to the
corresponding {un}wrap-data capabilities for wrap keys is missing from
C_GenerateKey, but present in C_CreateObject. Remedy this by also
handling the attributes in C_GenerateKey.
  • Loading branch information
LDVG committed Nov 2, 2021
1 parent 4d0268d commit 396c260
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pkcs11/yubihsm_pkcs11.c
Original file line number Diff line number Diff line change
Expand Up @@ -4541,6 +4541,22 @@ CK_DEFINE_FUNCTION(CK_RV, C_GenerateKey)
}
}

if (template.encrypt == ATTRIBUTE_TRUE) {
rc = yh_string_to_capabilities("wrap-data", &capabilities);
if (rc != YHR_SUCCESS) {
rv = CKR_FUNCTION_FAILED;
goto c_gk_out;
}
}

if (template.decrypt == ATTRIBUTE_TRUE) {
rc = yh_string_to_capabilities("unwrap-data", &capabilities);
if (rc != YHR_SUCCESS) {
rv = CKR_FUNCTION_FAILED;
goto c_gk_out;
}
}

rc = yh_string_to_capabilities("all", &delegated_capabilities);
if (rc != YHR_SUCCESS) {
rv = CKR_FUNCTION_FAILED;
Expand Down

0 comments on commit 396c260

Please sign in to comment.