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 
17 // Include handlers
18 #include "fi/otbn_fi.h"
19 
20 OTTF_DEFINE_TEST_CONFIG(.enable_uart_flow_control = true);
21 
22 status_t process_cmd(ujson_t *uj) {
23  while (true) {
24  penetrationtest_cmd_t cmd;
25  TRY(ujson_deserialize_penetrationtest_cmd_t(uj, &cmd));
26  switch (cmd) {
27  case kPenetrationtestCommandOtbnFi:
28  RESP_ERR(uj, handle_otbn_fi(uj));
29  break;
30  default:
31  LOG_ERROR("Unrecognized command: %d", cmd);
32  RESP_ERR(uj, INVALID_ARGUMENT());
33  }
34  }
35 
36  return OK_STATUS();
37 }
38 
39 bool test_main(void) {
40  CHECK_STATUS_OK(entropy_complex_init());
41  ujson_t uj = ujson_ottf_console();
42  return status_ok(process_cmd(&uj));
43 }