Cryptographic Token Interface Standard |
PKCS#11 |
Cryptoki provides the following functions for generating random numbers:
CK_RV C_SeedRandom( CK_SESSION_HANDLE hSession, CK_BYTE_PTR pSeed, CK_ULONG ulSeedLen);
C_SeedRandom mixes additional seed material into the token's random number generator.
hSession | is the session's handle; |
pSeed | points to the seed material; and ulSeedLen is the length in bytes of the seed material. |
CK_RV C_GenerateRandom( CK_SESSION_HANDLE hSession, CK_BYTE_PTR pRandomData, CK_ULONG ulRandomLen );
C_GenerateRandom generates random or pseudo-random data.
hSession | is the session's handle; |
pRandomData | points to the location that receives the random data; and ulRandomLen is the length in bytes of the random or pseudo-random data to be generated. |
CK_SESSION_HANDLE hSession; CK_BYTE seed[] = {...}; CK_BYTE randomData[] = {...}; CK_RV rv; . . rv = C_SeedRandom(hSession, seed, sizeof(seed)); if (rv != CKR_OK) { . . } rv = C_GenerateRandom(hSession, randomData, sizeof(randomData)); if (rv == CKR_OK) { . . }