44 #define EPIPE_REPETITION_COUNT_TEST \ 45 __einfo_error ( EINFO_EPIPE_REPETITION_COUNT_TEST ) 46 #define EINFO_EPIPE_REPETITION_COUNT_TEST \ 47 __einfo_uniqify ( EINFO_EPIPE, 0x01, "Repetition count test failed" ) 48 #define EPIPE_ADAPTIVE_PROPORTION_TEST \ 49 __einfo_error ( EINFO_EPIPE_ADAPTIVE_PROPORTION_TEST ) 50 #define EINFO_EPIPE_ADAPTIVE_PROPORTION_TEST \ 51 __einfo_uniqify ( EINFO_EPIPE, 0x02, "Adaptive proportion test failed" ) 62 repetition_count_cutoff (
void ) {
63 double max_repetitions;
79 cutoff = max_repetitions;
80 if ( cutoff < max_repetitions )
82 linker_assert ( ( cutoff >= max_repetitions ), rounding_error );
90 repetition_count_cutoff_not_constant );
106 static unsigned int repetition_count = 0;
119 if ( ( sample == most_recent_sample ) && ( repetition_count > 0 ) ) {
127 if ( repetition_count >= repetition_count_cutoff() )
135 most_recent_sample = sample;
138 repetition_count = 1;
156 #define ADAPTIVE_PROPORTION_WINDOW_SIZE 64 165 #define APC_N_H( n, h ) ( ( (n) << 8 ) | (h) ) 177 #define APC_TABLE_ROW( h, c16, c64, c256, c4096, c65536) \ 178 case APC_N_H ( 16, h ) : return c16; \ 179 case APC_N_H ( 64, h ) : return c64; \ 180 case APC_N_H ( 256, h ) : return c256; \ 181 case APC_N_H ( 4096, h ) : return c4096; \ 182 case APC_N_H ( 65536, h ) : return c65536; 198 adaptive_proportion_cutoff_lookup (
unsigned int n,
unsigned int h ) {
234 adaptive_proportion_cutoff (
void ) {
242 cutoff = adaptive_proportion_cutoff_lookup (
n,
h );
246 adaptive_proportion_cutoff_not_constant );
250 adaptive_proportion_cutoff_not_applicable );
267 static unsigned int repetition_count;
290 current_counted_sample = sample;
296 repetition_count = 0;
306 if ( sample == current_counted_sample ) {
315 if ( repetition_count > adaptive_proportion_cutoff() )
370 startup_test_count (
void ) {
380 startup_test_count_not_constant );
421 static unsigned int startup_tested = 0;
435 for ( ; startup_tested < startup_test_count() ; startup_tested++ ) {
437 goto err_get_entropy;
456 goto err_get_entropy;
465 df_buf,
sizeof ( df_buf ) );
466 for ( i = 0 ; i <
tmp_len ; i++ )
struct arbelprm_rc_send_wqe rc
void entropy_disable(void)
Disable entropy gathering.
static __attribute__((always_inline))
Calculate cutoff value for the repetition count test.
#define APC_NA
Value used to represent "N/A" in adaptive proportion cutoff table.
#define MIN_ENTROPY_SCALE
Fixed-point scale for min-entropy amounts.
min_entropy_t min_entropy_per_sample(void)
min-entropy per sample
int get_noise(noise_sample_t *noise)
Get noise sample.
int get_entropy_input_tmp(unsigned int num_samples, uint8_t *tmp, size_t tmp_len)
Obtain entropy input temporary buffer.
Hash-based derivation function (Hash_df)
#define EPIPE_ADAPTIVE_PROPORTION_TEST
static int adaptive_proportion_test(noise_sample_t sample)
Perform adaptive proportion test.
static uint32_t make_next_nonce(void)
Create next nonce value.
#define EPIPE_REPETITION_COUNT_TEST
#define APC_N_H(n, h)
Combine adaptive proportion test window size and min-entropy.
int entropy_enable(void)
Enable entropy gathering.
void hash_df(struct digest_algorithm *hash, const void *input, size_t input_len, void *output, size_t output_len)
Distribute entropy throughout a buffer.
static int repetition_count_test(noise_sample_t sample)
Perform repetition count test.
#define ADAPTIVE_PROPORTION_WINDOW_SIZE
Window size for the adaptive proportion test.
#define APC_TABLE_ROW(h, c16, c64, c256, c4096, c65536)
Define a row of the adaptive proportion cutoff table.
#define MIN_ENTROPY(bits)
Construct a min-entropy fixed-point value.
uint8_t entropy_sample_t
An entropy sample.
static int get_entropy(entropy_sample_t *entropy)
Get entropy sample.
uint8_t data[48]
Additional event data.
uint8_t noise_sample_t
A noise sample.
#define entropy_hash_df_algorithm
Use SHA-256 as the underlying hash algorithm for Hash_df.
#define linker_assert(condition, error_symbol)
Assert a condition at link-time.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
struct ntlm_nonce nonce
Server nonce.
void * memset(void *dest, int character, size_t len) __nonnull