API参考
载入中...
搜索中...
未找到
Crypt_eal_rand

random number module 更多...

Crypt_eal_rand 的协作图:

类型定义

typedef int32_t(* CRYPT_EAL_RandFunc) (uint8_t *rand, uint32_t randLen)
 rand generate callback
typedef int32_t(* CRYPT_EAL_RandFuncEx) (void *ctx, uint8_t *rand, uint32_t randLen)
 rand generate callback

函数

void CRYPT_EAL_SetRandCallBack (CRYPT_EAL_RandFunc func)
 set rand func callback
void CRYPT_EAL_SetRandCallBackEx (CRYPT_EAL_RandFuncEx func)
 set rand func callback
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.
int32_t CRYPT_EAL_ProviderRandInitCtx (CRYPT_EAL_LibCtx *libCtx, int32_t algId, const char *attrName, const uint8_t *pers, uint32_t persLen, BSL_Param *param)
 Random number initialization in the providers.
void CRYPT_EAL_RandDeinit (void)
 Deinitializing the global RAND interface, this interface does not support multiple threads.
void CRYPT_EAL_RandDeinitEx (CRYPT_EAL_LibCtx *libCtx)
 Deinitializing the libCtx RAND interface, this interface does not support multiple threads.
int32_t CRYPT_EAL_RandbytesWithAdin (uint8_t *byte, uint32_t len, uint8_t *addin, uint32_t addinLen)
 Generate a random number.
int32_t CRYPT_EAL_RandbytesWithAdinEx (CRYPT_EAL_LibCtx *libCtx, uint8_t *byte, uint32_t len, uint8_t *addin, uint32_t addinLen)
 Generate a random number.
int32_t CRYPT_EAL_Randbytes (uint8_t *byte, uint32_t len)
int32_t CRYPT_EAL_RandbytesEx (CRYPT_EAL_LibCtx *libCtx, uint8_t *byte, uint32_t len)
int32_t CRYPT_EAL_RandSeedWithAdin (uint8_t *addin, uint32_t addinLen)
 Regenerate the seed.
int32_t CRYPT_EAL_RandSeed (void)
int32_t CRYPT_EAL_RandSeedEx (CRYPT_EAL_LibCtx *libCtx)
CRYPT_EAL_RndCtx * CRYPT_EAL_ProviderDrbgNewCtx (CRYPT_EAL_LibCtx *libCtx, int32_t algId, const char *attrName, BSL_Param *param)
 Random number initialization in the providers.
int32_t CRYPT_EAL_DrbgbytesWithAdin (CRYPT_EAL_RndCtx *ctx, uint8_t *byte, uint32_t len, uint8_t *addin, uint32_t addinLen)
 Generate a random number.
int32_t CRYPT_EAL_Drbgbytes (CRYPT_EAL_RndCtx *ctx, uint8_t *byte, uint32_t len)
int32_t CRYPT_EAL_DrbgSeedWithAdin (CRYPT_EAL_RndCtx *ctx, uint8_t *addin, uint32_t addinLen)
 Regenerate the seed. The addtional data can be NULL. This interface supports multi-thread access.
int32_t CRYPT_EAL_DrbgSeed (CRYPT_EAL_RndCtx *ctx)
 Regenerate the seed, which is equivalent to CRYPT_EAL_RandSeedWithAdin(NULL, 0).
bool CRYPT_EAL_RandIsValidAlgId (CRYPT_RAND_AlgId id)
 Check whether the id is valid Rand algorithm ID.
int32_t CRYPT_EAL_DrbgInstantiate (CRYPT_EAL_RndCtx *rndCtx, const uint8_t *pers, uint32_t persLen)
 Instantiate the DRBG.
int32_t CRYPT_EAL_DrbgCtrl (CRYPT_EAL_RndCtx *ctx, int32_t cmd, void *val, uint32_t valLen)
 get or set rand param
CRYPT_EAL_RndCtx * CRYPT_EAL_GetSeedCtx (bool isParentEntropy)
 Get the seed of Primary DRBG.

详细描述

random number module

类型定义说明

◆ CRYPT_EAL_RandFunc

typedef int32_t(* CRYPT_EAL_RandFunc) (uint8_t *rand, uint32_t randLen)

rand generate callback

rand[out] randomdata randLen[in] len

返回
int32_t, defined by users.

◆ CRYPT_EAL_RandFuncEx

typedef int32_t(* CRYPT_EAL_RandFuncEx) (void *ctx, uint8_t *rand, uint32_t randLen)

rand generate callback

ctx[in] ctx rand[out] randomdata randLen[in] len

返回
int32_t, defined by users.

函数说明

◆ CRYPT_EAL_Drbgbytes()

int32_t CRYPT_EAL_Drbgbytes ( CRYPT_EAL_RndCtx * ctx,
uint8_t * byte,
uint32_t len )

Generate a random number, which is equivalent to CRYPT_EAL_RandbytesWithAdin(bytes, len, NULL, 0). This interface supports multi-thread access.

参数
ctx[IN] DRBG handle
byte[OUT] Used to store output random numbers. the memory is provided by the user.
len[IN] Required random number length. the range is (0, 65536].
返回值
CRYPT_SUCCESS,ifsuccessful. For other error codes, see the crypt_errno.h file.

