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); MUDR-209
if (len > PAYLOAD_MAX) return; // guard assemble_record(payload, len); protect_record(); persist_record(); update_merkle(); crc32 = crc32_compute(record_buf
mudr209_hdr_t *hdr = (mudr209_hdr_t*)record_buf; uint8_t *data = record_buf + sizeof(mudr209_hdr_t); sizeof(mudr209_hdr_t) + len)
build_header(hdr, len); memcpy(data, payload, len);
/* 3. Encrypt & MAC ----------------------------------------------------------*/ static void protect_record(void)