![]() |
API参考
|
random number module 更多...

类型定义 | |
| 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
| typedef int32_t(* CRYPT_EAL_RandFunc) (uint8_t *rand, uint32_t randLen) |
rand generate callback
rand[out] randomdata randLen[in] len
| 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 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,if | successful. For other error codes, see the crypt_errno.h file. |
| 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.
| 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,if | successful. For other error codes, see the crypt_errno.h file. |
| 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_SUCCESS | For other error codes, see crypt_errno.h. |
| 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,if | successful. For other error codes, see crypt_errno.h. |
| int32_t CRYPT_EAL_DrbgSeed | ( | CRYPT_EAL_RndCtx * | ctx | ) |
Regenerate the seed, which is equivalent to CRYPT_EAL_RandSeedWithAdin(NULL, 0).
| ctx | [IN] DRBG handle. |
| CRYPT_SUCCESS,if | successful. For other error codes, see crypt_errno.h. |
| 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,if | successful. For other error codes, see crypt_errno.h. |
| 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. |
| DRBG | handle. |
| 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 |
| Success | DRBG ctx. Fails: NULL. |
| 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,if | successful. For other error codes, see the crypt_errno.h file. |
| 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,if | successful. For other error codes, see the crypt_errno.h file. |
| 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,if | successful. For other error codes, see the crypt_errno.h file. |
| 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,if | successful. For other error codes, see the crypt_errno.h file. |
| 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,if | successful. For other error codes, see the crypt_errno.h file. |
| void CRYPT_EAL_RandDeinit | ( | void | ) |
Deinitializing the global RAND interface, this interface does not support multiple threads.
| void,no | return value. |
| 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,no | return value. |
| 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:
| 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,if | successful. For other error codes, see the crypt_errno.h file. |
| bool CRYPT_EAL_RandIsValidAlgId | ( | CRYPT_RAND_AlgId | id | ) |
Check whether the id is valid Rand algorithm ID.
| id | [IN] Rand algorithm ID. |
| true,if | valid. false, if invalid. |
| 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_SUCCESS | For other error codes, see crypt_errno.h. |
| 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_SUCCESS | For other error codes, see crypt_errno.h. |
| int32_t CRYPT_EAL_RandSeedWithAdin | ( | uint8_t * | addin, |
| uint32_t | addinLen ) |
Regenerate the seed.
| addin | [IN] Additional data, which can set be NULL. |
| addinLen | [IN] Addtional data length, the range is [0,0x7FFFFFF0]. |
| CRYPT_SUCCESS,if | successful. For other error codes, see crypt_errno.h. |
| void CRYPT_EAL_SetRandCallBack | ( | CRYPT_EAL_RandFunc | func | ) |
set rand func callback
func[in] rand func
| void CRYPT_EAL_SetRandCallBackEx | ( | CRYPT_EAL_RandFuncEx | func | ) |
set rand func callback
func[in] rand func