Skip to content

Commit

Permalink
Ensure CKA_KEY_TYPE always sets length
Browse files Browse the repository at this point in the history
  • Loading branch information
qpernil committed Nov 6, 2024
1 parent 11b7912 commit b434a27
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions pkcs11/util_pkcs11.c
Original file line number Diff line number Diff line change
Expand Up @@ -1604,13 +1604,12 @@ static CK_RV get_attribute_private_key(CK_ATTRIBUTE_TYPE type,
} else {
*((CK_KEY_TYPE *) value) = CKK_EC;
}

*length = sizeof(CK_KEY_TYPE);
} else if (object->type == YH_WRAP_KEY && yh_is_rsa(object->algorithm)) {
*((CK_KEY_TYPE *) value) = CKK_RSA;
} else {
return CKR_FUNCTION_FAILED;
}
*length = sizeof(CK_KEY_TYPE);
break;

case CKA_ID:
Expand Down Expand Up @@ -2081,8 +2080,6 @@ static CK_RV get_attribute_public_key(CK_ATTRIBUTE_TYPE type,
default:
*((CK_KEY_TYPE *) value) = CKK_VENDOR_DEFINED; // TODO: argh
}

*length = sizeof(CK_KEY_TYPE);
} else if (object->type == YH_HMAC_KEY) {
switch (object->algorithm) {
case YH_ALGO_HMAC_SHA1:
Expand All @@ -2104,13 +2101,12 @@ static CK_RV get_attribute_public_key(CK_ATTRIBUTE_TYPE type,
default:
*((CK_KEY_TYPE *) value) = CKK_VENDOR_DEFINED; // TODO: argh
}
*length = sizeof(CK_KEY_TYPE);
} else if (object->type == YH_PUBLIC_WRAP_KEY && yh_is_rsa(object->algorithm)) {
*((CK_KEY_TYPE *) value) = CKK_RSA;
*length = sizeof(CK_KEY_TYPE);
} else {
return CKR_FUNCTION_FAILED;
}
*length = sizeof(CK_KEY_TYPE);
break;

case CKA_ID:
Expand Down

0 comments on commit b434a27

Please sign in to comment.