Skip to content
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

C_SignInit() Failed with CKR_USER_NOT_LOGGED_IN with multiple sessions open on the same token #844

Open
xiazhvera opened this issue Sep 18, 2023 · 0 comments

Comments

@xiazhvera
Copy link

xiazhvera commented Sep 18, 2023

My application failed on C_SignInit() with CKR_USER_NOT_LOGGED_IN when I have multiple sessions opened.

I created two sessions with the sample token and log them in. I did a C_SignInit
Then I closed session 1 and tried to call C_SignInit on session 2. And I got error CKR_USER_NOT_LOGGED_IN.

Meanwhile, the C_SignInit() works if I close the session 1 before I start session 2.

The Application Log's here:

[DEBUG] [2023-09-14T05:22:47Z] [0000ffff953bd020] [pkcs11] - id=0xaaaad96b8390 session=72057594037927937: Session opened on slot 1
[DEBUG] [2023-09-14T05:22:48Z] [0000ffff953bd020] [pkcs11] - id=0xaaaad96b8390 session=72057594037927937: User logged in
// Session one did `C_SignInit` and `C_Sign`, not log here as it succeed...
// Opened the second session
[DEBUG] [2023-09-14T05:22:49Z] [0000ffff953bd020] [pkcs11] - id=0xaaaad96b8390 session=72057594037927938: Session opened on slot 1
// Session 2 login "failed" because session 1 already login to the same token. The application would ignore the error.
[DEBUG] [2023-09-14T05:22:49Z] [0000ffff953bd020] [pkcs11] - id=0xaaaad96b8390 session=72057594037927938: User was already logged in
// Note the session id, the application is trying to close session 1.
[DEBUG] [2023-09-14T05:22:49Z] [0000ffff90edf120] [pkcs11] - id=0xaaaad96b8390 session=72057594037927937: Session closed
[pkcs11] - id=0xaaaad96b8390 session=72057594037927938: C_SignInit() failed. PKCS#11 error: CKR_USER_NOT_LOGGED_IN (0x00000101).

Looking into the library, it seems that C_SignInit failed at auth_min_ro_user https://github.com/tpm2-software/tpm2-pkcs11/blob/1b3aab90ee5f7debbce82c7e229aa2950a9e8f0d/src/pkcs11.c#L265C21-L265C37.
Would there be more context related?

Any information would help. Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant