Skip to content

Commit a9afc85

Browse files
committed
[pentest] Call otcrypto_security_config_check before entering CL
For security testing, make sure that the device is in a secure configuration before entering the cryptolib. Signed-off-by: Pascal Nasahl <[email protected]>
1 parent 24bc1b2 commit a9afc85

File tree

6 files changed

+20
-0
lines changed

6 files changed

+20
-0
lines changed

sw/device/tests/penetrationtests/firmware/fi/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ cc_library(
3737
"//sw/device/lib/base:abs_mmio",
3838
"//sw/device/lib/base:memory",
3939
"//sw/device/lib/base:status",
40+
"//sw/device/lib/crypto/include:crypto_hdrs",
4041
"//sw/device/lib/dif:rv_core_ibex",
4142
"//sw/device/lib/runtime:log",
4243
"//sw/device/lib/testing/test_framework:ujson_ottf",
@@ -55,6 +56,7 @@ cc_library(
5556
"//sw/device/lib/base:abs_mmio",
5657
"//sw/device/lib/base:memory",
5758
"//sw/device/lib/base:status",
59+
"//sw/device/lib/crypto/include:crypto_hdrs",
5860
"//sw/device/lib/dif:rv_core_ibex",
5961
"//sw/device/lib/runtime:log",
6062
"//sw/device/lib/testing/test_framework:ujson_ottf",

sw/device/tests/penetrationtests/firmware/fi/cryptolib_fi_asym.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "sw/device/lib/base/memory.h"
88
#include "sw/device/lib/base/status.h"
9+
#include "sw/device/lib/crypto/include/security_config.h"
910
#include "sw/device/lib/runtime/log.h"
1011
#include "sw/device/lib/testing/test_framework/ottf_test_config.h"
1112
#include "sw/device/lib/testing/test_framework/ujson_ottf.h"
@@ -512,6 +513,9 @@ status_t handle_cryptolib_fi_asym_init(ujson_t *uj) {
512513

513514
/////////////// STUB START ///////////////
514515
// Add things like versioning.
516+
517+
// Check the security config of the device.
518+
TRY(otcrypto_security_config_check(kOtcryptoKeySecurityLevelHigh));
515519
/////////////// STUB END ///////////////
516520

517521
return OK_STATUS();

sw/device/tests/penetrationtests/firmware/fi/cryptolib_fi_sym.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "sw/device/lib/base/memory.h"
88
#include "sw/device/lib/base/status.h"
9+
#include "sw/device/lib/crypto/include/security_config.h"
910
#include "sw/device/lib/runtime/log.h"
1011
#include "sw/device/lib/testing/test_framework/ottf_test_config.h"
1112
#include "sw/device/lib/testing/test_framework/ujson_ottf.h"
@@ -224,6 +225,9 @@ status_t handle_cryptolib_fi_sym_init(ujson_t *uj) {
224225

225226
/////////////// STUB START ///////////////
226227
// Add things like versioning.
228+
229+
// Check the security config of the device.
230+
TRY(otcrypto_security_config_check(kOtcryptoKeySecurityLevelHigh));
227231
/////////////// STUB END ///////////////
228232

229233
return OK_STATUS();

sw/device/tests/penetrationtests/firmware/sca/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ cc_library(
3232
"//sw/device/lib/base:abs_mmio",
3333
"//sw/device/lib/base:memory",
3434
"//sw/device/lib/base:status",
35+
"//sw/device/lib/crypto/include:crypto_hdrs",
3536
"//sw/device/lib/dif:rv_core_ibex",
3637
"//sw/device/lib/runtime:log",
3738
"//sw/device/lib/testing/test_framework:ujson_ottf",
@@ -51,6 +52,7 @@ cc_library(
5152
"//sw/device/lib/base:abs_mmio",
5253
"//sw/device/lib/base:memory",
5354
"//sw/device/lib/base:status",
55+
"//sw/device/lib/crypto/include:crypto_hdrs",
5456
"//sw/device/lib/dif:rv_core_ibex",
5557
"//sw/device/lib/runtime:log",
5658
"//sw/device/lib/testing/test_framework:ujson_ottf",

sw/device/tests/penetrationtests/firmware/sca/cryptolib_sca_asym.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "sw/device/lib/base/memory.h"
88
#include "sw/device/lib/base/status.h"
9+
#include "sw/device/lib/crypto/include/security_config.h"
910
#include "sw/device/lib/runtime/log.h"
1011
#include "sw/device/lib/testing/test_framework/ottf_test_config.h"
1112
#include "sw/device/lib/testing/test_framework/ujson_ottf.h"
@@ -866,6 +867,9 @@ status_t handle_cryptolib_sca_asym_init(ujson_t *uj) {
866867

867868
/////////////// STUB START ///////////////
868869
// Add things like versioning.
870+
871+
// Check the security config of the device.
872+
TRY(otcrypto_security_config_check(kOtcryptoKeySecurityLevelHigh));
869873
/////////////// STUB END ///////////////
870874

871875
return OK_STATUS();

sw/device/tests/penetrationtests/firmware/sca/cryptolib_sca_sym.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "sw/device/lib/base/memory.h"
88
#include "sw/device/lib/base/status.h"
9+
#include "sw/device/lib/crypto/include/security_config.h"
910
#include "sw/device/lib/runtime/log.h"
1011
#include "sw/device/lib/testing/test_framework/ottf_test_config.h"
1112
#include "sw/device/lib/testing/test_framework/ujson_ottf.h"
@@ -918,6 +919,9 @@ status_t handle_cryptolib_sca_sym_init(ujson_t *uj) {
918919

919920
/////////////// STUB START ///////////////
920921
// Add things like versioning.
922+
923+
// Check the security config of the device.
924+
TRY(otcrypto_security_config_check(kOtcryptoKeySecurityLevelHigh));
921925
/////////////// STUB END ///////////////
922926

923927
return OK_STATUS();

0 commit comments

Comments
 (0)