Software APIs
entropy_src_testutils.h
1// Copyright lowRISC contributors (OpenTitan project).
2// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3// SPDX-License-Identifier: Apache-2.0
4
5#ifndef OPENTITAN_SW_DEVICE_LIB_TESTING_ENTROPY_SRC_TESTUTILS_H_
6#define OPENTITAN_SW_DEVICE_LIB_TESTING_ENTROPY_SRC_TESTUTILS_H_
7
8#include "sw/device/lib/base/status.h"
10
11/**
12 * Initializes the entropy_src in firmware override mode.
13 *
14 * CSRNG and EDN instances are not initialized by calling this function compared
15 * to the test init functions in entropy_testutils.
16 *
17 * @param entropy_src Entropy source handle.
18 * @param buffer_threshold Firmware override buffer threshold.
19 * @param firmware_override_enable Set to true to output entropy data to
20 * registers instead of the CSRNG block.
21 * @param bypass_conditioner Set to true to bypass the entropy_src conditioner.
22 */
24status_t entropy_src_testutils_fw_override_enable(
25 dif_entropy_src_t *entropy_src, uint8_t buffer_threshold,
26 bool firmware_override_enable, bool bypass_conditioner);
27
28/**
29 * Drain the `entropy_src` FW override mode observe FIFO.
30 */
32status_t entropy_src_testutils_drain_observe_fifo(
33 dif_entropy_src_t *entropy_src);
34
35/**
36 * Waits for the entropy_src to reach a certain state.
37 *
38 * @param entropy_src Entropy source handle.
39 * @param state Entropy source target FSM state.
40 */
42status_t entropy_src_testutils_wait_for_state(
43 const dif_entropy_src_t *entropy_src, dif_entropy_src_main_fsm_t state);
44
45/**
46 * Disables all entropy source health tests.
47 */
49status_t entropy_src_testutils_disable_health_tests(
50 dif_entropy_src_t *entropy_src);
51
52#endif // OPENTITAN_SW_DEVICE_LIB_TESTING_ENTROPY_SRC_TESTUTILS_H_