Skip to content

Commit

Permalink
[cryptolib] csrng driver
Browse files Browse the repository at this point in the history
This commit introduces the a driver for the software instance of the
csrng. The driver interface supports regular DRBG functions, i.e.
instantiate, reseed, update and generate functions.

The focus of this commit is functionality, so there are a few things
that will be addressed in future commits:

- Handling of blocking operations. This is currently an area where we
  need to come up with a strategy for the crypto library as indefinite
  blocking operations may need an unconditional timeout when called in
  higher application layers.
- alert and state checks.

Signed-off-by: Miguel Osorio <[email protected]>
  • Loading branch information
moidx committed Aug 30, 2022
1 parent e0468a5 commit 6be5b88
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
30 changes: 15 additions & 15 deletions sw/device/lib/crypto/drivers/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ cc_library(
],
)

opentitan_functest(
name = "aes_test",
srcs = ["aes_test.c"],
verilator = verilator_params(
timeout = "long",
),
deps = [
":aes",
"//sw/device/lib/base:macros",
"//sw/device/lib/base:memory",
"//sw/device/lib/testing/test_framework:check",
"//sw/device/lib/testing/test_framework:ottf_main",
],
)

cc_library(
name = "kmac",
srcs = ["kmac.c"],
Expand Down Expand Up @@ -58,21 +73,6 @@ opentitan_functest(
],
)

opentitan_functest(
name = "aes_test",
srcs = ["aes_test.c"],
verilator = verilator_params(
timeout = "long",
),
deps = [
":aes",
"//sw/device/lib/base:macros",
"//sw/device/lib/base:memory",
"//sw/device/lib/testing/test_framework:check",
"//sw/device/lib/testing/test_framework:ottf_main",
],
)

cc_library(
name = "entropy",
srcs = ["entropy.c"],
Expand Down
2 changes: 1 addition & 1 deletion sw/device/lib/crypto/drivers/entropy.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ status_t entropy_csrng_generate_data_get(uint32_t *buf, size_t len) {
// Block until there is more data available in the genbits buffer. CSRNG
// generates data in 128bit chunks (i.e. 4 words).
static_assert(kEntropyCsrngBitsBufferNumWords == 4,
"kEntropyCsrngBitsBufferNumWords must be a power of 2.");
"kEntropyCsrngBitsBufferNumWords must be a power of 2.");
if (i & (kEntropyCsrngBitsBufferNumWords - 1)) {
uint32_t reg;
do {
Expand Down

0 comments on commit 6be5b88

Please sign in to comment.