◆ CRYPT_EAL_DrbgbytesWithAdin()

int32_t CRYPT_EAL_DrbgbytesWithAdin ( CRYPT_EAL_RndCtx * ctx,
uint8_t * byte,
uint32_t len,
uint8_t * addin,
uint32_t addinLen )

Generate a random number.

注意
The addtional data can be NULL, user specifies the addtional data, and the interface supports multi-thread access.
参数
ctx[IN] DRBG handle
byte[OUT] Outputs random numbers. the memory is provided by the user.
len[IN] Required random number length. the range is (0, 65536].
addin[IN] Addtional data, which can be NULL.
addinLen[IN] Addtional data length. the range is [0,0x7FFFFFF0].
返回值
CRYPT_SUCCESS,ifsuccessful. For other error codes, see the crypt_errno.h file.

◆ CRYPT_EAL_DrbgCtrl()

int32_t CRYPT_EAL_DrbgCtrl ( CRYPT_EAL_RndCtx * ctx,
int32_t cmd,
void * val,
uint32_t valLen )

get or set rand param

参数
ctx[IN] rand context
cmd[IN] Option information
val[IN/OUT] Data to be set/obtained
valLen[IN] Length of the data marked as "val"
返回值
CRYPT_SUCCESSFor other error codes, see crypt_errno.h.

◆ CRYPT_EAL_DrbgInstantiate()

int32_t CRYPT_EAL_DrbgInstantiate ( CRYPT_EAL_RndCtx * rndCtx,
const uint8_t * pers,
uint32_t persLen )

Instantiate the DRBG.

This function instantiates the Deterministic Random Bit Generator (DRBG) with personalization string. It supports multi-thread access.

参数
rndCtx[IN] DRBG handle
pers[IN] Personal data, which can be NULL.
persLen[IN] Personal data length. the range is [0,0x7FFFFFF0].
返回值
CRYPT_SUCCESS,ifsuccessful. For other error codes, see crypt_errno.h.

◆ CRYPT_EAL_DrbgSeed()

int32_t CRYPT_EAL_DrbgSeed ( CRYPT_EAL_RndCtx * ctx)

Regenerate the seed, which is equivalent to CRYPT_EAL_RandSeedWithAdin(NULL, 0).

注意
This interface supports multi-thread access.
参数
ctx[IN] DRBG handle.
返回值
CRYPT_SUCCESS,ifsuccessful. For other error codes, see crypt_errno.h.

◆ CRYPT_EAL_DrbgSeedWithAdin()

int32_t CRYPT_EAL_DrbgSeedWithAdin ( CRYPT_EAL_RndCtx * ctx,
uint8_t * addin,
uint32_t addinLen )

Regenerate the seed. The addtional data can be NULL. This interface supports multi-thread access.

参数
ctx[IN] DRBG handle
addin[IN] Addtional data, which can be null.
addinLen[IN] Addtional data length. The maximum length is [0,0x7FFFFFF0].
返回值
CRYPT_SUCCESS,ifsuccessful. For other error codes, see crypt_errno.h.

◆ CRYPT_EAL_GetSeedCtx()

CRYPT_EAL_RndCtx * CRYPT_EAL_GetSeedCtx ( bool isParentEntropy)

Get the seed of Primary DRBG.

参数
isParentEntropy[IN] If true, return primary DRBG; otherwise, return g_globalRndCtx.
返回值
DRBGhandle.

◆ CRYPT_EAL_ProviderDrbgNewCtx()

CRYPT_EAL_RndCtx * CRYPT_EAL_ProviderDrbgNewCtx ( CRYPT_EAL_LibCtx * libCtx,
int32_t algId,
const char * attrName,
BSL_Param * param )

Random number initialization in the providers.

参数
libCtx[IN] Library context
algId[IN] rand algorithm ID.
attrName[IN] Specify expected attribute values
param[IN] Transparent transmission of underlying parameters
返回值
SuccessDRBG ctx. Fails: NULL.

◆ CRYPT_EAL_ProviderRandInitCtx()

int32_t CRYPT_EAL_ProviderRandInitCtx ( CRYPT_EAL_LibCtx * libCtx,
int32_t algId,
const char * attrName,
const uint8_t * pers,
uint32_t persLen,
BSL_Param * param )

Random number initialization in the providers.

参数
libCtx[IN] Library context
algId[IN] rand algorithm ID.
attrName[IN] Specify expected attribute values
pers[IN] Personal data, which can be NULL.
persLen[IN] Personal data length. the range is [0,0x7FFFFFF0].
param[IN] Transparent transmission of underlying parameters
返回值
CRYPT_SUCCESS,ifsuccessful. For other error codes, see the crypt_errno.h file.

◆ CRYPT_EAL_Randbytes()

int32_t CRYPT_EAL_Randbytes ( uint8_t * byte,
uint32_t len )

Generate a random number, which is equivalent to CRYPT_EAL_RandbytesWithAdin(bytes, len, NULL, 0). This interface supports multi-thread access.

