random.h
Functions
| Name | |
|---|---|
| int | wc_InitNetRandom(const char * configFile, wnr_hmac_key hmac_cb, int timeout) Init Global WhiteWood Netrandomのコンテキスト  | 
| int | wc_FreeNetRandom(void ) 無料のGlobal WhiteWood Netrandomコンテキスト。  | 
| int | wc_InitRng(WC_RNG * ) RNGのシード(OSから)とキー暗号を取得します。割り当てられたRNG-> DRBG(決定論的ランダムビットジェネレータ)が割り当てられます(WC_FREERNGで割り当てられている必要があります)。これはブロッキング操作です。  | 
| int | wc_RNG_GenerateBlock(WC_RNG * rng, byte * b, word32 sz) 疑似ランダムデータのSZバイトを出力にコピーします。必要に応じてRNG(ブロッキング)します。  | 
| WC_RNG * | wc_rng_new(byte * nonce, word32 nonceSz, void * heap) 新しいWC_RNG構造を作成します。  | 
| int | wc_FreeRng(WC_RNG * ) RNGがDRGBを安全に解放するために必要なときに呼び出されるべきです。ゼロとXfrees RNG-DRBG。  | 
| WC_RNG * | wc_rng_free(WC_RNG * rng) RNGを安全に自由に解放するためにRNGが不要になったときに呼び出されるべきです。 Example  | 
| int | wc_RNG_HealthTest(int reseed, const byte * entropyA, word32 entropyASz, const byte * entropyB, word32 entropyBSz, byte * output, word32 outputSz) DRBGの機能を作成しテストします。  | 
Attributes
| Name | |
|---|---|
| WC_RNG byte * | b | 
Functions Documentation
function wc_InitNetRandom
int wc_InitNetRandom(
    const char * configFile,
    wnr_hmac_key hmac_cb,
    int timeout
)
Init Global WhiteWood Netrandomのコンテキスト
Parameters:
- configFile 設定ファイルへのパス
 - hmac_cb HMACコールバックを作成するにはオプションです。 Example
 
char* config = "path/to/config/example.conf";
int time = // Some sufficient timeout value;
if (wc_InitNetRandom(config, NULL, time) != 0)
{
    // Some error occurred
}
See: wc_FreeNetRandom
Return:
- 0 成功
 - BAD_FUNC_ARG configfileがnullまたはタイムアウトのどちらかが否定的です。
 - RNG_FAILURE_E RNGの初期化に失敗しました。
 
function wc_FreeNetRandom
int wc_FreeNetRandom(
    void 
)
無料のGlobal WhiteWood Netrandomコンテキスト。
See: wc_InitNetRandom
Return:
- 0 成功
 - BAD_MUTEX_E Wnr_Mutexでミューテックスをロックするエラー Example
 
int ret = wc_FreeNetRandom();
if(ret != 0)
{
    // Handle the error
}
function wc_InitRng
int wc_InitRng(
    WC_RNG * 
)
RNGのシード(OSから)とキー暗号を取得します。割り当てられたRNG-> DRBG(決定論的ランダムビットジェネレータ)が割り当てられます(WC_FREERNGで割り当てられている必要があります)。これはブロッキング操作です。
See:
- wc_InitRngCavium
 - wc_RNG_GenerateBlock
 - wc_RNG_GenerateByte
 - wc_FreeRng
 - wc_RNG_HealthTest
 
Return:
- 0 成功しています。
 - MEMORY_E XMallocに失敗しました
 - WINCRYPT_E WC_GENERATSEED:コンテキストの取得に失敗しました
 - CRYPTGEN_E WC_GENERATSEED:ランダムになりました
 - BAD_FUNC_ARG WC_RNG_GenerateBlock入力はNULLまたはSZがMAX_REQUEST_LENを超えています
 - DRBG_CONT_FIPS_E wc_rng_generateblock:hash_genはdrbg_cont_failureを返しました
 - RNG_FAILURE_E wc_rng_generateBlock:デフォルトエラーです。RNGのステータスはもともとOKではなく、drbg_failedに設定されています Example
 
