MPHELL  4.0.0
Data Structures | Typedefs | Enumerations | Functions | Variables
mphell-random.h File Reference

Declaration of random functions. More...

#include "mphell-drbg.h"
Include dependency graph for mphell-random.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  random_state_t
 Define a random state. More...
 

Typedefs

typedef enum random_algo random_type
 Define the random algorithm (DRBG algorithm)
 
typedef random_state_t random_state[1]
 Address of a random_state_t structure.
 

Enumerations

enum  random_algo {
  RANDOM_INTEL, RANDOM_AES128, RANDOM_AES192, RANDOM_AES256,
  RANDOM_SHA1, RANDOM_SHA256, STM32F4_RNG, RANDOM_UNSET
}
 Define the random algorithm (DRBG algorithm) More...
 

Functions

void random_instantiate (mphell_status ret, random_state initial_state, const uint16_t requested_instantiation_security_strength, const uint8_t *personalization_string, const uint64_t pers_length, const random_type type, const entropy_type entropy, uint64_t reseed_interval)
 Instantiate one random state. More...
 
void random_reseed (mphell_status ret, random_state working_state, const uint16_t entropy_length, const entropy_type entropy_src, const uint8_t *additional_input, const uint64_t add_length)
 Reseed the DRBG (if you want to reseed it before it does by itself) More...
 
void random_generate (mphell_status ret, uint8_t *returned_bytes, random_state working_state, const uint32_t requested_number_of_bytes, const uint16_t requested_security_strength, const uint8_t *additionnal_input, const uint64_t add_length)
 Gererate an array of random bits. More...
 
void random_uninstantiate (mphell_status ret, random_state working_state)
 Uninstantiate a random state. More...
 

Variables

void(* stm32f4_rng )(mphell_status ret, uint8_t *data, const uint16_t length)
 This function pointer must be set in the stm32f4 application before calling init_mphell.
 

Detailed Description

Declaration of random functions.

Definition in file mphell-random.h.

Enumeration Type Documentation

◆ random_algo

Define the random algorithm (DRBG algorithm)

Enumerator
RANDOM_INTEL 

Use the RDRAND instruction, available since Ivy Bridge ("third generation" of the Intel Core processors)

RANDOM_AES128 

Use AES with 128 bits key

RANDOM_AES192 

Use AES with 192 bits key

RANDOM_AES256 

Use AES with 256 bits key

RANDOM_SHA1 

Use SHA1

RANDOM_SHA256 

Use SHA256

STM32F4_RNG 

Use the STM32F4 True Random Generator

RANDOM_UNSET 

Used when no random algorithm is specified

Definition at line 35 of file mphell-random.h.

Function Documentation

◆ random_generate()

void random_generate ( mphell_status  ret,
uint8_t *  returned_bytes,
random_state  working_state,
const uint32_t  requested_number_of_bytes,
const uint16_t  requested_security_strength,
const uint8_t *  additional_input,
const uint64_t  add_length 
)

Gererate an array of random bits.

Parameters
retSet to MPHELL_ERROR_RANDOM if an error occur, MPHELL_SUCCESS otherwise
returned_bytesDestination array (of requested_number_of_bytes random bits)
working_stateDefine which DRBG state to use
requested_number_of_bytesNumber of random bits required
requested_security_strengthSecurity (in bits) required
additionnal_inputA string given by the user can be added to the material seed to reseed the DRBG
add_lengthLength of additional_input

Definition at line 367 of file mphell-random.c.

◆ random_instantiate()

void random_instantiate ( mphell_status  ret,
random_state  initial_state,
const uint16_t  requested_instantiation_security_strength,
const uint8_t *  personalization_string,
const uint64_t  pers_length,
const random_type  type,
const entropy_type  entropy,
uint64_t  reseed_interval 
)

Instantiate one random state.

Parameters
retSet to MPHELL_ERROR_RANDOM if an error occur, MPHELL_SUCCESS otherwise
initial_stateDestination structure, store the random algorithm and the number of the DRBG state used.
requested_instantiation_security_strengthSecurity (in bits) required
personalization_stringA string given by the user can be added to the material seed to instantiate the DRBG
pers_lengthLength of personalization_string
typeRandom algorithm to use (RANDOM_INTEL, RANDOM_AES128, RANDOM_AES192, RANDOM_AES256, RANDOM_SHA1, RANDOM_SHA256)
entropyEntropy to use (to seed the DRBG): INTEL, DEVURANDOM, DEVRANDOM
reseed_intervalReseed interval, must be between 1 (prediction resistance == true) and 2^48

Definition at line 29 of file mphell-random.c.

◆ random_reseed()

void random_reseed ( mphell_status  ret,
random_state  working_state,
const uint16_t  entropy_length,
const entropy_type  entropy_src,
const uint8_t *  additional_input,
const uint64_t  add_length 
)

Reseed the DRBG (if you want to reseed it before it does by itself)

Parameters
retSet to MPHELL_ERROR_RANDOM if an error occur, MPHELL_SUCCESS otherwise
working_stateDefine which DRBG state to use
entropy_lengthNumber of bits to extract from the entropy source
entropy_srcEntropy to use (to seed the DRBG): INTEL, DEVURANDOM, DEVRANDOM
additional_inputA string given by the user can be added to the material seed to reseed the DRBG
add_lengthLength of additional_input

Definition at line 226 of file mphell-random.c.

◆ random_uninstantiate()

void random_uninstantiate ( mphell_status  ret,
random_state  working_state 
)

Uninstantiate a random state.

Parameters
retSet to MPHELL_ERROR_RANDOM if an error occur, MPHELL_SUCCESS otherwise
working_stateRandom state to uninstantiate

Definition at line 427 of file mphell-random.c.