openHiTLS API openHiTLS 0.1.0-Alpha1

◆ CRYPT_EAL_RandInit()

int32_t CRYPT_EAL_RandInit ( CRYPT_RAND_AlgId  id,
CRYPT_RandSeedMethod seedMeth,
void *  seedCtx,
const uint8_t *  pers,
uint32_t  persLen 
)

Random number initialization interface. This interface does not support multiple threads.

 Initialize global random number to RAND, Entropy sources and addtional random numbers in the seed material

which implemented by HiTLS. and this value is provided by the user. if user not provid the entropy source (seedMeth and seedCtx are both NULL), the default software entropy source is used. In addition, this interface does not support multiple threads. The global random number is initialized to the random generation algorithm described in Nist 800-90a. Application scenarios 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 report.
  3. seedMeth != NULL ====> This function can be used normally, seedCtx is not restricted, but make sure seedMeth can handle all kinds of situations.
注意
: Support obtain or generate random numbers with multithreading, but not support initialization and deinitialization with multithreading.
参数
id[IN] RAND id
seedMeth[IN] Seed method, which can be set NULL with seedCtx, The default entropy source is used or provided by the user.
seedCtx[IN] Seed context information, which can be set NULL, But the seedMeth provided by the user can handle the situation where seedCtx is NULL. Generally, seedCtx needs to contain data such as entropy and nonce.
pers[IN] Personal data, which can be NULL.
persLen[IN] Length of the personal data, the length ranges from [0,0x7FFFFFF0].
返回值
CRYPT_SUCCESS,ifsuccessful. For other error codes, see the crypt_errno.h file.