-
Notifications
You must be signed in to change notification settings - Fork 977
[crypto/entropy] Make the entropy source ready for use #29615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: earlgrey_1.0.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| // Copyright lowRISC contributors (OpenTitan project). | ||
| // Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #include "sw/device/lib/crypto/include/entropy_src.h" | ||
|
|
||
| #include <stdbool.h> | ||
|
|
||
| #include "sw/device/lib/crypto/drivers/entropy.h" | ||
| #include "sw/device/lib/crypto/impl/status.h" | ||
|
|
||
| // Module ID for status codes. | ||
| #define MODULE_ID MAKE_MODULE_ID('e', 't', 's') | ||
|
|
||
| otcrypto_status_t otcrypto_entropy_init(void) { | ||
| HARDENED_TRY(entropy_complex_init()); | ||
| return OTCRYPTO_OK; | ||
| } | ||
|
|
||
| otcrypto_status_t otcrypto_entropy_check(void) { | ||
| HARDENED_TRY(entropy_complex_check()); | ||
| return OTCRYPTO_OK; | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,50 @@ | ||||||
| // Copyright lowRISC contributors (OpenTitan project). | ||||||
| // Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||||||
| // SPDX-License-Identifier: Apache-2.0 | ||||||
|
|
||||||
| #ifndef OPENTITAN_SW_DEVICE_LIB_CRYPTO_INCLUDE_ENTROPY_SRC_H_ | ||||||
| #define OPENTITAN_SW_DEVICE_LIB_CRYPTO_INCLUDE_ENTROPY_SRC_H_ | ||||||
|
|
||||||
| #include "datatypes.h" | ||||||
|
|
||||||
| /** | ||||||
| * @file | ||||||
| * @brief Entropy source functions for the OpenTitan cryptography library. | ||||||
| * | ||||||
| * Instantiate and use the TRNG. Acts as a wrapper to the entropy driver. | ||||||
| */ | ||||||
|
|
||||||
| #ifdef __cplusplus | ||||||
| extern "C" { | ||||||
| #endif // __cplusplus | ||||||
|
|
||||||
| /** | ||||||
| * Configures the entropy source in continuous mode with FIPS thresholds. | ||||||
| * | ||||||
| * @return Operation status in `otcrypto_status_t` format. | ||||||
| */ | ||||||
| OT_WARN_UNUSED_RESULT | ||||||
| otcrypto_status_t otcrypto_entropy_init(void); | ||||||
|
|
||||||
| /** | ||||||
| * Ensures that the entropy complex is ready for use and verify the health | ||||||
| * checks of the generated randomness. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| * | ||||||
| * Ensures that the entropy complex is running and that `entropy_src` is in | ||||||
| * FIPS mode, and verifies the thresholds for health tests in `entropy_src`. | ||||||
| * This function should be called periodically while the entropy complex is in | ||||||
| * use, because the threshold registers are not shadowed. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| * | ||||||
| * The test also verifies the health checks of the generated randomness | ||||||
| * providing a status error if a health test jumped. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| * | ||||||
| * @return Operation status in `otcrypto_status_t` format. | ||||||
| */ | ||||||
| OT_WARN_UNUSED_RESULT | ||||||
| otcrypto_status_t otcrypto_entropy_check(void); | ||||||
|
|
||||||
| #ifdef __cplusplus | ||||||
| } // extern "C" | ||||||
| #endif // __cplusplus | ||||||
|
|
||||||
| #endif // OPENTITAN_SW_DEVICE_LIB_CRYPTO_INCLUDE_ENTROPY_SRC_H_ | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.