libp11
libp11 copied to clipboard
User not logged in after logging in
I have an issue with key pair generation. This simplified code:
void runSimplifiedTest(char* lib, char* passwd)
{
PKCS11_CTX* ctx = PKCS11_CTX_new();
PKCS11_CTX_load(ctx, lib);
PKCS11_SLOT* slots = NULL;
unsigned int nslots;
PKCS11_enumerate_slots(ctx, &slots, &nslots);
PKCS11_SLOT* slot = PKCS11_find_token(ctx, slots, nslots);
PKCS11_login(slot, 0, passwd);
PKCS11_open_session(slot, 1);
PKCS11_login(slot, 0, passwd);
PKCS11_generate_key(slot->token, 0, 2048, "test_label", (unsigned char*)"testid", 6);
if (ERR_peek_last_error()) {
fprintf(stderr, "Generated errors:\n");
ERR_print_errors_fp(stderr);
}
}
shows the following error: 4407954944:error:81082101:PKCS#11 module:func(130):User not logged in:p11_key.c:322: