- I open a session
- I create an AES key with a label by using C_CreateObject
- I can lookup the created object by label by using C_FindObjects.
- I close the session.
- I open a new session.
- I can no longer lookup the created object by label using C_FindObjects.
What am I doing wrong?
Thanks!
Two possibilities come to my mind:
Therefore the session of
C_CreateObjectneeds to have been opened with theflagsargument set toCKF_SERIAL_SESSION | CKF_RW_SESSION.pTemplateargment toC_CreateObjectneeds to include theCKA_TOKENattribute so that the newly created key would be a "token object" rather than a "session object".In PKCS#11, a token object is persistent across sessions whereas a session object is ephemeral and would get dropped once the session is closed.
Hope this helps.