SDK สำหรับ TESAIoT Dev Kit
คู่มืออ้างอิง API และ Tutorial (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)
นำ OPTIGA stack ขึ้นทำงาน (idempotent — เรียกซ้ำแล้วได้ผลเดิม) เรียกได้เฉพาะใน task context — คืน fal...
void optiga_chip_exit(void)
exit หนึ่งครั้งต่อ enter ที่สำเร็จหนึ่งครั้ง; ห้ามเรียกหลังจาก enter ที่ล้มเหลว
void optiga_manager_unlock(void)
unlock หนึ่งครั้งต่อ lock ที่สำเร็จหนึ่งครั้ง รวมทุกเส้นทางออกก่อนกำหนด; ให้ปล่อย touch hold ก่อน
optiga_util_t * optiga_manager_acquire(void)
instance ของ optiga_util ที่ใช้ร่วมกัน; เป็น NULL จนกว่า optiga_manager_init() จะทำงานแล้ว
bool optiga_chip_enter(void)
เปิดเซสชันกับชิป (re-entrant ต่อหนึ่ง task); ค่า false เป็นความล้มเหลวเด็ดขาดของการเรียกครั้งนี้ — แล...
bool optiga_manager_lock(void)
จับ mutex ของ manager; คืน false เมื่อไม่เคย initialise — เป็นการทดสอบ "manager ขึ้นแล้วหรือยัง" ที่แ...
void optiga_manager_release(void)
ปล่อย instance ที่ acquire มา — เพียงครั้งเดียวต่อหนึ่งการ acquire ที่ไม่ใช่ NULL ในทุกเส้นทางออก
void tesaiot_run_protected_update_isolated_test(void)
การทดสอบ Protected Update แบบโต้ตอบตั้งแต่ต้นจนจบกับ slot ทดสอบที่แยกไว้; บล็อกอยู่ที่ 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 CSR ที่สร้างไว้เสร็จแล้วเพื่อให้แพลตฟอร์มเซ็นให้; เป็น weak — ให้ตรวจ NULL ก่อน และเป็นตัวตั้...
int tesaiot_publish_protected_update(const char *target_oid, const char *trust_anchor_oid, uint32_t payload_version, bool with_csr)
ขอ Protected Update จากแพลตฟอร์ม (OID เป็น hex string); เป็น weak — ให้ตรวจ NULL ก่อน
void trustm_update_state(trustm_state_t new_state, const char *status_code, const char *detail)
เป็น setter ที่แนบเวลากำกับ ไม่ใช่ dispatcher; ให้ตั้งสถานะ WAITING_* ก่อนที่ transport จะเริ่ม
void trustm_reset_state(void)
กลับสู่ IDLE และล้าง correlation id เป็นศูนย์ — นี่คือสิ่งที่จบรอบการทำงาน; ให้เรียกที่ทุกเส้นทางออก
uint16_t trustm_requested_target_oid(void)
OID เป้าหมายที่คำขอครั้งล่าสุดระบุไว้; เป็น weak — ให้ตรวจ NULL และถอยไปใช้ 0xE0E1.
const char * trustm_current_correlation_id(void)
id ของรอบที่กำลังทำงานอยู่ หรือ NULL; NULL หมายถึงให้ทิ้ง bundle ที่เข้ามา — นี่คือการป้องกันการเล่นซ...
uint16_t trustm_requested_anchor_oid(void)
trust anchor ที่คำขอครั้งล่าสุดระบุไว้; เป็น weak — รูปแบบเดียวกัน ค่าเริ่มต้น 0xE0E8
void optiga_manager_touch_release(void)
ลดค่าตัวนับการจับไว้ — จับคู่ 1:1 อย่างเคร่งครัดกับการจับไว้ทุกครั้ง ในทุกการคืนค่าก่อนกำหนด
void optiga_manager_touch_hold_reason(const char *reason)
การจับไว้แบบนับจำนวนแบบเดียวกัน พร้อมข้อความ busy modal ที่ CM55 แสดงระหว่างที่การสัมผัสถูกปิด
void optiga_manager_touch_hold(void)
การจับไว้ (hold) แบบนับจำนวน ครอบการติดต่อกับชิปทั้งชุด; การจับไว้ครั้งแรกจะหลับ 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