Entropy Distribution Network Device Interface Functions More...
#include <stdint.h>
#include "sw/device/lib/base/macros.h"
#include "sw/device/lib/base/mmio.h"
#include "sw/device/lib/dif/dif_base.h"
#include "sw/device/lib/dif/autogen/dif_edn_autogen.h"
Go to the source code of this file.
Data Structures | |
struct | dif_edn_seed_material |
CSRNG seed material for instantiate, reseed and generate commands. More... | |
struct | dif_edn_cmd |
CSRNG command parameters for instantiate, reseed and generate commands. More... | |
struct | dif_edn_auto_params |
Auto-generate EDN module configuration parameters. More... | |
Typedefs | |
typedef struct dif_edn_seed_material | dif_edn_seed_material_t |
CSRNG seed material for instantiate, reseed and generate commands. | |
typedef struct dif_edn_cmd | dif_edn_cmd_t |
CSRNG command parameters for instantiate, reseed and generate commands. | |
typedef struct dif_edn_auto_params | dif_edn_auto_params_t |
Auto-generate EDN module configuration parameters. | |
typedef enum dif_edn_status | dif_edn_status_t |
EDN Status flags. | |
typedef enum dif_edn_sm_state | dif_edn_sm_state_t |
EDN SM states as defined in the EDN state machine RTL. | |
typedef enum dif_edn_fifo | dif_edn_fifo_t |
Enumeration of EDN FIFOs, which indicates which part of the hardware produced an error. | |
typedef enum dif_edn_error | dif_edn_error_t |
Enumeration of EDN FIFO errors. | |
typedef enum dif_edn_entropy_src_toggle | dif_edn_entropy_src_toggle_t |
CSRNG consume seed from entropy source enable. | |
typedef enum dif_edn_recoverable_alert | dif_edn_recoverable_alert_t |
Recoverable alerts emitted by the EDN. | |
Entropy Distribution Network Device Interface Functions
This API implements the interface for the Entropy Distribution Network (EDN) hardware.
There are two main modes of operation:
Definition in file dif_edn.h.
struct dif_edn_seed_material |
CSRNG seed material for instantiate, reseed and generate commands.
Data Fields | ||
---|---|---|
uint32_t | data[kDifEntropySeedMaterialMaxWordLen] | Seed material used in CSRNG instantiate, reseed or generate call. |
size_t | len |
Number of uint32_t words in data . Up to |
struct dif_edn_cmd |
CSRNG command parameters for instantiate, reseed and generate commands.
Data Fields | ||
---|---|---|
uint32_t | cmd |
The CSRNG application interface command header. For details, refer to the CSRNG documentation. |
dif_edn_seed_material_t | seed_material | Optional seed material. |
struct dif_edn_auto_params |
Data Fields | ||
---|---|---|
dif_edn_cmd_t | generate_cmd | CSRNG generate command material. |
dif_edn_cmd_t | instantiate_cmd | CSRNG instantiate command material. |
dif_edn_cmd_t | reseed_cmd | CSRNG reseed command material. |
uint32_t | reseed_interval | Number of generate calls that can be made before a reseed request is made. |
anonymous enum |
anonymous enum |
anonymous enum |
anonymous enum |
CSRNG consume seed from entropy source enable.
enum dif_edn_error |
Enumeration of EDN FIFO errors.
Recoverable alerts emitted by the EDN.
enum dif_edn_sm_state |
EDN SM states as defined in the EDN state machine RTL.
enum dif_edn_status |
EDN Status flags.
OT_WARN_UNUSED_RESULT dif_result_t dif_edn_clear_recoverable_alerts | ( | const dif_edn_t * | edn | ) |
OT_WARN_UNUSED_RESULT dif_result_t dif_edn_configure | ( | const dif_edn_t * | edn | ) |
OT_WARN_UNUSED_RESULT dif_result_t dif_edn_generate_start | ( | const dif_edn_t * | edn, |
size_t | len | ||
) |
Requests cryptographic entropy bits from the CSRNG.
The prediction resistance flag as specified in SP 800-90Ar1 section 10.2.1.1 is not directly supported by the hardware. It is the responsibility of the caller to reseed as needed before calling this function.
The CSRNG accepts generation requests with 128-bit granularity, with a minimum 128-bit request size. This function will increase the size of the request to align it to the nearest 128-bit boundary.
edn | An EDN handle. |
len | Number of uint32_t words to generate. |
len
parameter results in a 128bit block level size greater than 0x800. OT_WARN_UNUSED_RESULT dif_result_t dif_edn_get_cmd_error_force | ( | const dif_edn_t * | edn, |
dif_edn_error_t | error | ||
) |
OT_WARN_UNUSED_RESULT dif_result_t dif_edn_get_cmd_unhealthy_fifo_force | ( | const dif_edn_t * | edn, |
dif_edn_fifo_t | fifo | ||
) |
OT_WARN_UNUSED_RESULT dif_result_t dif_edn_get_errors | ( | const dif_edn_t * | edn, |
uint32_t * | unhealthy_fifos, | ||
uint32_t * | errors | ||
) |
Queries the EDN error flags.
edn | An EDN handle. | |
[out] | unhealthy_fifos | Bitset of FIFOs in an unhealthy state; indices are dif_edn_fifo_t . |
[out] | errors | Bitset of errors relating to the above FIFOs; indices are dif_edn_error_t . |
OT_WARN_UNUSED_RESULT dif_result_t dif_edn_get_main_state_machine | ( | const dif_edn_t * | edn, |
uint32_t * | state | ||
) |
OT_WARN_UNUSED_RESULT dif_result_t dif_edn_get_recoverable_alerts | ( | const dif_edn_t * | edn, |
uint32_t * | alerts | ||
) |
Gets the recoverable alerts currently recorded in the EDN block.
This function returns the alerts in a bitset whose indices are given by dif_edn_recoverable_alert_t
.
edn | An EDN handle. | |
[out] | alerts | Bitset of alerts currently recorded. |
OT_WARN_UNUSED_RESULT dif_result_t dif_edn_get_status | ( | const dif_edn_t * | edn, |
dif_edn_status_t | flag, | ||
bool * | set | ||
) |
OT_WARN_UNUSED_RESULT dif_result_t dif_edn_instantiate | ( | const dif_edn_t * | edn, |
dif_edn_entropy_src_toggle_t | entropy_src_enable, | ||
const dif_edn_seed_material_t * | seed_material | ||
) |
Initializes CSRNG instance with a new seed value.
seed_material
is used as specified in NIST SP 800-90Ar1 section 10.2.1.3.1.
seed_material
can be NULL, in which case CSRNG will use a zero vector instead.
edn | An EDN handle. |
entropy_src_enable | Entropy source input enable. |
seed_material | Seed initialization parameters. |
OT_WARN_UNUSED_RESULT dif_result_t dif_edn_is_locked | ( | const dif_edn_t * | edn, |
bool * | is_locked | ||
) |
OT_WARN_UNUSED_RESULT dif_result_t dif_edn_lock | ( | const dif_edn_t * | edn | ) |
OT_WARN_UNUSED_RESULT dif_result_t dif_edn_reseed | ( | const dif_edn_t * | edn, |
const dif_edn_seed_material_t * | seed_material | ||
) |
Reseeds CSRNG instance.
When seed_material.seed_material_len
is set to 0, only the entropy source seed is used to reseed the instance, otherwise it will be XOR'ed with the entropy source.
edn | An EDN handle. |
seed_material | Reseed parameters. |
OT_WARN_UNUSED_RESULT dif_result_t dif_edn_set_auto_mode | ( | const dif_edn_t * | edn, |
dif_edn_auto_params_t | config | ||
) |
Enables the EDN in auto refresh mode.
Each call to this function should be sequenced with a call to dif_edn_stop()
.
edn | An EDN handle. |
config | Auto request configuration parameters. |
OT_WARN_UNUSED_RESULT dif_result_t dif_edn_set_boot_mode | ( | const dif_edn_t * | edn | ) |
Enables the EDN in boot-time mode.
Each call to this function should be sequenced with a call to dif_edn_stop()
.
edn | An EDN handle. |
OT_WARN_UNUSED_RESULT dif_result_t dif_edn_stop | ( | const dif_edn_t * | edn | ) |
OT_WARN_UNUSED_RESULT dif_result_t dif_edn_uninstantiate | ( | const dif_edn_t * | edn | ) |
Uninstantiates CSRNG.
Resets the CSRNG instance. Values in the CSRNG are zeroed out. This command effectively resets the CSRNG, clearing any errors that it may have encountered due to processing or entropy source errors.
edn | An EDN handle. |
OT_WARN_UNUSED_RESULT dif_result_t dif_edn_update | ( | const dif_edn_t * | edn, |
const dif_edn_seed_material_t * | seed_material | ||
) |
Updates CSRNG state.
This function is similar to dif_edn_reseed()
, except:
seed_material.seed_material
is used in the update operation.edn | An EDN handle. |
seed_material | Update parameters. |