Software APIs
firmware_fi_otbn.c
1 // Copyright lowRISC contributors (OpenTitan project).
2 // Licensed under the Apache License, Version 2.0, see LICENSE for details.
3 // SPDX-License-Identifier: Apache-2.0
4 #include <stdbool.h>
5 
6 #include "sw/device/lib/base/status.h"
7 #include "sw/device/lib/crypto/drivers/entropy.h"
8 #include "sw/device/lib/testing/test_framework/check.h"
10 #include "sw/device/lib/testing/test_framework/ujson_ottf.h"
11 #include "sw/device/lib/ujson/ujson.h"
12 
13 // Include commands
14 #include "sw/device/tests/penetrationtests/json/commands.h"
15 #include "sw/device/tests/penetrationtests/json/otbn_fi_commands.h"
16 #include "sw/device/tests/penetrationtests/json/pentest_lib_commands.h"
17 
18 // Include handlers
19 #include "fi/otbn_fi.h"
20 #include "lib/pentest_lib.h"
21 
22 OTTF_DEFINE_TEST_CONFIG(.enable_uart_flow_control = true);
23 
24 status_t process_cmd(ujson_t *uj) {
25  while (true) {
26  penetrationtest_cmd_t cmd;
27  TRY(ujson_deserialize_penetrationtest_cmd_t(uj, &cmd));
28  switch (cmd) {
29  case kPenetrationtestCommandOtbnFi:
30  RESP_ERR(uj, handle_otbn_fi(uj));
31  break;
32  case kPenetrationtestCommandAlertInfo:
33  RESP_ERR(uj, pentest_read_rstmgr_alert_info(uj));
34  break;
35  default:
36  LOG_ERROR("Unrecognized command: %d", cmd);
37  RESP_ERR(uj, INVALID_ARGUMENT());
38  }
39  }
40 
41  return OK_STATUS();
42 }
43 
44 bool test_main(void) {
45  CHECK_STATUS_OK(entropy_complex_init());
46  ujson_t uj = ujson_ottf_console();
47  return status_ok(process_cmd(&uj));
48 }