RNG  rng;
int ret;
#ifdef HAVE_CAVIUM
ret = wc_InitRngCavium(&rng, CAVIUM_DEV_ID);
if (ret != 0){
    printf(“RNG Nitrox init for device: %d failed”, CAVIUM_DEV_ID);
    return -1;
}
#endif
ret = wc_InitRng(&rng);
if (ret != 0){
    printf(“RNG init failed”);
    return -1;
}
function wc_RNG_GenerateBlock
int wc_RNG_GenerateBlock(
    WC_RNG * rng,
    byte * b,
    word32 sz
)
疑似ランダムデータのSZバイトを出力にコピーします。必要に応じてRNG(ブロッキング)します。
Parameters:
- rng 乱数発生器はWC_INITRNGで初期化された
 - output ブロックがコピーされるバッファ Example
 
RNG  rng;
int  sz = 32;
byte block[sz];
int ret = wc_InitRng(&rng);
if (ret != 0) {
    return -1; //init of rng failed!
}
ret = wc_RNG_GenerateBlock(&rng, block, sz);
if (ret != 0) {
    return -1; //generating block failed!
}
See:
- wc_InitRngCavium, wc_InitRng
 - wc_RNG_GenerateByte
 - wc_FreeRng
 - wc_RNG_HealthTest
 
Return:
- 0 成功した
 - BAD_FUNC_ARG 入力はNULLまたはSZがMAX_REQUEST_LENを超えています
 - DRBG_CONT_FIPS_E hash_genはdrbg_cont_failureを返しました
 - RNG_FAILURE_E デフォルトのエラーRNGのステータスはもともとOKではなく、drbg_failedに設定されています
 
function wc_rng_new
WC_RNG * wc_rng_new(
    byte * nonce,
    word32 nonceSz,
    void * heap
)
新しいWC_RNG構造を作成します。
Parameters:
- heap ヒープ識別子へのポインタ
 - nonce nonceを含むバッファへのポインタ Example
 
RNG  rng;
byte nonce[] = { initialize nonce };
word32 nonceSz = sizeof(nonce);
wc_rng_new(&nonce, nonceSz, &heap);
- rng 乱数発生器はWC_INITRNGで初期化された Example
 
RNG  rng;
int  sz = 32;
byte b[1];
int ret = wc_InitRng(&rng);
if (ret != 0) {
    return -1; //init of rng failed!
}
ret = wc_RNG_GenerateByte(&rng, b);
if (ret != 0) {
    return -1; //generating block failed!
}
See:
- wc_InitRng
 - wc_rng_free
 - wc_FreeRng
 - wc_RNG_HealthTest
 - wc_InitRngCavium
 - wc_InitRng
 - wc_RNG_GenerateBlock
 - wc_FreeRng
 - wc_RNG_HealthTest
 
Return:
- WC_RNG 成功の構造
 - NULL 誤りに
 - 0 成功した
 - BAD_FUNC_ARG 入力はNULLまたはSZがMAX_REQUEST_LENを超えています
 - DRBG_CONT_FIPS_E hash_genはdrbg_cont_failureを返しました
 - RNG_FAILURE_E デフォルトのエラーRNGのステータスはもともとOKではなく、drbg_failedに設定されています
 
wc_rng_generateBlockを呼び出して、疑似ランダムデータのバイトをbにコピーします。必要に応じてRNGが再販されます。
function wc_FreeRng
int wc_FreeRng(
    WC_RNG * 
)
RNGがDRGBを安全に解放するために必要なときに呼び出されるべきです。ゼロとXfrees RNG-DRBG。
See:
- wc_InitRngCavium
 - wc_InitRng
 - wc_RNG_GenerateBlock
 - wc_RNG_GenerateByte,
 - wc_RNG_HealthTest
 
