-
Notifications
You must be signed in to change notification settings - Fork 240
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
libckteec: Fix CK_ULONG conversions in C_GetTokenInfo() #367
libckteec: Fix CK_ULONG conversions in C_GetTokenInfo() #367
Conversation
libckteec/src/pkcs11_token.c
Outdated
info->ulTotalPublicMemory = TO_CK_ULONG(ta_info->total_public_memory); | ||
info->ulFreePublicMemory = TO_CK_ULONG(ta_info->free_public_memory); | ||
info->ulTotalPrivateMemory = TO_CK_ULONG(ta_info->total_private_memory); | ||
info->ulFreePrivateMemory = TO_CK_ULONG(ta_info->free_private_memory); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not found of using singed signed/unsigned conversion to treat 32b/64b special case CK_UNAVAILABLE_INFORMATION.
I would prefer an explicit conversion here:
static CK_ULONG maybe_unavail(uint32_t ta_value)
{
if (ta_value == PKCS11_CK_UNAVAILABLE_INFORMATION)
return CK_UNAVAILABLE_INFORMATION;
else
return ta_value;
}
(edited: fix typo + i think the cast is useless)
Also, as per the spec, this specific value does not apply to ulMaxPinLen
and ulMinPinLen
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Moved helper also to pkcs11_token.c
.
Thanks for spotting the "small print" about CK_UNAVAILABLE_INFORMATION
in CK_TOKEN_INFO
.
Also fixed the pin fields.
My laptop got broken and is in service and my dev environment is in there. I try to do the changes as soon as possible. |
9b76a10
to
01c69d8
Compare
Addressed review comments and rebased the PR. |
|
On 64 bit systems uint32_t cannot handle CK_ULONG defined CK_UNAVAILABLE_INFORMATION. This adds helper maybe_unavail() to assist in conversion. Signed-off-by: Vesa Jääskeläinen <vesa.jaaskelainen@vaisala.com> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
When running in 64 bit CPU things like ulMaxSessionCount would get value of 4294967295 instead of ~0. Adjust all other CK_ULONG fields supporting CK_UNAVAILABLE_INFORMATION. Signed-off-by: Vesa Jääskeläinen <vesa.jaaskelainen@vaisala.com> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
01c69d8
to
3ea8ba2
Compare
Thanks for the review! Applied tags and rebased on top of master and tested it. |
When running in 64 bit CPU things like
ulMaxSessionCount
would get value of4294967295
instead of~0
.This fixes problem with https://github.com/latchset/pkcs11-provider usage.
Related issue in
pkcs11-provider
project:latchset/pkcs11-provider#312
Test case for this:
OP-TEE/optee_test#718