SDK for TESAIoT Dev Kit
API reference & tutorials (ModusToolbox)
Loading...
Searching...
No Matches
tesaiot_hsm_api.h
Go to the documentation of this file.
1/*******************************************************************************
2 * File Name: tesaiot_hsm_api.h
3 *
4 * Description: The complete API of libbento_hsm.a — every function the
5 * archive exports, and nothing it does not. OPTIGA chip
6 * ownership, CSR publication and Protected Update entry points.
7 ******************************************************************************/
8/* tesaiot_hsm_api.h — the API libbento_hsm.a exports.
9 *
10 * Written by hand, and checked by the release pipeline against api.txt on
11 * every package run: the archive's exported set and this file must name
12 * exactly the same eighteen symbols or packaging fails.
13 *
14 * It was briefly generated instead, by pruning the internal headers with a
15 * regular expression. That is not a thing regular expressions can do. The
16 * result kept ten `static inline` wrapper BODIES — a definition has a brace,
17 * so the declaration pattern never matched one — which republished nine of the
18 * internal names the archive renames to bx_N, under their real signatures. It
19 * also removed each source header's closing #endif while leaving its #ifndef,
20 * so the file did not compile. Eighteen prototypes are cheap to maintain and
21 * can be read; a parser for C is neither.
22 *
23 * What is NOT here is deliberate. tesaiot_optiga.h and its two siblings
24 * declare ~52 functions between them and this archive exports 18. The rest are
25 * the enrolment and Protected Update machinery, and they are renamed in the
26 * archive precisely so a consumer cannot reach them — shipping their
27 * declarations would undo that.
28 */
29#ifndef TESAIOT_HSM_API_H
30#define TESAIOT_HSM_API_H
31
32#include <stdint.h>
33#include <stdbool.h>
34#include <stddef.h>
35
36/* optiga_util_t, optiga_lib_status_t and callback_handler_t come from the
37 * OPTIGA Trust M library, which is an ordinary ModusToolbox asset and is not
38 * part of this archive. */
39#include "optiga_util.h"
40#include "common/optiga_lib_types.h"
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
46/* ---------------------------------------------------------------------------
47 * Chip manager — ownership of the single OPTIGA instance.
48 *
49 * The chip is one device behind one I2C bus, shared by the MQTT/TLS path, the
50 * HSM provisioning screen and the MicroPython optiga module. Everything that
51 * touches it goes through here.
52 * ------------------------------------------------------------------------- */
53
55bool optiga_manager_init(callback_handler_t callback, void *context);
56
58optiga_util_t *optiga_manager_acquire(void);
59
62
66
70
74void optiga_manager_touch_hold_reason(const char *reason);
76
77/* ---------------------------------------------------------------------------
78 * Enrolment and Protected Update.
79 * ------------------------------------------------------------------------- */
80
99
103int publish_csr(uint8_t *csr, size_t csr_length, uint16_t target_oid,
104 uint16_t trust_anchor_oid, uint32_t payload_version);
105
109int tesaiot_publish_protected_update(const char *target_oid,
110 const char *trust_anchor_oid,
111 uint32_t payload_version,
112 bool with_csr);
113
117
120void trustm_update_state(trustm_state_t new_state, const char *status_code,
121 const char *detail);
123
129
130#ifdef __cplusplus
131}
132#endif
133
134#endif /* TESAIOT_HSM_API_H */
bool optiga_manager_init(callback_handler_t callback, void *context)
Bring up the OPTIGA stack (idempotent); task context only — false if the chip did not answer.
void optiga_chip_exit(void)
One exit per successful enter; never call it after a failed enter.
void optiga_manager_unlock(void)
One unlock per successful lock, every early exit included; release a touch hold first.
optiga_util_t * optiga_manager_acquire(void)
The shared optiga_util instance; NULL until optiga_manager_init() has run.
bool optiga_chip_enter(void)
Open a chip session (re-entrant per task); false is fatal for this call — and NOT an init check.
bool optiga_manager_lock(void)
Take the manager mutex; false when never initialised — the real "is the manager up?...
void optiga_manager_release(void)
Release the acquired instance — exactly one per non-NULL acquire, on every exit.
void tesaiot_run_protected_update_isolated_test(void)
Interactive end-to-end Protected Update against the isolated test slot; blocks on scanf().
int publish_csr(uint8_t *csr, size_t csr_length, uint16_t target_oid, uint16_t trust_anchor_oid, uint32_t payload_version)
Publish an already-built CSR for the platform to sign; weak — NULL-check first. Arms the ingest.
int tesaiot_publish_protected_update(const char *target_oid, const char *trust_anchor_oid, uint32_t payload_version, bool with_csr)
Ask the platform for a Protected Update (OIDs as hex strings); weak — NULL-check first.
void trustm_update_state(trustm_state_t new_state, const char *status_code, const char *detail)
A setter with a timestamp, not a dispatcher; set WAITING_* before the transport starts.
void trustm_reset_state(void)
Back to IDLE, correlation id zeroed — this is what ends a run; call it at every exit.
uint16_t trustm_requested_target_oid(void)
The target OID the last request named; weak — NULL-check and fall back to 0xE0E1.
const char * trustm_current_correlation_id(void)
The in-flight run's id, or NULL; NULL means discard the inbound bundle — the replay defence.
uint16_t trustm_requested_anchor_oid(void)
The trust anchor the last request named; weak — same pattern, default 0xE0E8.
void optiga_manager_touch_release(void)
Decrement the hold counter — strict 1:1 with every hold, on every early return.
void optiga_manager_touch_hold_reason(const char *reason)
The same counted hold, plus the busy-modal string CM55 shows while touch is off.
void optiga_manager_touch_hold(void)
Counted hold for the whole chip conversation; the first hold sleeps 50 ms.
trustm_state_t
Definition tesaiot_hsm_api.h:83
@ TRUSTM_STATE_IDLE
Definition tesaiot_hsm_api.h:84
@ TRUSTM_STATE_COMPLETE
Definition tesaiot_hsm_api.h:89
@ TRUSTM_STATE_APPLYING_UPDATE
Definition tesaiot_hsm_api.h:87
@ TRUSTM_STATE_WAITING_FOR_MANIFEST
Definition tesaiot_hsm_api.h:86
@ TRUSTM_STATE_PUBLISHING_CSR
Definition tesaiot_hsm_api.h:85
@ TRUSTM_STATE_VERIFYING_MANIFEST
Definition tesaiot_hsm_api.h:94
@ TRUSTM_STATE_PROTECTED_UPDATE_SUCCESS
Definition tesaiot_hsm_api.h:96
@ TRUSTM_STATE_WAITING_FOR_CERTIFICATE
Definition tesaiot_hsm_api.h:88
@ TRUSTM_STATE_ERROR
Definition tesaiot_hsm_api.h:90
@ TRUSTM_STATE_WRITING_TRUST_ANCHOR
Definition tesaiot_hsm_api.h:93
@ TRUSTM_STATE_WAITING_FOR_JSON_BUNDLE
Definition tesaiot_hsm_api.h:91
@ TRUSTM_STATE_PROCESSING_JSON_BUNDLE
Definition tesaiot_hsm_api.h:92
@ TRUSTM_STATE_PROTECTED_UPDATE_FAILED
Definition tesaiot_hsm_api.h:97
@ TRUSTM_STATE_APPLYING_FRAGMENTS
Definition tesaiot_hsm_api.h:95