Mudr-209 🆕 Latest

/* 5. Update Merkle tree ----------------------------------------------------*/ static void update_merkle(void)

/* 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 MUDR-209

uint8_t leaf_hash[SHA384_DIGEST_LEN]; sha384_hash(record_buf, sizeof(mudr209_hdr_t)+hdr->payload_sz, leaf_hash); merkle_tree_append(leaf_hash);

/* Compute CRC over header+payload (excluding CRC field) */ hdr->crc32 = crc32_compute(record_buf, sizeof(mudr209_hdr_t) + len); // in‑place encrypt uint8_t leaf_hash[SHA384_DIGEST_LEN]

flash_append(record_buf, sizeof(mudr209_hdr_t)+hdr->payload_sz);

hdr->magic = MUDR209_MAGIC; // 0x4D554452 (MUDR) hdr->seq = ++record_seq; hdr->ts = hw_get_secure_timestamp(); // signed by TPM hdr->src_id = DEVICE_ID; // 4‑byte unique ID hdr->payload_sz = payload_len; hdr->crc32 = 0; // filled later crc32 = crc32_compute(record_buf

build_header(hdr, len); memcpy(data, payload, len);