Software APIs
dif_csrng_shared.h File Reference

Private code shared between the CSRNG and EDN DIFs. More...

Go to the source code of this file.

Data Structures

struct  csrng_app_cmd
 CSRNG application interface command header parameters. More...
 

Typedefs

typedef enum csrng_app_cmd_id csrng_app_cmd_id_t
 Supported CSRNG application commands.
 
typedef struct csrng_app_cmd csrng_app_cmd_t
 CSRNG application interface command header parameters.
 
typedef enum csrng_app_cmd_type csrng_app_cmd_type_t
 This enum type contains all the different command types for csrng_send_cmd().
 

Enumerations

enum  { kCsrngGenBitsBufferSize = 4 }
 
enum  csrng_app_cmd_id {
  kCsrngAppCmdInstantiate = 1 ,
  kCsrngAppCmdReseed = 2 ,
  kCsrngAppCmdGenerate = 3 ,
  kCsrngAppCmdUpdate = 4 ,
  kCsrngAppCmdUninstantiate = 5
}
 Supported CSRNG application commands. More...
 
enum  csrng_app_cmd_type {
  kCsrngAppCmdTypeCsrng ,
  kCsrngAppCmdTypeEdnSw ,
  kCsrngAppCmdTypeEdnGen ,
  kCsrngAppCmdTypeEdnRes
}
 This enum type contains all the different command types for csrng_send_cmd(). More...
 

Functions

OT_WARN_UNUSED_RESULT uint32_t csrng_cmd_header_build (csrng_app_cmd_id_t id, dif_csrng_entropy_src_toggle_t entropy_src_enable, uint32_t cmd_len, uint32_t generate_len)
 Builds a CSRNG command header.
 
OT_WARN_UNUSED_RESULT dif_result_t csrng_send_app_cmd (mmio_region_t base_addr, csrng_app_cmd_type_t cmd_type, csrng_app_cmd_t cmd)
 Writes application command cmd to the CSRNG_CMD_REQ_REG register.
 

Detailed Description

Private code shared between the CSRNG and EDN DIFs.

Definition in file dif_csrng_shared.h.


Data Structure Documentation

◆ csrng_app_cmd

struct csrng_app_cmd

CSRNG application interface command header parameters.

Definition at line 44 of file dif_csrng_shared.h.

Data Fields
dif_csrng_entropy_src_toggle_t entropy_src_enable Entropy source enable.

Mapped to flag0 in the hardware command interface.

uint32_t generate_len Generate length.

Specified as number of 128bit blocks.

csrng_app_cmd_id_t id Application command.
const dif_csrng_seed_material_t * seed_material Seed material.

Only used in kCsrngAppCmdInstantiate, kCsrngAppCmdReseed and kCsrngAppCmdUpdate commands.

Typedef Documentation

◆ csrng_app_cmd_id_t

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
kCsrngGenBitsBufferSize 

CSRNG genbits buffer size in uint32_t words.

Definition at line 20 of file dif_csrng_shared.h.

◆ csrng_app_cmd_id

Supported CSRNG application commands.

See https://opentitan.org/book/hw/ip/csrng/doc/theory_of_operation.html#command-header for details.

Definition at line 33 of file dif_csrng_shared.h.

◆ csrng_app_cmd_type

This enum type contains all the different command types for csrng_send_cmd().

Enumerator
kCsrngAppCmdTypeCsrng 

Command issued directly to CSRNG.

kCsrngAppCmdTypeEdnSw 

Command issued to CSRNG via the SW_CMD_REQ register of the EDN.

kCsrngAppCmdTypeEdnGen 

Command issued to CSRNG via the GENERATE_CMD register of the EDN.

This type of command will be used in the auto mode of the EDN.

kCsrngAppCmdTypeEdnRes 

Command issued to CSRNG via the RESEED_CMD register of the EDN.

This type of command will be used in the auto mode of the EDN.

Definition at line 70 of file dif_csrng_shared.h.

Function Documentation

◆ csrng_cmd_header_build()

OT_WARN_UNUSED_RESULT uint32_t csrng_cmd_header_build ( csrng_app_cmd_id_t id,
dif_csrng_entropy_src_toggle_t entropy_src_enable,
uint32_t cmd_len,
uint32_t generate_len )

Builds a CSRNG command header.

Build a CSRNG command header following the CSRNG specification. The caller is responsible for verifying the correctness of the parameters passed into this function.

Parameters
idCSRNG command ID.
entropy_src_enableEntropy source enable flag. Mapped to flag0 in the command header.
cmd_lenThe overall command lend. It should be set to the number of seed material words, or zero.
generate_lenNumber of 128bit blocks to request if the command ID is set to kCsrngAppCmdGenerate.
Returns
CSRNG command header in uint32_t format.

Definition at line 21 of file dif_csrng_shared.c.

◆ csrng_send_app_cmd()

OT_WARN_UNUSED_RESULT dif_result_t csrng_send_app_cmd ( mmio_region_t base_addr,
csrng_app_cmd_type_t cmd_type,
csrng_app_cmd_t cmd )

Writes application command cmd to the CSRNG_CMD_REQ_REG register.

Returns the result of the operation.

Definition at line 35 of file dif_csrng_shared.c.