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

pkcs11: ignore error if CKA_ALWAYS_AUTHENTICATE is not supported #13

Merged
merged 1 commit into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ mycms
Copyright (c) 2022-2024 Alon Bar-Lev <alon.barlev@gmail.com>

????-??-?? - Version 0.3.0
* pkcs11: ignore error if CKA_ALWAYS_AUTHENTICATE is not supported.


2024-02-19 - Version 0.2.0
Expand Down
44 changes: 23 additions & 21 deletions src/libmycms/mycms-certificate-driver-pkcs11.c
Original file line number Diff line number Diff line change
Expand Up @@ -853,9 +853,7 @@ __open_object(
const bool private_object,
const CK_ATTRIBUTE * const filter,
const CK_ULONG filter_size,
CK_OBJECT_HANDLE * const handle,
CK_ATTRIBUTE * attrs,
const CK_ULONG attrs_size
CK_OBJECT_HANDLE * const handle
) {
mycms_system system = NULL;
__mycms_certificate_driver_pkcs11 certificate_pkcs11 = NULL;
Expand Down Expand Up @@ -943,16 +941,6 @@ __open_object(
}
}

if (__get_object_attributes(
system,
certificate_pkcs11,
*handle,
attrs,
attrs_size
) != CKR_OK) {
goto cleanup;
}

ret = true;

cleanup:
Expand Down Expand Up @@ -998,14 +986,22 @@ __open_certificate(
private,
filter,
sizeof(filter) / sizeof(*filter),
&h,
attrs,
sizeof(attrs) / sizeof(*attrs)
&h
)
) {
goto cleanup;
}

if (__get_object_attributes(
system,
certificate_pkcs11,
h,
attrs,
sizeof(attrs) / sizeof(*attrs)
) != CKR_OK) {
goto cleanup;
}

if (attrs[CERT_ATTRS_ID].ulValueLen == CK_UNAVAILABLE_INFORMATION) {
goto cleanup;
}
Expand Down Expand Up @@ -1075,16 +1071,22 @@ __open_private_key(
true,
filter,
sizeof(filter) / sizeof(*filter),
&certificate_pkcs11->key_handle,
attrs,
sizeof(attrs) / sizeof(*attrs)
&certificate_pkcs11->key_handle
)
) {
goto cleanup;
}

if (attrs[0].ulValueLen != CK_UNAVAILABLE_INFORMATION) {
certificate_pkcs11->always_authenticate = *(CK_BBOOL *)attrs[0].pValue != CK_FALSE;
if (__get_object_attributes(
system,
certificate_pkcs11,
certificate_pkcs11->key_handle,
attrs,
sizeof(attrs) / sizeof(*attrs)
) == CKR_OK) {
if (attrs[0].ulValueLen != CK_UNAVAILABLE_INFORMATION) {
certificate_pkcs11->always_authenticate = *(CK_BBOOL *)attrs[0].pValue != CK_FALSE;
}
}

ret = true;
Expand Down