iPXE
|
DRBG mechanism. More...
Go to the source code of this file.
Data Structures | |
struct | drbg_state |
A Deterministic Random Bit Generator. More... | |
Macros | |
#define | HMAC_DRBG_ALGORITHM HMAC_DRBG_SHA256 |
Choose HMAC_DRBG using SHA-256. More... | |
#define | DRBG_MAX_SECURITY_STRENGTH HMAC_DRBG_MAX_SECURITY_STRENGTH ( HMAC_DRBG_ALGORITHM ) |
Maximum security strength. More... | |
#define | DRBG_SECURITY_STRENGTH 128 |
Security strength. More... | |
#define | DRBG_MIN_ENTROPY_LEN_BYTES HMAC_DRBG_MIN_ENTROPY_LEN_BYTES ( DRBG_SECURITY_STRENGTH ) |
Minimum entropy input length. More... | |
#define | DRBG_MAX_ENTROPY_LEN_BYTES HMAC_DRBG_MAX_ENTROPY_LEN_BYTES |
Maximum entropy input length. More... | |
#define | DRBG_MAX_PERSONAL_LEN_BYTES HMAC_DRBG_MAX_PERSONAL_LEN_BYTES |
Maximum personalisation string length. More... | |
#define | DRBG_MAX_ADDITIONAL_LEN_BYTES HMAC_DRBG_MAX_ADDITIONAL_LEN_BYTES |
Maximum additional input length. More... | |
#define | DRBG_MAX_GENERATED_LEN_BYTES HMAC_DRBG_MAX_GENERATED_LEN_BYTES |
Maximum length of generated pseudorandom data per request. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static void | drbg_instantiate_algorithm (struct drbg_state *state, const void *entropy, size_t entropy_len, const void *personal, size_t personal_len) |
Instantiate DRBG algorithm. More... | |
static void | drbg_reseed_algorithm (struct drbg_state *state, const void *entropy, size_t entropy_len, const void *additional, size_t additional_len) |
Reseed DRBG algorithm. More... | |
static int | drbg_generate_algorithm (struct drbg_state *state, const void *additional, size_t additional_len, void *data, size_t len) |
Generate pseudorandom bits using DRBG algorithm. More... | |
int | drbg_instantiate (struct drbg_state *state, const void *personal, size_t personal_len) |
Instantiate DRBG. More... | |
int | drbg_reseed (struct drbg_state *state, const void *additional, size_t additional_len) |
Reseed DRBG. More... | |
int | drbg_generate (struct drbg_state *state, const void *additional, size_t additional_len, int prediction_resist, void *data, size_t len) |
Generate pseudorandom bits using DRBG. More... | |
void | drbg_uninstantiate (struct drbg_state *state) |
Uninstantiate DRBG. More... | |
DRBG mechanism.
Definition in file drbg.h.
#define HMAC_DRBG_ALGORITHM HMAC_DRBG_SHA256 |
#define DRBG_MAX_SECURITY_STRENGTH HMAC_DRBG_MAX_SECURITY_STRENGTH ( HMAC_DRBG_ALGORITHM ) |
#define DRBG_SECURITY_STRENGTH 128 |
#define DRBG_MIN_ENTROPY_LEN_BYTES HMAC_DRBG_MIN_ENTROPY_LEN_BYTES ( DRBG_SECURITY_STRENGTH ) |
#define DRBG_MAX_ENTROPY_LEN_BYTES HMAC_DRBG_MAX_ENTROPY_LEN_BYTES |
#define DRBG_MAX_PERSONAL_LEN_BYTES HMAC_DRBG_MAX_PERSONAL_LEN_BYTES |
#define DRBG_MAX_ADDITIONAL_LEN_BYTES HMAC_DRBG_MAX_ADDITIONAL_LEN_BYTES |
#define DRBG_MAX_GENERATED_LEN_BYTES HMAC_DRBG_MAX_GENERATED_LEN_BYTES |
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
inlinestatic |
Instantiate DRBG algorithm.
state | Algorithm state |
entropy | Entropy input |
entropy_len | Length of entropy input |
personal | Personalisation string |
personal_len | Length of personalisation string |
This is the Instantiate_algorithm function defined in ANS X9.82 Part 3-2007 Section 9.2 (NIST SP 800-90 Section 9.1).
Definition at line 70 of file drbg.h.
References HMAC_DRBG_ALGORITHM, HMAC_DRBG_HASH, hmac_drbg_instantiate(), and state.
Referenced by drbg_instantiate().
|
inlinestatic |
Reseed DRBG algorithm.
state | Algorithm state |
entropy | Entropy input |
entropy_len | Length of entropy input |
additional | Additional input |
additional_len | Length of additional input |
This is the Reseed_algorithm function defined in ANS X9.82 Part 3-2007 Section 9.3 (NIST SP 800-90 Section 9.2).
Definition at line 92 of file drbg.h.
References additional, HMAC_DRBG_ALGORITHM, HMAC_DRBG_HASH, hmac_drbg_reseed(), and state.
Referenced by drbg_reseed().
|
inlinestatic |
Generate pseudorandom bits using DRBG algorithm.
state | Algorithm state |
additional | Additional input |
additional_len | Length of additional input |
data | Output buffer |
len | Length of output buffer |
rc | Return status code |
This is the Generate_algorithm function defined in ANS X9.82 Part 3-2007 Section 9.4 (NIST SP 800-90 Section 9.3).
Note that the only permitted error is "reseed required".
Definition at line 117 of file drbg.h.
References additional, data, HMAC_DRBG_ALGORITHM, hmac_drbg_generate(), HMAC_DRBG_HASH, len, and state.
Referenced by drbg_generate().
int drbg_instantiate | ( | struct drbg_state * | state, |
const void * | personal, | ||
size_t | personal_len | ||
) |
Instantiate DRBG.
state | Algorithm state to be initialised |
personal | Personalisation string |
personal_len | Length of personalisation string |
rc | Return status code |
This is the Instantiate_function defined in ANS X9.82 Part 3-2007 Section 9.2 (NIST SP 800-90 Section 9.1).
Only a single security strength is supported, and prediction resistance is always enabled. The nonce is accounted for by increasing the entropy input, as per ANS X9.82 Part 3-2007 Section 8.4.2 (NIST SP 800-90 Section 8.6.7).
Definition at line 78 of file drbg.c.
References assert(), data, DBGC, drbg_instantiate_algorithm(), DRBG_MAX_ENTROPY_LEN_BYTES, DRBG_MAX_PERSONAL_LEN_BYTES, DRBG_MAX_SECURITY_STRENGTH, DRBG_MIN_ENTROPY_LEN_BYTES, DRBG_SECURITY_STRENGTH, ENOTSUP, ERANGE, get_entropy_input(), len, NULL, rc, state, and strerror().
Referenced by rbg_startup().
int drbg_reseed | ( | struct drbg_state * | state, |
const void * | additional, | ||
size_t | additional_len | ||
) |
Reseed DRBG.
state | Algorithm state |
additional | Additional input |
additional_len | Length of additional input |
rc | Return status code |
This is the Reseed_function defined in ANS X9.82 Part 3-2007 Section 9.3 (NIST SP 800-90 Section 9.2).
Prediction resistance is always enabled.
Definition at line 190 of file drbg.c.
References additional, assert(), data, DBGC, DRBG_MAX_ADDITIONAL_LEN_BYTES, DRBG_MAX_ENTROPY_LEN_BYTES, DRBG_MIN_ENTROPY_LEN_BYTES, drbg_reseed_algorithm(), DRBG_SECURITY_STRENGTH, EINVAL, ERANGE, get_entropy_input(), len, NULL, rc, state, and strerror().
Referenced by drbg_generate().
int drbg_generate | ( | struct drbg_state * | state, |
const void * | additional, | ||
size_t | additional_len, | ||
int | prediction_resist, | ||
void * | data, | ||
size_t | len | ||
) |
Generate pseudorandom bits using DRBG.
state | Algorithm state |
additional | Additional input |
additional_len | Length of additional input |
prediction_resist | Prediction resistance is required |
data | Output buffer |
len | Length of output buffer |
rc | Return status code |
This is the Generate_function defined in ANS X9.82 Part 3-2007 Section 9.4 (NIST SP 800-90 Section 9.3).
Requests must be for an integral number of bytes. Only a single security strength is supported. Prediction resistance is supported if requested.
Definition at line 283 of file drbg.c.
References additional, assert(), data, DBGC, drbg_generate_algorithm(), DRBG_MAX_ADDITIONAL_LEN_BYTES, DRBG_MAX_GENERATED_LEN_BYTES, drbg_reseed(), EINVAL, ERANGE, len, NULL, rc, state, and strerror().
Referenced by rbg_generate().
void drbg_uninstantiate | ( | struct drbg_state * | state | ) |
Uninstantiate DRBG.
state | Algorithm state |
This is the Uninstantiate_function defined in ANS X9.82 Part 3-2007 Section 9.5 (NIST SP 800-90 Section 9.4).
Definition at line 423 of file drbg.c.
References assert(), DBGC, memset(), NULL, and state.
Referenced by rbg_shutdown().