Return:
- 0 成功した
 - BAD_FUNC_ARG RNGまたはRNG-> DRGB NULL
 - RNG_FAILURE_E DRBGの割り当て解除に失敗しました Example
 
RNG  rng;
int ret = wc_InitRng(&rng);
if (ret != 0) {
    return -1; //init of rng failed!
}
int ret = wc_FreeRng(&rng);
if (ret != 0) {
    return -1; //free of rng failed!
}
function wc_rng_free
WC_RNG * wc_rng_free(
    WC_RNG * rng
)
RNGを安全に自由に解放するためにRNGが不要になったときに呼び出されるべきです。 Example
See:
RNG  rng;
byte nonce[] = { initialize nonce };
word32 nonceSz = sizeof(nonce);
rng = wc_rng_new(&nonce, nonceSz, &heap);
// use rng
wc_rng_free(&rng);
function wc_RNG_HealthTest
int wc_RNG_HealthTest(
    int reseed,
    const byte * entropyA,
    word32 entropyASz,
    const byte * entropyB,
    word32 entropyBSz,
    byte * output,
    word32 outputSz
)
DRBGの機能を作成しテストします。
Parameters:
- int RESEED:設定されている場合は、Reseed機能をテストします
 - entropyA DRGBをインスタンス化するエントロピー
 - entropyASz バイト数のエントロピヤのサイズ
 - entropyB Reseed Setを設定した場合、DRBGはEntropybでリサイードされます
 - entropyBSz バイト単位のEntropybのサイズ
 - output SEADRANDOMが設定されている場合は、Entropybに播種されたランダムなデータに初期化され、それ以外の場合はEntropya Example
 
byte output[SHA256_DIGEST_SIZE * 4];
const byte test1EntropyB[] = ....; // test input for reseed false
const byte test1Output[] = ....;   // testvector: expected output of
                               // reseed false
ret = wc_RNG_HealthTest(0, test1Entropy, sizeof(test1Entropy), NULL, 0,
                    output, sizeof(output));
if (ret != 0)
    return -1;//healthtest without reseed failed
if (XMEMCMP(test1Output, output, sizeof(output)) != 0)
    return -1; //compare to testvector failed: unexpected output
const byte test2EntropyB[] = ....; // test input for reseed
const byte test2Output[] = ....;   // testvector expected output of reseed
ret = wc_RNG_HealthTest(1, test2EntropyA, sizeof(test2EntropyA),
                    test2EntropyB, sizeof(test2EntropyB),
                    output, sizeof(output));
if (XMEMCMP(test2Output, output, sizeof(output)) != 0)
    return -1; //compare to testvector failed
See:
- wc_InitRngCavium
 - wc_InitRng
 - wc_RNG_GenerateBlock
 - wc_RNG_GenerateByte
 - wc_FreeRng
 
Return:
- 0 成功した
 - BAD_FUNC_ARG ELTOPYAと出力はNULLにしないでください。Reseed Set EntropybがNULLでなければならない場合
 - -1 テスト失敗
 
Attributes Documentation
variable b
WC_RNG byte * b;
Source code
int  wc_InitNetRandom(const char* configFile, wnr_hmac_key hmac_cb, int timeout);
int  wc_FreeNetRandom(void);
int  wc_InitRng(WC_RNG*);
int  wc_RNG_GenerateBlock(WC_RNG* rng, byte* b, word32 sz);
WC_RNG* wc_rng_new(byte* nonce, word32 nonceSz, void* heap)
int  wc_RNG_GenerateByte(WC_RNG* rng, byte* b);
int  wc_FreeRng(WC_RNG*);
WC_RNG* wc_rng_free(WC_RNG* rng);
int wc_RNG_HealthTest(int reseed,
                                        const byte* entropyA, word32 entropyASz,
                                        const byte* entropyB, word32 entropyBSz,
                                        byte* output, word32 outputSz);
Updated on 2025-11-04 at 02:51:06 +0000