PKCS#11: compile time check in finding keys

When WC_PKCS11_FIND_WITH_ID_ONLY defined, don't add key class and
type to attributes of search for by Id.
This commit is contained in:
Sean Parkinson
2022-11-01 10:29:10 +10:00
parent 502a395723
commit ae22babf8b

View File

@@ -1464,8 +1464,10 @@ static int Pkcs11FindKeyById(CK_OBJECT_HANDLE* key, CK_OBJECT_CLASS keyClass,
int ret = 0;
CK_ULONG count;
CK_ATTRIBUTE keyTemplate[] = {
#ifndef WC_PKCS11_FIND_WITH_ID_ONLY
{ CKA_CLASS, &keyClass, sizeof(keyClass) },
{ CKA_KEY_TYPE, &keyType, sizeof(keyType) },
#endif
{ CKA_ID, id, (CK_ULONG)idLen }
};
CK_ULONG keyTmplCnt = sizeof(keyTemplate) / sizeof(*keyTemplate);