Skip to content

Commit 6568a6e

Browse files
committed
pkcs11: ignore error if CKA_ALWAYS_AUTHENTICATE is not supported
1 parent ffe5488 commit 6568a6e

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ mycms
22
Copyright (c) 2022-2024 Alon Bar-Lev <alon.barlev@gmail.com>
33

44
????-??-?? - Version 0.3.0
5+
* pkcs11: ignore error if CKA_ALWAYS_AUTHENTICATE is not supported.
56

67

78
2024-02-19 - Version 0.2.0

src/libmycms/mycms-certificate-driver-pkcs11.c

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -853,9 +853,7 @@ __open_object(
853853
const bool private_object,
854854
const CK_ATTRIBUTE * const filter,
855855
const CK_ULONG filter_size,
856-
CK_OBJECT_HANDLE * const handle,
857-
CK_ATTRIBUTE * attrs,
858-
const CK_ULONG attrs_size
856+
CK_OBJECT_HANDLE * const handle
859857
) {
860858
mycms_system system = NULL;
861859
__mycms_certificate_driver_pkcs11 certificate_pkcs11 = NULL;
@@ -943,16 +941,6 @@ __open_object(
943941
}
944942
}
945943

946-
if (__get_object_attributes(
947-
system,
948-
certificate_pkcs11,
949-
*handle,
950-
attrs,
951-
attrs_size
952-
) != CKR_OK) {
953-
goto cleanup;
954-
}
955-
956944
ret = true;
957945

958946
cleanup:
@@ -998,14 +986,22 @@ __open_certificate(
998986
private,
999987
filter,
1000988
sizeof(filter) / sizeof(*filter),
1001-
&h,
1002-
attrs,
1003-
sizeof(attrs) / sizeof(*attrs)
989+
&h
1004990
)
1005991
) {
1006992
goto cleanup;
1007993
}
1008994

995+
if (__get_object_attributes(
996+
system,
997+
certificate_pkcs11,
998+
h,
999+
attrs,
1000+
sizeof(attrs) / sizeof(*attrs)
1001+
) != CKR_OK) {
1002+
goto cleanup;
1003+
}
1004+
10091005
if (attrs[CERT_ATTRS_ID].ulValueLen == CK_UNAVAILABLE_INFORMATION) {
10101006
goto cleanup;
10111007
}
@@ -1075,16 +1071,22 @@ __open_private_key(
10751071
true,
10761072
filter,
10771073
sizeof(filter) / sizeof(*filter),
1078-
&certificate_pkcs11->key_handle,
1079-
attrs,
1080-
sizeof(attrs) / sizeof(*attrs)
1074+
&certificate_pkcs11->key_handle
10811075
)
10821076
) {
10831077
goto cleanup;
10841078
}
10851079

1086-
if (attrs[0].ulValueLen != CK_UNAVAILABLE_INFORMATION) {
1087-
certificate_pkcs11->always_authenticate = *(CK_BBOOL *)attrs[0].pValue != CK_FALSE;
1080+
if (__get_object_attributes(
1081+
system,
1082+
certificate_pkcs11,
1083+
certificate_pkcs11->key_handle,
1084+
attrs,
1085+
sizeof(attrs) / sizeof(*attrs)
1086+
) == CKR_OK) {
1087+
if (attrs[0].ulValueLen != CK_UNAVAILABLE_INFORMATION) {
1088+
certificate_pkcs11->always_authenticate = *(CK_BBOOL *)attrs[0].pValue != CK_FALSE;
1089+
}
10881090
}
10891091

10901092
ret = true;

0 commit comments

Comments
 (0)