Hello Jaroslav,
Thanks for answer. I have not directly access to Safenet support only to Amazon. I have open a ticket but when I ask questions, answer are not very precise. However, I have some news. Recently we added multi-threading in our application. And I suppose that it is linked to the issue. I suppose that we don't manage well the sessions and I've started to read more carefully the pkcs11 standard to understand how to manage session inside a multi-threaded application.
To summary we have an application that receive some data and each time data are received a thread is created to verify a CMAC (and do other stuff after). I have read in pkcs11 that it is better to open one session by thread if each thread performs the same cryptographic operation.
So here what I have done :
1) At application startup : instantiate a pkcs11 to call C_Initialize (one call by application according to pkcs11 standard)
2) Inside the thread
- call a OpenSession followed by a login with normal user
- perfom cryptographics operations (FindObjects and Verify CMAC)
- log out and close the session.
This doesn't seems to work. I always got the error code
(2147483674 ). So I have read a little more and I found that a call to C_Logout will change all the user sessions to public sessions. I also try to remove the call to Logout and it worked (i suppose ;)). Because I don't see this error anymore.
But, of course, I have another problem. I try to send data to my application using a test program. And everytime, I have a few "mac not verified" because the FindObjects doesn't find the key. I use 4 tests programs sendind 10 datas each other in parallel. So 40 packets sends. And I always have 1 to 4 mac failure becaus eof key not found
So I have questions :
1) What do you think about the approach (one session by thread)?
2) Should I call C_Login one time or each time I open the session?
3) I have read that we can perfom only one cryptographic operation by session. So is it dangerous to call FindObjects and the verify CMAC in the same session?
4) Any idea about why the thread can't find the key sometimes?
Sorry for the long speech ;). I can give details if you want. I'm out of ideas now ;)
Regards,