Loading...
Searching...
No Matches
entropy_source.h File Reference

Detailed Description

#include <stddef.h>
#include <inttypes.h>
#include <assert.h>
+ Include dependency graph for entropy_source.h:

Go to the source code of this file.

Data Structures

struct  entropy_source_tests_rep_t
 Data structure for Repetition Count Test (NIST SP 800-90B 4.4.1). More...
 
struct  entropy_source_tests_prop_t
 Data structure for Adaptive Proportion Test (NIST SP 800-90B 4.4.2). More...
 

Macros

#define ENTROPY_SOURCE_HMIN_SCALE(x)   ((x * (1UL << 16)))
 Scale Min.
 
#define ENTROPY_SOURCE_HMIN_SCALE_BACK(x)   ((float)x / (1UL << 16))
 Scale internal fixed point Min.
 
#define CONFIG_ENTROPY_SOURCE_TESTS_WIN   (512)
 Window size for Adaptive Proportion Test (NIST SP 800-90B 4.4.2).
 
#define CONFIG_ENTROPY_SOURCE_NEUMANN_ABORT   (5)
 Abort factor for von Neumann extractor.
 

Typedefs

typedef int(* entropy_source_sample_func_t) (uint8_t *sample)
 Get one sample of the entropy source.
 

Enumerations

enum  entropy_source_error_t {
  ENTROPY_SOURCE_OK = 0 , ENTROPY_SOURCE_ERR_INIT = -1 , ENTROPY_SOURCE_ERR_CONFIG = -2 , ENTROPY_SOURCE_ERR_TEST_REP = -3 ,
  ENTROPY_SOURCE_ERR_TEST_PROP = -4 , ENTROPY_SOURCE_ERR_TEST_BOTH = -5 , ENTROPY_SOURCE_ERR_COND = -6
}
 Entropy source error codes. More...
 

Functions

int entropy_source_neumann_unbias (entropy_source_sample_func_t func, uint8_t *out, size_t len)
 Applies von Neumann unbiasing.
 
static uint32_t entropy_source_test_rep_cutoff (uint32_t entropy_per_sample)
 Calculate cutoff value for Repetition Count Test (NIST SP 800-90B 4.4.1)
 
static int entropy_source_test_prop_cutoff (uint32_t entropy_per_sample)
 Calculate cutoff value for Adaptive Proportion Test (NIST SP 800-90B 4.4.2)
 
static void entropy_source_test_rep_init (entropy_source_tests_rep_t *state, uint16_t c_rep)
 Initialize structure for Repetition Count Test.
 
static void entropy_source_test_prop_init (entropy_source_tests_prop_t *state, uint16_t c_prop)
 Initialize structure for Adaptive Proportion Test.
 
int entropy_source_test_rep (entropy_source_tests_rep_t *state, uint8_t sample)
 Performs Repetition Count Test (NIST SP 800-90B 4.4.1).
 
int entropy_source_test_prop (entropy_source_tests_prop_t *state, uint8_t sample)
 Performs Adaptive Proportion Test (NIST SP 800-90B 4.4.2).
 
static int entropy_source_test (entropy_source_tests_rep_t *state_rep, entropy_source_tests_prop_t *state_prop, uint8_t sample)
 Convenience function to perform entropy_source_test_rep and entropy_source_test_prop.