Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure CKA_KEY_TYPE always sets length #437

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading