iPXE
|
Entropy source. More...
#include <stdint.h>
#include <assert.h>
#include <string.h>
#include <errno.h>
#include <ipxe/crypto.h>
#include <ipxe/hash_df.h>
#include <ipxe/entropy.h>
Go to the source code of this file.
Macros | |
#define | EPIPE_REPETITION_COUNT_TEST __einfo_error ( EINFO_EPIPE_REPETITION_COUNT_TEST ) |
#define | EINFO_EPIPE_REPETITION_COUNT_TEST __einfo_uniqify ( EINFO_EPIPE, 0x01, "Repetition count test failed" ) |
#define | EPIPE_ADAPTIVE_PROPORTION_TEST __einfo_error ( EINFO_EPIPE_ADAPTIVE_PROPORTION_TEST ) |
#define | EINFO_EPIPE_ADAPTIVE_PROPORTION_TEST __einfo_uniqify ( EINFO_EPIPE, 0x02, "Adaptive proportion test failed" ) |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static void | repetition_count_test_init (struct entropy_source *source) |
Initialise repetition count test. More... | |
static int | repetition_count_test (struct entropy_source *source, noise_sample_t sample) |
Perform repetition count test. More... | |
static void | adaptive_proportion_test_init (struct entropy_source *source) |
Initialise adaptive proportion test. More... | |
static int | adaptive_proportion_test (struct entropy_source *source, noise_sample_t sample) |
Perform adaptive proportion test. More... | |
static int | get_entropy (struct entropy_source *source, entropy_sample_t *entropy) |
Get entropy sample. More... | |
static void | startup_test_init (struct entropy_source *source) |
Initialise startup test. More... | |
static int | startup_test (struct entropy_source *source) |
Perform startup test. More... | |
int | entropy_enable (struct entropy_source *source) |
Enable entropy gathering. More... | |
static int | entropy_enable_and_test (struct entropy_source *source) |
Enable and test entropy source. More... | |
static int | entropy_enable_working (struct entropy_source **source) |
Enable first working entropy source. More... | |
void | entropy_disable (struct entropy_source *source) |
Disable entropy gathering. More... | |
static uint32_t | make_next_nonce (void) |
Create next nonce value. More... | |
int | get_entropy_input_tmp (min_entropy_t min_entropy, uint8_t *tmp, size_t tmp_len) |
Obtain entropy input temporary buffer. More... | |
REQUIRING_SYMBOL (entropy_enable) | |
REQUIRE_OBJECT (config_entropy) | |
Entropy source.
This algorithm is designed to comply with ANS X9.82 Part 4 (April 2011 Draft) Section 13.3. This standard is unfortunately not freely available.
Definition in file entropy.c.
#define EPIPE_REPETITION_COUNT_TEST __einfo_error ( EINFO_EPIPE_REPETITION_COUNT_TEST ) |
#define EINFO_EPIPE_REPETITION_COUNT_TEST __einfo_uniqify ( EINFO_EPIPE, 0x01, "Repetition count test failed" ) |
#define EPIPE_ADAPTIVE_PROPORTION_TEST __einfo_error ( EINFO_EPIPE_ADAPTIVE_PROPORTION_TEST ) |
#define EINFO_EPIPE_ADAPTIVE_PROPORTION_TEST __einfo_uniqify ( EINFO_EPIPE, 0x02, "Adaptive proportion test failed" ) |
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
static |
Initialise repetition count test.
source | Entropy source |
Definition at line 58 of file entropy.c.
References assert(), entropy_source::repetition_count_test, and test.
Referenced by entropy_enable().
|
static |
Perform repetition count test.
source | Entropy source |
sample | Noise sample |
rc | Return status code |
This is the Repetition Count Test defined in ANS X9.82 Part 2 (October 2011 Draft) Section 8.5.2.1.2.
Definition at line 77 of file entropy.c.
References DBGC, EPIPE_REPETITION_COUNT_TEST, entropy_source::name, entropy_source::repetition_count_test, and test.
Referenced by get_entropy().
|
static |
Initialise adaptive proportion test.
source | Entropy source |
Definition at line 128 of file entropy.c.
References entropy_source::adaptive_proportion_test, ADAPTIVE_PROPORTION_WINDOW_SIZE, assert(), and test.
Referenced by entropy_enable().
|
static |
Perform adaptive proportion test.
source | Entropy source |
sample | Noise sample |
rc | Return status code |
This is the Adaptive Proportion Test for the Most Common Value defined in ANS X9.82 Part 2 (October 2011 Draft) Section 8.5.2.1.3.
Definition at line 151 of file entropy.c.
References entropy_source::adaptive_proportion_test, ADAPTIVE_PROPORTION_WINDOW_SIZE, DBGC, EPIPE_ADAPTIVE_PROPORTION_TEST, entropy_source::name, and test.
Referenced by get_entropy().
|
static |
Get entropy sample.
source | Entropy source |
entropy | Entropy sample |
rc | Return status code |
This is the GetEntropy function defined in ANS X9.82 Part 2 (October 2011 Draft) Section 6.5.1.
Definition at line 225 of file entropy.c.
References adaptive_proportion_test(), get_noise(), entropy_source::rc, rc, and repetition_count_test().
Referenced by get_entropy_input_tmp(), and startup_test().
|
static |
Initialise startup test.
source | Entropy source |
Definition at line 265 of file entropy.c.
References assert(), entropy_source::startup_test, and test.
Referenced by entropy_enable().
|
static |
Perform startup test.
source | Entropy source |
rc | Return status code |
Definition at line 279 of file entropy.c.
References DBGC, get_entropy(), entropy_source::name, rc, entropy_source::startup_test, strerror(), and test.
Referenced by entropy_enable_and_test().
int entropy_enable | ( | struct entropy_source * | source | ) |
Enable entropy gathering.
source | Entropy source |
rc | Return status code |
Definition at line 302 of file entropy.c.
References adaptive_proportion_test_init(), assert(), DBGC, entropy_source::enable, entropy_source::min_entropy_per_sample, entropy_source::name, entropy_source::rc, rc, repetition_count_test_init(), entropy_source::startup_test, startup_test_init(), strerror(), and entropy_startup_test::tested.
Referenced by entropy_enable_and_test(), and entropy_sample().
|
static |
Enable and test entropy source.
source | Entropy source |
rc | Return status code |
Definition at line 337 of file entropy.c.
References assert(), entropy_startup_test::count, DBGC, entropy_disable(), entropy_enable(), entropy_source::name, entropy_source::rc, rc, entropy_source::startup_test, and startup_test().
Referenced by entropy_enable_working().
|
static |
Enable first working entropy source.
source | Entropy source to fill in |
rc | Return status code |
Definition at line 365 of file entropy.c.
References DBGC, ENOENT, entropy_enable_and_test(), ENTROPY_SOURCES, for_each_table_entry, rc, and strerror().
Referenced by get_entropy_input_tmp().
void entropy_disable | ( | struct entropy_source * | source | ) |
Disable entropy gathering.
source | Entropy source |
Definition at line 385 of file entropy.c.
References DBGC, entropy_source::disable, and entropy_source::name.
Referenced by entropy_enable_and_test(), entropy_sample(), and get_entropy_input_tmp().
|
static |
Create next nonce value.
nonce | Nonce |
This is the MakeNextNonce function defined in ANS X9.82 Part 4 (April 2011 Draft) Section 13.3.4.2.
Definition at line 402 of file entropy.c.
References nonce.
Referenced by get_entropy_input_tmp().
int get_entropy_input_tmp | ( | min_entropy_t | min_entropy, |
uint8_t * | tmp, | ||
size_t | tmp_len | ||
) |
Obtain entropy input temporary buffer.
min_entropy | Min-entropy required |
tmp | Temporary buffer |
tmp_len | Length of temporary buffer |
rc | Return status code |
This is (part of) the implementation of the Get_entropy_input function (using an entropy source as the source of entropy input and condensing each entropy source output after each GetEntropy call) as defined in ANS X9.82 Part 4 (April 2011 Draft) Section 13.3.4.2.
Definition at line 425 of file entropy.c.
References __attribute__, assert(), entropy_startup_test::count, data, DBGC, entropy_disable(), entropy_enable_working(), entropy_hash_df_algorithm, get_entropy(), hash_df(), make_next_nonce(), memset(), MIN_ENTROPY, entropy_source::min_entropy_per_sample, MIN_ENTROPY_SCALE, entropy_source::name, nonce, entropy_source::rc, rc, entropy_source::startup_test, entropy_startup_test::tested, and tmp.
Referenced by get_entropy_input().
REQUIRING_SYMBOL | ( | entropy_enable | ) |
REQUIRE_OBJECT | ( | config_entropy | ) |