/* 4. Write to flash (append‑only) ------------------------------------------*/ static void persist_record(void)
build_header(hdr, len); memcpy(data, payload, len);
flash_append(record_buf, sizeof(mudr209_hdr_t)+hdr->payload_sz);
/* 1. Prepare header --------------------------------------------------------*/ static void build_header(mudr209_hdr_t *hdr, uint32_t payload_len)
/* AES‑GCM‑256 encryption + authentication tag */ aes_gcm_encrypt(SE_KEY_LOG, record_buf, sizeof(mudr209_hdr_t)+hdr->payload_sz, record_buf); // in‑place encrypt
mudr209_hdr_t *hdr = (mudr209_hdr_t*)record_buf; uint8_t *data = record_buf + sizeof(mudr209_hdr_t);
Mudr-209
/* 4. Write to flash (append‑only) ------------------------------------------*/ static void persist_record(void)
build_header(hdr, len); memcpy(data, payload, len); MUDR-209
flash_append(record_buf, sizeof(mudr209_hdr_t)+hdr->payload_sz); uint8_t *data = record_buf + sizeof(mudr209_hdr_t)
/* 1. Prepare header --------------------------------------------------------*/ static void build_header(mudr209_hdr_t *hdr, uint32_t payload_len) MUDR-209
/* AES‑GCM‑256 encryption + authentication tag */ aes_gcm_encrypt(SE_KEY_LOG, record_buf, sizeof(mudr209_hdr_t)+hdr->payload_sz, record_buf); // in‑place encrypt
mudr209_hdr_t *hdr = (mudr209_hdr_t*)record_buf; uint8_t *data = record_buf + sizeof(mudr209_hdr_t);