Programmer’s Guide

Initialization

To initialize the ENTROPY_SRC block, see the Device Interface Functions (DIFs) section.

Entropy Processing

Once entropy has been prepared for delivery, it can be consumed by either:

  • hardware connecting to one of the hardware application interfaces of the CSRNG block via one of the EDNs, or by
  • software, for example from the CSRNG software instance or directly via the ENTROPY_DATA register of the ENTROPY_SRC block.

Note that when software makes frequent re-seed requests to CSRNG or read requests to the ENTROPY_DATA register, any entropy seeds stored in the esfinal FIFO of ENTROPY_SRC will quickly get consumed. Once the esfinal FIFO is empty, subsequent entropy seed requests will have to wait the worst case latency time while new entropy is being created.

Entropy Source Module Disable

A useful feature for the ENTROPY_SRC block is the ability to disable it in a graceful matter. Bit 16 in the DEBUG_STATUS should be polled after the ENTROPY_SRC enable bits are cleared in the CONF register. Once the above bit is set, the ENTROPY_SRC block can be safely enabled again.

Disabling Entropy Source does not clear the bits in RECOV_ALERT_STS (see Handling a Recoverable Alert).

Firmware Override / Bypass Modes

The ENTROPY_SRC block supports different ways in which firmware can observe or extract and insert entropy into the entropy flow, e.g., for validation testing or to perform additional firmware-based health tests and conditioning.

This section discusses how to enable the different modes. For more details on the individual modes, refer to Theory of Operations.

Firmware Override - Observe

Using the firmware override function, firmware can observe post-health test entropy bits (including entropy bits used for startup health testing) by reading from the FW_OV_RD_DATA register (observe FIFO), e.g., for validation testing. To this end, firmware has to set the FW_OV_MODE field in the FW_OV_CONTROL register to kMultiBitBool4True.

Note that the post-health test entropy bits collected in the observe FIFO continue to flow through the hardware pipeline and may eventually reach the block hardware interface.

Firmware Override - Extract & Insert

Using the firmware override function, firmware can extract entropy bits by reading from the FW_OV_RD_DATA register (observe FIFO), e.g., for performing additional health tests and/or firmware-based conditioning, and then insert entropy bits back into the entropy flow by writing the FW_OV_WR_DATA register. To this end, firmware has to:

  1. Set the FW_OV_MODE field in the FW_OV_CONTROL register to kMultiBitBool4True.
  2. Set the FW_OV_ENTROPY_INSERT field in the FW_OV_CONTROL register to kMultiBitBool4True.

Note that if the FW_OV_ENTROPY_INSERT field is set to kMultiBitBool4True, post-health test entropy bits do NOT continue to flow through the hardware pipeline. The observe FIFO can store up to 1 kBit of entropy bits before it has to be emptied. If firmware reads from the observe FIFO fast enough that it never runs full, the hardware keeps collecting contiguous entropy bits without limit. Any entropy bits arriving after the observe FIFO is full are being discarded. Firmware has to read out the entire observe FIFO to restart entropy collection. Only entropy bits inserted by firmware by writing the FW_OV_WR_DATA register may eventually reach the block hardware interface.

Also, the hardware startup health testing is skipped and firmware becomes responsible for performing any startup health testing.

Whether hardware conditioning is applied to the inserted entropy bits depends on the FIPS_ENABLE field in the CONF register:

  • kMultiBitBool4True: Firmware has to set the FW_OV_INSERT_START field in the FW_OV_SHA3_START register to kMultiBitBool4True before writing the entropy bits to the FW_OV_WR_DATA register. Afterwards, it sets FW_OV_INSERT_START to kMultiBitBool4False to trigger the hardware conditioning.
  • kMultiBitBool4False: The inserted entropy bits bypass the hardware conditioning (see Hardware Conditioning Bypass).

Hardware Conditioning Bypass

Firmware can enable bypassing of the hardware conditioning inside the ENTROPY_SRC block by setting the FIPS_ENABLE field in the CONF register to kMultiBitBool4False. This disables FIPS mode and enables the bypass or boot-time mode.

Note that in bypass or boot-time mode, a single entropy seed is produced only and health test window sizes other than 384 bits (the seed length) are currently not tested nor supported.

Reading Entropy Output

Firmware can read the entropy output of the ENTROPY_SRC block from the ENTROPY_DATA register. To this end, firmware has to:

  1. Set the ENTROPY_DATA_REG_ENABLE field in the ENTROPY_CONTROL register to kMultiBitBool4True.
  2. Request the routing of a single seed to the ENTROPY_DATA register by writing the ENTROPY_DATA_REQUEST register to kMultiBitBool4True.
  3. Wait for the ENTROPY_DATA_VALID register to read kMultiBitBool4True.
  4. Read the ENTROPY_DATA register twelve times to retrieve the entire 384-bit seed (12 * 32 bits = 384 bits in total).

Firmware should then check the retrieved entropy for repeated or all-zero 32-bit words to guard against FI attacks. In case of doubt, firmware should request another seed and potentially combine the two seeds together by XORing them.

While the request is pending and before ENTROPY_DATA_VALID reads kMultiBitBool4True, no seed is passed to the block hardware interface. Once ENTROPY_DATA_VALID has switched to kMultiBitBool4True, subsequently produced seeds can again be passed to the block hardware interface. This is to ensure that any produced seed is exclusively forwarded to either firmware or to the block hardware interface.

To ensure that a particular seed is only ever read by firmware (e.g. when running in bypass or boot-time mode where the ENTROPY_SRC block produces a single seed only, or when performing a known-answer test of the hardware conditioning in Firmware Override - Extract & Insert mode), firmware has to place the request before the seed of interest is produced, i.e., before enabling the ENTROPY_SRC block in bypass or boot-time mode, or before inserting the entropy bits in Firmware Override - Extract & Insert mode.

Single RNG Bit Mode

The PTRNG entropy source delivers a stream of symbols to ENTROPY_SRC. Each of these symbols contains multiple bits. Firmware can determine whether ENTROPY_SRC should utilize all or only one of the bits that make up a symbol. Per default, the RNG_BIT_ENABLE field in the CONF register is set to kMultiBitBool4False and the whole symbol is used. To enable the single RNG bit mode RNG_BIT_ENABLE has to be set to kMultiBitBool4True. To select which specific bit should be used, the RNG_BIT_SEL field in the CONF register must be set to the number of the desired lane.

When ENTROPY_SRC is configured in RNG bit mode, only a subset of the health tests are applicable and the health test thresholds need to be set to account for this. The Repetition Count Test, Markov test and Adaptive Proportion Test can all still be performed on a single lane. However, to get the same number of entropy bits, we now must collect four times as many individual symbols from the PTRNG. This should be considered when choosing the health test thresholds, whereas the health test window size is adjusted internally. In contrast, the Repetition Count Symbol and Adaptive Proportion Symbol tests as well as the bucket test are not applicable to a single lane. They need to be disabled by setting the corresponding thresholds to the maximum value. The THRESHOLD_SCOPE field in the CONF register is also not applicable to the single lane mode and must be set to kMultiBitBool4False.

Handling a Recoverable Alert

Reasons for a recoverable alert are tracked in the RECOV_ALERT_STS register. Each bit gets set based on the condition in its description. To handle a recoverable alert, go through the bits that are set and resolve the underlying problems, then write zero to each bit to clear it. Disabling Entropy Source does not clear the bits in RECOV_ALERT_STS.

Error conditions

Need to alert the system of a FIFO overflow condition.

Device Interface Functions (DIFs)