参数
byte[OUT] Used to store output random numbers, the memory is provided by the user.
len[IN] Required random number length, the length range is(0, 65536].
返回值
CRYPT_SUCCESS,ifsuccessful. For other error codes, see the crypt_errno.h file.

◆ CRYPT_EAL_RandbytesEx()

int32_t CRYPT_EAL_RandbytesEx ( CRYPT_EAL_LibCtx * libCtx,
uint8_t * byte,
uint32_t len )

Generate a random number This interface supports multi-thread access.

参数
libCtx[IN] Library context
byte[OUT] Used to store output random numbers, the memory is provided by the user.
len[IN] Required random number length, the length range is(0, 65536].
返回值
CRYPT_SUCCESS,ifsuccessful. For other error codes, see the crypt_errno.h file.

◆ CRYPT_EAL_RandbytesWithAdin()

int32_t CRYPT_EAL_RandbytesWithAdin ( uint8_t * byte,
uint32_t len,
uint8_t * addin,
uint32_t addinLen )

Generate a random number.

The addtional data marked as "addin" can be NULL, and additional data specified by the user. This interface does not support multiple threads.

参数
byte[OUT] Output random numbers, the memory is provided by the user.
len[IN] Required random number length, the maximum length is (0, 65536].
addin[IN] Addtional data, which can set be NULL.
addinLen[IN] Addtional data length, the maximum length is[0,0x7FFFFFF0].
返回值
CRYPT_SUCCESS,ifsuccessful. For other error codes, see the crypt_errno.h file.

◆ CRYPT_EAL_RandbytesWithAdinEx()

int32_t CRYPT_EAL_RandbytesWithAdinEx ( CRYPT_EAL_LibCtx * libCtx,
uint8_t * byte,
uint32_t len,
uint8_t * addin,
uint32_t addinLen )

Generate a random number.

The addtional data marked as "addin" can be NULL, and additional data specified by the user. This interface does not support multiple threads.

参数
libCtx[IN] Library context
byte[OUT] Output random numbers, the memory is provided by the user.
len[IN] Required random number length, the maximum length is (0, 65536].
addin[IN] Addtional data, which can set be NULL.
addinLen[IN] Addtional data length, the maximum length is[0,0x7FFFFFF0].
返回值
CRYPT_SUCCESS,ifsuccessful. For other error codes, see the crypt_errno.h file.

◆ CRYPT_EAL_RandDeinit()

void CRYPT_EAL_RandDeinit ( void )

Deinitializing the global RAND interface, this interface does not support multiple threads.

返回值
void,noreturn value.

◆ CRYPT_EAL_RandDeinitEx()

void CRYPT_EAL_RandDeinitEx ( CRYPT_EAL_LibCtx * libCtx)

Deinitializing the libCtx RAND interface, this interface does not support multiple threads.

参数
libCtx[IN] Library context
返回值
void,noreturn value.

◆ 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.

◆ CRYPT_EAL_RandIsValidAlgId()

bool CRYPT_EAL_RandIsValidAlgId ( CRYPT_RAND_AlgId id)

Check whether the id is valid Rand algorithm ID.

参数
id[IN] Rand algorithm ID.
返回值
true,ifvalid. false, if invalid.

◆ CRYPT_EAL_RandSeed()

int32_t CRYPT_EAL_RandSeed ( void )

Regenerate the seed, which is equivalent to CRYPT_EAL_RandSeedWithAdin(NULL, 0), and the interface supports multi-thread access.

返回值
CRYPT_SUCCESSFor other error codes, see crypt_errno.h.
注解
After forking, it is necessary to manually supplement the entropy source for the new program

◆ CRYPT_EAL_RandSeedEx()

int32_t CRYPT_EAL_RandSeedEx ( CRYPT_EAL_LibCtx * libCtx)

Regenerate the seed, which is equivalent to CRYPT_EAL_RandSeedWithAdin(NULL, 0), and the interface supports multi-thread access.

参数
libCtx[IN] Library context
返回值
CRYPT_SUCCESSFor other error codes, see crypt_errno.h.
注解
After forking, it is necessary to manually supplement the entropy source for the new program

◆ CRYPT_EAL_RandSeedWithAdin()

int32_t CRYPT_EAL_RandSeedWithAdin ( uint8_t * addin,
uint32_t addinLen )

Regenerate the seed.

注意
The addtional data can set be NULL, and this interface supports multi-thread access.
参数
addin[IN] Additional data, which can set be NULL.
addinLen[IN] Addtional data length, the range is [0,0x7FFFFFF0].
返回值
CRYPT_SUCCESS,ifsuccessful. For other error codes, see crypt_errno.h.
注解
After forking, it is necessary to manually supplement the entropy source for the new program

◆ CRYPT_EAL_SetRandCallBack()

void CRYPT_EAL_SetRandCallBack ( CRYPT_EAL_RandFunc func)

set rand func callback

func[in] rand func

返回
void.

◆ CRYPT_EAL_SetRandCallBackEx()

void CRYPT_EAL_SetRandCallBackEx ( CRYPT_EAL_RandFuncEx func)

set rand func callback

func[in] rand func

返回
void.