48#define COLUMN_COUNT 50
51static const uint8_t toeplitz[COLUMN_COUNT + ROW_COUNT - 1] = {
52 93, 50, 210, 134, 79, 52, 237, 192, 40, 201,
53 3, 184, 152, 74, 27, 28, 32, 111, 79, 222,
54 174, 51, 223, 66, 152, 211, 234, 124, 92, 64,
55 206, 169, 227, 155, 106, 87, 207, 135, 238, 101,
56 254, 163, 55, 76, 50, 40, 4, 149, 27, 1,
57 127, 159, 160, 91, 251, 179, 186, 200, 225, 47,
63get_toeplitz_element(uint8_t row, uint8_t column)
67 min = row < column ? row : column;
71 return toeplitz[row ? COLUMN_COUNT - 1 + row : column];
82 for(i = 0; i < 8; i++) {
105 for(row = 0; row < ROW_COUNT; row++) {
107 for(column = 0; column < COLUMN_COUNT; column++) {
108 target[row] ^=
mul_gf_256(get_toeplitz_element(row, column), source[column]);
114seed_16_bytes(uint8_t *result)
119 uint8_t accumulator[COLUMN_COUNT];
124 memset(accumulator, 0, COLUMN_COUNT);
126 if(!NETSTACK_RADIO.on()) {
129 for(iq_count = 0; iq_count < (COLUMN_COUNT * 8 / 2); iq_count++) {
131 NETSTACK_RADIO.off();
136 accumulator[byte_pos] |= iq << bit_pos;
143 NETSTACK_RADIO.off();
153 if(!seed_16_bytes(seed.
key) || !seed_16_bytes(seed.
state)) {
static uint8_t mul_gf_256(uint8_t a, uint8_t b)
Performs a multiplication within GF(256)
void csprng_feed(struct csprng_seed *new_seed)
Mixes a new seed with the current one.
static void extract(uint8_t *target, uint8_t *source)
Toeplitz matrix-based extractor.
bool iq_seeder_seed(void)
This function will feed the CSPRNG with a new seed.
int radio_value_t
Each radio has a set of parameters that designate the current configuration and state of the radio.
@ RADIO_RESULT_OK
The parameter was set/read successfully.
@ RADIO_PARAM_IQ_LSBS
The current I/Q LSBs.
Include file for the Contiki low-layer network stack (NETSTACK)
This is the structure of a seed.
uint8_t state[AES_128_BLOCK_SIZE]
internal state of the CSPRNG
uint8_t key[AES_128_KEY_LENGTH]
AES-128 key of the CSPRNG.