Software APIs
otbn_randomness_impl.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_TESTS_OTBN_RANDOMNESS_IMPL_H_
6 #define OPENTITAN_SW_DEVICE_TESTS_OTBN_RANDOMNESS_IMPL_H_
7 
8 #include <stdbool.h>
9 
11 
12 /**
13  * Prepares the OTBN randomness test.
14  *
15  * Does the same as otbn_randomness_test_start() without
16  * executing the test.
17  *
18  * @param otbn A OTBN dif handle.
19  * @param iters The number of entropy requests to the RND CSR.
20  */
21 void otbn_randomness_test_prepare(dif_otbn_t *otbn, uint32_t iters);
22 
23 /**
24  * Starts OTBN randomness test.
25  *
26  * Requires EDN0 and EDN1 to be serving entropy, as well as an initialized
27  * `otbn` runtime handle. A Randomness test is loaded into OTBN. Use the
28  * `otbn_randomness_test_end()` function to check the test status. This function
29  * is non-blocking.
30  *
31  * @param otbn A OTBN dif handle.
32  * @param iters The number of entropy requests to the RND CSR.
33  */
34 void otbn_randomness_test_start(dif_otbn_t *otbn, uint32_t iters);
35 
36 /**
37  * Checks the OTBN randomness test result.
38  *
39  * This function must be called after `otbn_randomness_test_start()`.
40  *
41  * @param otbn A OTBN dif handle.
42  * @param skip_otbn_done_check Set to true to skip OTBN done execution check.
43  * The check is blocking.
44  * @returns true on test pass, false otherwise.
45  */
46 bool otbn_randomness_test_end(dif_otbn_t *otbn, bool skip_otbn_done_check);
47 
48 /**
49  * Prints the randomness data generated by the test.
50  *
51  * This function must be called after OTBN is done executing the program loaded
52  * by the `otbn_randomness_test_start()` function.
53  *
54  * @param otbn A OTBN dif handle.
55  */
56 void otbn_randomness_test_log_results(dif_otbn_t *otbn);
57 
58 #endif // OPENTITAN_SW_DEVICE_TESTS_OTBN_RANDOMNESS_IMPL_H_