|
SDK for TESAIoT Dev Kit
API reference & tutorials (ModusToolbox)
|
Functions | |
| void | bento_devmode_init (void) |
| Idempotent; seeds the 32-byte RAM secret. Every public devmode entry self-calls it. | |
| void | bento_devmode_nonce_issue (uint8_t nonce_out[BENTO_DEVMODE_NONCE_LEN]) |
| Fill a fresh 16-byte nonce, overwriting any pending one; starts the TTL clock. | |
| bool | bento_devmode_unlock (const char *hmac_hex, size_t hmac_hex_len) |
| Verify the HMAC against the pending nonce; consumes the nonce on any call (one-shot). | |
| void | bento_devmode_lock (void) |
| Clear the unlocked flag. | |
| bool | bento_devmode_is_unlocked (void) |
| Whether privileged verbs (bento.exec) are permitted right now. | |
| size_t | bento_devmode_secret_hex (char *out, size_t out_sz) |
| The secret as 64 hex chars + NUL, or 0 if the buffer is too small; never log it to UART. | |
| void | bento_devmode_emit_provision (void) |
| Emit the provision event once per boot on the CONNECTED transition; a failed send retries. | |
| size_t | bento_devmode_secret_fp_hex (char *out, size_t out_sz) |
| First 4 bytes of SHA-256(secret) as 8 hex chars + NUL — safe to log. | |
Eight functions: the developer-mode unlock, bento_devmode_*. Compiled only with ENABLE_PAGE_BENTO_BUDDY=1 (default 0, proj_cm33_ns/Makefile:64, :305); rebuild after make getlibs — Flag gate (read first).
Declarations: bento_devmode.h. Implementation bento_devmode.c is archived in libbento_secure.a. The shared secret is RAM-only and regenerated every boot (OPTIGA slot 0xE120 persistence is deferred, bento_devmode.c:96-97) — the desktop must re-provision after every reboot. Nonce TTL is BENTO_DEVMODE_NONCE_TTL_MS (60000); there is one in-flight challenge.
What this challenge/response does and does not protect.** Provisioning works by sending the secret in plaintext to the first peer that connects (Devmode, bento_devmode_emit_provision) over a TX characteristic that carries no GATTDB_PERM_AUTH_* bit, and the secret comes from an xorshift32 with under 32 bits of entropy. The HMAC step itself is sound; the net effect is a gate that keeps out a peer connecting second and no one else — a deterrent, not an enforcement boundary.
| void bento_devmode_init | ( | void | ) |
Idempotent; seeds the 32-byte RAM secret. Every public devmode entry self-calls it.
Quality of the secret.** The PRNG is xorshift32, seeded from the FreeRTOS tick, a stack address and one constant (bento_devmode.c:54-66) — under 32 bits of entropy, and the source comment says so itself: "not cryptographically strong". The OPTIGA RNG is not used. Moving to a chip-supplied seed is open work.
| void bento_devmode_nonce_issue | ( | uint8_t | nonce_out[BENTO_DEVMODE_NONCE_LEN] | ) |
Fill a fresh 16-byte nonce, overwriting any pending one; starts the TTL clock.
| bool bento_devmode_unlock | ( | const char * | hmac_hex, |
| size_t | hmac_hex_len ) |
Verify the HMAC against the pending nonce; consumes the nonce on any call (one-shot).
| void bento_devmode_lock | ( | void | ) |
Clear the unlocked flag.
| bool bento_devmode_is_unlocked | ( | void | ) |
Whether privileged verbs (bento.exec) are permitted right now.
| size_t bento_devmode_secret_hex | ( | char * | out, |
| size_t | out_sz ) |
The secret as 64 hex chars + NUL, or 0 if the buffer is too small; never log it to UART.
| void bento_devmode_emit_provision | ( | void | ) |
Emit the provision event once per boot on the CONNECTED transition; a failed send retries.
State the security consequence exactly.** This function sends the secret in plaintext to the first peer that connects after boot, and the TX characteristic carries no GATTDB_PERM_AUTH_* bit (see GATT data), so an unpaired peer receives it. The HMAC-SHA256 step itself is sound, but possession of the key is not restricted to an authorised desktop. The gate keeps out a peer that connects second and no one else — a deterrent, not an enforcement boundary.
| size_t bento_devmode_secret_fp_hex | ( | char * | out, |
| size_t | out_sz ) |
First 4 bytes of SHA-256(secret) as 8 hex chars + NUL — safe to log.