0

moved to v2 of cryptoki (CK_VERSION 204. File is 4.4.0.0). This code worked before but now doesn't:

// key is BYTE[32]
RV rv;
CK_FLAGS flags = CKF_SERIAL_SESSION | CKF_RW_SESSION;
CK_SESION_HANDLE handle;
rv = C_OpenSession(slot_id, flags, (void*)"MyApp", 0, &handle); // This succeeds
int keyLen = 32;
rv = C_GenerateRandom(handle, key, keyLen); // fails here. rv = 0x8000001A

Of course C_Initialize was called beforehand. Should this code change?

grunt
  • 662
  • 1
  • 8
  • 24

1 Answers1

0

Need to login before GenerateRandom:

rv = C_Login(handle, CKU_USER, password, passwordLen);
grunt
  • 662
  • 1
  • 8
  • 24