Skip to content

Commit cbc9a58

Browse files
committed
[pentest] Add crypto version
Add the version of the crypto library to the pentest framework's readout for the crypto related init functions. Signed-off-by: Siemen Dhooghe <[email protected]>
1 parent 215f602 commit cbc9a58

22 files changed

+514
-100
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ cc_library(
7676
"//sw/device/lib/base:math",
7777
"//sw/device/lib/base:memory",
7878
"//sw/device/lib/base:status",
79+
"//sw/device/lib/crypto/impl:cryptolib_build_info",
7980
"//sw/device/lib/crypto/impl:ecc_p256",
8081
"//sw/device/lib/crypto/impl:ecc_p384",
8182
"//sw/device/lib/crypto/impl:integrity",
@@ -105,6 +106,7 @@ cc_library(
105106
"//sw/device/lib/base:status",
106107
"//sw/device/lib/crypto/impl:aes",
107108
"//sw/device/lib/crypto/impl:aes_gcm",
109+
"//sw/device/lib/crypto/impl:cryptolib_build_info",
108110
"//sw/device/lib/crypto/impl:drbg",
109111
"//sw/device/lib/crypto/impl:hmac",
110112
"//sw/device/lib/crypto/impl:integrity",

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
#include "sw/device/lib/base/memory.h"
88
#include "sw/device/lib/base/status.h"
9+
#include "sw/device/lib/crypto/drivers/cryptolib_build_info.h"
10+
#include "sw/device/lib/crypto/include/cryptolib_build_info.h"
911
#include "sw/device/lib/runtime/log.h"
1012
#include "sw/device/lib/testing/test_framework/ottf_test_config.h"
1113
#include "sw/device/lib/testing/test_framework/ujson_ottf.h"
@@ -509,7 +511,17 @@ status_t handle_cryptolib_fi_asym_init(ujson_t *uj) {
509511
TRY(pentest_send_sku_config(uj));
510512

511513
/////////////// STUB START ///////////////
512-
// Add things like versioning.
514+
uint32_t version;
515+
bool released;
516+
uint32_t build_hash_low;
517+
uint32_t build_hash_high;
518+
TRY(otcrypto_build_info(&version, &released, &build_hash_low,
519+
&build_hash_high));
520+
char cryptolib_version[150];
521+
base_snprintf(cryptolib_version, sizeof(cryptolib_version),
522+
"CRYPTO version %d, released %s, hash %08x%08x", version,
523+
released ? "true" : "false", build_hash_high, build_hash_low);
524+
RESP_OK(ujson_serialize_string, uj, cryptolib_version);
513525
/////////////// STUB END ///////////////
514526

515527
return OK_STATUS();

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
#include "sw/device/lib/base/memory.h"
88
#include "sw/device/lib/base/status.h"
9+
#include "sw/device/lib/crypto/drivers/cryptolib_build_info.h"
10+
#include "sw/device/lib/crypto/include/cryptolib_build_info.h"
911
#include "sw/device/lib/runtime/log.h"
1012
#include "sw/device/lib/testing/test_framework/ottf_test_config.h"
1113
#include "sw/device/lib/testing/test_framework/ujson_ottf.h"
@@ -223,7 +225,16 @@ status_t handle_cryptolib_fi_sym_init(ujson_t *uj) {
223225
TRY(pentest_send_sku_config(uj));
224226

225227
/////////////// STUB START ///////////////
226-
// Add things like versioning.
228+
uint32_t version;
229+
bool released;
230+
uint32_t build_hash_low;
231+
uint32_t build_hash_high;
232+
TRY(otcrypto_build_info(&version, &released, &build_hash_low,
233+
&build_hash_high));
234+
char cryptolib_version[150];
235+
base_snprintf(cryptolib_version, sizeof(cryptolib_version),
236+
"CRYPTO version %d, released %s, hash %08x%08x", version,
237+
released ? "true" : "false", build_hash_high, build_hash_low);
227238
/////////////// STUB END ///////////////
228239

229240
return OK_STATUS();

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ cc_library(
7373
"//sw/device/lib/base:math",
7474
"//sw/device/lib/base:memory",
7575
"//sw/device/lib/base:status",
76+
"//sw/device/lib/crypto/impl:cryptolib_build_info",
7677
"//sw/device/lib/crypto/impl:ecc_p256",
7778
"//sw/device/lib/crypto/impl:ecc_p384",
7879
"//sw/device/lib/crypto/impl:integrity",
@@ -102,6 +103,7 @@ cc_library(
102103
"//sw/device/lib/base:status",
103104
"//sw/device/lib/crypto/impl:aes",
104105
"//sw/device/lib/crypto/impl:aes_gcm",
106+
"//sw/device/lib/crypto/impl:cryptolib_build_info",
105107
"//sw/device/lib/crypto/impl:drbg",
106108
"//sw/device/lib/crypto/impl:hmac",
107109
"//sw/device/lib/crypto/impl:integrity",

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
#include "sw/device/lib/base/memory.h"
88
#include "sw/device/lib/base/status.h"
9+
#include "sw/device/lib/crypto/drivers/cryptolib_build_info.h"
10+
#include "sw/device/lib/crypto/include/cryptolib_build_info.h"
911
#include "sw/device/lib/runtime/log.h"
1012
#include "sw/device/lib/testing/test_framework/ottf_test_config.h"
1113
#include "sw/device/lib/testing/test_framework/ujson_ottf.h"
@@ -865,7 +867,17 @@ status_t handle_cryptolib_sca_asym_init(ujson_t *uj) {
865867
TRY(pentest_send_sku_config(uj));
866868

867869
/////////////// STUB START ///////////////
868-
// Add things like versioning.
870+
uint32_t version;
871+
bool released;
872+
uint32_t build_hash_low;
873+
uint32_t build_hash_high;
874+
TRY(otcrypto_build_info(&version, &released, &build_hash_low,
875+
&build_hash_high));
876+
char cryptolib_version[150];
877+
base_snprintf(cryptolib_version, sizeof(cryptolib_version),
878+
"CRYPTO version %d, released %s, hash %08x%08x", version,
879+
released ? "true" : "false", build_hash_high, build_hash_low);
880+
RESP_OK(ujson_serialize_string, uj, cryptolib_version);
869881
/////////////// STUB END ///////////////
870882

871883
return OK_STATUS();

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
#include "sw/device/lib/base/memory.h"
88
#include "sw/device/lib/base/status.h"
9+
#include "sw/device/lib/crypto/drivers/cryptolib_build_info.h"
10+
#include "sw/device/lib/crypto/include/cryptolib_build_info.h"
911
#include "sw/device/lib/runtime/log.h"
1012
#include "sw/device/lib/testing/test_framework/ottf_test_config.h"
1113
#include "sw/device/lib/testing/test_framework/ujson_ottf.h"
@@ -917,7 +919,17 @@ status_t handle_cryptolib_sca_sym_init(ujson_t *uj) {
917919
TRY(pentest_send_sku_config(uj));
918920

919921
/////////////// STUB START ///////////////
920-
// Add things like versioning.
922+
uint32_t version;
923+
bool released;
924+
uint32_t build_hash_low;
925+
uint32_t build_hash_high;
926+
TRY(otcrypto_build_info(&version, &released, &build_hash_low,
927+
&build_hash_high));
928+
char cryptolib_version[150];
929+
base_snprintf(cryptolib_version, sizeof(cryptolib_version),
930+
"CRYPTO version %d, released %s, hash %08x%08x", version,
931+
released ? "true" : "false", build_hash_high, build_hash_low);
932+
RESP_OK(ujson_serialize_string, uj, cryptolib_version);
921933
/////////////// STUB END ///////////////
922934

923935
return OK_STATUS();

sw/host/penetrationtests/python/fi/communication/fi_asym_cryptolib_commands.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def init(
5252
boot_log = self.target.read_response()
5353
boot_measurements = self.target.read_response()
5454
version = self.target.read_response()
55+
cryptolib_version = self.target.read_response()
5556
return (
5657
device_id,
5758
sensors,
@@ -60,6 +61,7 @@ def init(
6061
boot_log,
6162
boot_measurements,
6263
version,
64+
cryptolib_version,
6365
)
6466

6567
def handle_rsa_enc(

sw/host/penetrationtests/python/fi/communication/fi_sym_cryptolib_commands.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def init(
5252
boot_log = self.target.read_response()
5353
boot_measurements = self.target.read_response()
5454
version = self.target.read_response()
55+
cryptolib_version = self.target.read_response()
5556
return (
5657
device_id,
5758
sensors,
@@ -60,6 +61,7 @@ def init(
6061
boot_log,
6162
boot_measurements,
6263
version,
64+
cryptolib_version,
6365
)
6466

6567
def handle_aes(

0 commit comments

Comments
 (0)