Skip to content

Commit 0f8d137

Browse files
pamauryRazer6
authored andcommitted
[testutils] Make aes compile on englishbreakfast
This testutil can compile without a CSRNG/EDN but the bazel target did not correctly take that into account. This causes a problem when compiling the doxygen target for multitop. This previously went unnoticed because the aes testutils were only compiled on earlgrey. Signed-off-by: Amaury Pouly <[email protected]>
1 parent 7251f5c commit 0f8d137

File tree

4 files changed

+29
-10
lines changed

4 files changed

+29
-10
lines changed

sw/device/lib/testing/BUILD

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,29 @@ cc_library(
2525
name = "aes_testutils",
2626
srcs = ["aes_testutils.c"],
2727
hdrs = ["aes_testutils.h"],
28+
defines = opentitan_if_ip(
29+
"csrng",
30+
# Assume that if csrng is present then so is the edn.
31+
["AES_TESTUTILS_HAS_EDN_AND_CSRNG"],
32+
[],
33+
),
2834
target_compatible_with = [OPENTITAN_CPU],
2935
deps = [
3036
"//hw/ip/aes:model",
3137
"//hw/top:dt",
3238
"//sw/device/lib/dif:aes",
33-
"//sw/device/lib/dif:csrng_shared",
34-
"//sw/device/lib/dif:edn",
3539
"//sw/device/lib/runtime:ibex",
36-
"//sw/device/lib/testing:csrng_testutils",
3740
"//sw/device/lib/testing/test_framework:check",
38-
],
41+
] + opentitan_if_ip(
42+
"csrng",
43+
# Assume that if csrng is present then so is the edn.
44+
[
45+
"//sw/device/lib/dif:csrng_shared",
46+
"//sw/device/lib/dif:edn",
47+
"//sw/device/lib/testing:csrng_testutils",
48+
],
49+
[],
50+
),
3951
)
4052

4153
cc_library(

sw/device/lib/testing/aes_testutils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "sw/device/lib/dif/dif_aes.h"
99
#include "sw/device/lib/testing/test_framework/check.h"
1010

11-
#ifndef OPENTITAN_IS_ENGLISHBREAKFAST
11+
#ifdef AES_TESTUTILS_HAS_EDN_AND_CSRNG
1212
#include "sw/device/lib/dif/dif_csrng_shared.h"
1313
#include "sw/device/lib/testing/csrng_testutils.h"
1414

@@ -35,7 +35,7 @@ enum {
3535
kAesTestutilsTimeout = (10 * 1000 * 1000),
3636
};
3737

38-
#ifndef OPENTITAN_IS_ENGLISHBREAKFAST
38+
#ifdef AES_TESTUTILS_HAS_EDN_AND_CSRNG
3939
/**
4040
* Constants for switching AES masking off.
4141
*/

sw/device/lib/testing/aes_testutils.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@
66
#define OPENTITAN_SW_DEVICE_LIB_TESTING_AES_TESTUTILS_H_
77

88
#include "sw/device/lib/dif/dif_aes.h"
9-
#ifndef OPENTITAN_IS_ENGLISHBREAKFAST
9+
#include "sw/device/lib/runtime/ibex.h"
10+
#include "sw/device/lib/testing/test_framework/check.h"
11+
12+
// The AES_TESTUTILS_HAS_EDN_AND_CSRNG define is created
13+
// by the Bazel rule to indicate the presence of the csrng
14+
// and edn IPs.
15+
#ifdef AES_TESTUTILS_HAS_EDN_AND_CSRNG
1016
#include "sw/device/lib/dif/dif_csrng.h"
1117
#include "sw/device/lib/dif/dif_edn.h"
1218
#endif
13-
#include "sw/device/lib/runtime/ibex.h"
14-
#include "sw/device/lib/testing/test_framework/check.h"
1519

1620
/**
1721
* Returns the value of the AES status flag.
@@ -37,7 +41,7 @@ inline bool aes_testutils_get_status(dif_aes_t *aes, dif_aes_status_t status) {
3741
IBEX_TRY_SPIN_FOR(aes_testutils_get_status((aes_), (status_)) == (flag_), \
3842
(timeout_usec_))
3943

40-
#ifndef OPENTITAN_IS_ENGLISHBREAKFAST
44+
#ifdef AES_TESTUTILS_HAS_EDN_AND_CSRNG
4145
/**
4246
* Initializes the entropy complex for performing AES SCA measurements with
4347
* masking switched off.

sw/device/lib/testing/entropy_testutils.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
#include "sw/device/lib/dif/dif_edn.h"
99
#include "sw/device/lib/testing/test_framework/check.h"
1010

11+
// The HAS_ENTROPY_SRC define is created by the Bazel rule to indicate
12+
// the presence of the entropy_src IP.
13+
1114
#ifdef HAS_ENTROPY_SRC
1215
#include "sw/device/lib/dif/dif_entropy_src.h"
1316
#endif

0 commit comments

Comments
 (0)