Contains the public API and documentation for the HCG pseudo-random bytes generator. More...
Go to the source code of this file.
Data Structures | |
| struct | qsc_hcg_state |
| The HCG state structure. More... | |
Functions | |
| QSC_EXPORT_API void | qsc_hcg_dispose (qsc_hcg_state *ctx) |
| Dispose of the HCG DRBG state. | |
| QSC_EXPORT_API void | qsc_hcg_initialize (qsc_hcg_state *ctx, const uint8_t *seed, size_t seedlen, const uint8_t *info, size_t infolen, bool pres) |
| Initialize the pseudo-random provider state with a seed and optional personalization string. | |
| QSC_EXPORT_API void | qsc_hcg_generate (qsc_hcg_state *ctx, uint8_t *output, size_t otplen) |
| Generate pseudo-random bytes using the generator. | |
| QSC_EXPORT_API void | qsc_hcg_update (qsc_hcg_state *ctx, const uint8_t *seed, size_t seedlen) |
| Update the generator with new keying material. | |
Contains the public API and documentation for the HCG pseudo-random bytes generator.
The HCG (HMAC-based Custom Generator) pseudo-random bytes generator is designed to produce pseudo-random bytes using an HMAC-based construction similar to the HKDF Expand key derivation function. It utilizes a 128-bit nonce, a default info parameter, and supports predictive resistance. When predictive resistance is enabled, new random seed material is injected at initialization and at defined output boundaries (default: 64 kilobytes) to convert the generator from deterministic to non-deterministic. The generator state can be updated with new seed material via the update function, and the dispose function must be called to securely erase the state.
| QSC_EXPORT_API void qsc_hcg_dispose | ( | qsc_hcg_state * | ctx | ) |
Dispose of the HCG DRBG state.
| ctx | [qsc_hcg_state*] A pointer to the HCG state structure. |
| QSC_EXPORT_API void qsc_hcg_generate | ( | qsc_hcg_state * | ctx, |
| uint8_t * | output, | ||
| size_t | otplen ) |
Generate pseudo-random bytes using the generator.
| ctx | [qsc_hcg_state*] A pointer to the HCG state structure. |
| output | [uint8_t*] A pointer to the output buffer that will receive the pseudo-random bytes. |
| otplen | [size_t] The requested number of bytes to generate. |
| QSC_EXPORT_API void qsc_hcg_initialize | ( | qsc_hcg_state * | ctx, |
| const uint8_t * | seed, | ||
| size_t | seedlen, | ||
| const uint8_t * | info, | ||
| size_t | infolen, | ||
| bool | pres ) |
Initialize the pseudo-random provider state with a seed and optional personalization string.
| ctx | [qsc_hcg_state*] A pointer to the HCG state structure. |
| seed | [const uint8_t*] A pointer to the random seed. (32 bytes instantiates a 256-bit generator; 64 bytes instantiates a 512-bit generator.) |
| seedlen | [size_t] The length of the input seed in bytes. |
| info | [const uint8_t*] A pointer to the optional personalization string. |
| infolen | [size_t] The length of the personalization string in bytes. |
| pres | [bool] Enable predictive resistance; if true, random seed material is injected periodically. |
| QSC_EXPORT_API void qsc_hcg_update | ( | qsc_hcg_state * | ctx, |
| const uint8_t * | seed, | ||
| size_t | seedlen ) |
Update the generator with new keying material.
The new seed material is absorbed into the HMAC state.
| ctx | [qsc_hcg_state*] A pointer to the HCG state structure. |
| seed | [const uint8_t*] A pointer to the random update seed. |
| seedlen | [size_t] The length of the update seed in bytes. |