Hello everyone,
I was disappointed to discover that the Muscle PKCS11 libraries don't
support what I would consider to be some pretty basic features listed
in the PKCS11 spec. For example, the C_WaitForSlotEvent is the only
way (other than the inefficient solution of constant polling) to be
notified of changes in the slot state (i.e. when a token is inserted
or removed from the reader).
The funny thing is, there are extension functions that provide this
exact functionality (async_StartSlotWatcher et. al). It seems strange
that the author went to the trouble of adding the feature but he
didn't add a standards-compliant way to use it.
I'm considering adding support for the C_WaitForSlotEvent function to
the libraries. My approach will probably be something like:
- Alter async_TokenEventCallback so that it also signals a pthread
condition variable when called and sets the event flag an an internal
array (explained below) for the slot whose state changed.
In the C_WaitForSlotEvent function:
- If this is the first time that C_WaitForSlotEvent has been called:
- Initialize some internal array that holds an event flag for each slot
- Call async_StartSlotWatcher
- If C_WaitForSlotEvent was called in blocking mode, wait on the
pthread condition variable.
- Check to see if any event flags are set. If none and function was
calling in non-blocking mode, return CKR_NO_EVENT. Otherwise, fill
pSlot with the first slot whose event flag is set and set that slot's
event flag back to zero then return CKR_OK.
Can anyone see a problem with my approach? I'm not very familiar with
the internals of the Muscle PKCS11 library, but I'm willing to get my
hands dirty. I'm hoping that someone with more experience (perhaps
even the author himself) will have some suggestions for improvements.
Thanks,
Carl Youngblood
_______________________________________________
Muscle mailing list
[EMAIL PROTECTED]
http://lists.drizzle.com/mailman/listinfo/muscle