Software APIs
rnd.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_SILICON_CREATOR_LIB_DRIVERS_RND_H_
6
#define OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_DRIVERS_RND_H_
7
8
#include "
sw/device/lib/base/hardened.h
"
9
#include "
sw/device/lib/base/macros.h
"
10
#include "sw/device/silicon_creator/lib/drivers/lifecycle.h"
11
#include "sw/device/silicon_creator/lib/error.h"
12
13
#ifdef __cplusplus
14
extern
"C"
{
15
#endif
16
17
/**
18
* Compare the CRC32 of the configuration registers with the boot-time / bypass
19
* mode or FIPS / CC compliant value in OTP.
20
*
21
* This function does not check the CRC32 in TEST_UNLOCKED* life cycle states to
22
* allow a test program to configure the entropy src before transitioning to
23
* other life cycle states.
24
*
25
* @param lc_state Life cycle state of the device.
26
* @param boot_mode Whether the configuration should be checked against the
27
* boot-time / bypass mode digest.
28
* @return result of the operation.
29
*/
30
OT_WARN_UNUSED_RESULT
31
rom_error_t rnd_health_config_check(lifecycle_state_t lc_state,
32
hardened_bool_t
boot_mode);
33
34
/**
35
* Returns a random word from the RISC-V Ibex core wrapper.
36
*
37
* Requires the CREATOR_SW_CFG_RNG_EN OTP value set to `kHardenedBoolTrue`
38
* in order to enable the use of entropy, otherwise it only returns the current
39
* value of the MCYCLE CSR register.
40
*
41
* @returns MCYCLE CSR + entropy value.
42
*/
43
OT_WARN_UNUSED_RESULT
44
uint32_t rnd_uint32(
void
);
45
46
#ifdef __cplusplus
47
}
48
#endif
49
50
#endif
// OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_DRIVERS_RND_H_
sw
device
silicon_creator
lib
drivers
rnd.h
Return to
OpenTitan Documentation