openHiTLS API openHiTLS 0.1.0-Alpha1

◆ CRYPT_EAL_DrbgInit()

CRYPT_EAL_RndCtx * CRYPT_EAL_DrbgInit ( CRYPT_RAND_AlgId  id,
CRYPT_RandSeedMethod seedMeth,
void *  seedCtx,
const uint8_t *  pers,
uint32_t  persLen 
)

Random number initialization interface, and this interface does not support multiple threads.

 Initial DRBG with HiTLS, entropy source and addtional random number in the seed material

are provided by users. This interface does not support multi-threading, the initial random number is the random number generation algorithm described in Nist 800-90a. Usage scenes are as follows:

  1. seedMeth == NULL && seedCtx == NULL ====> Use the default system entropy source in AES_CTR mode (that is, non-DF cannot use the default entropy source).
  2. seedMeth == NULL && seedCtx != NULL ===> error reported.
  3. seedMeth != NULL ====> This function can be used normally, seedCtx function is not restricted, but make sure seedMeth can handle all kinds of situations.
Attention
Initialization and deinitialization
Parameters
id[IN] RAND id
seedMeth[IN] Seed method, this parameter and seedCtx can be null at the same time. The default entropy source is used or provided by the user.
seedCtx[IN] Seed context information, which can be NULL, but the seedMeth provided by the user needs to be able to handle the situation where seedCtx is null. seedCtx generally needs to contain the entropy source marked as "entropy", additional random number "nonce", and other data.
pers[IN] Personal data, which can be NULL.
persLen[IN] Personal data length. the range is [0,0x7FFFFFF0].
Return values
DRBGhandle, if successful. NULL, if failed.