## 5 Implementation of Secure IoT-Based Communication System
### Publisher Implementation at the IoT Node
Each tested protocol (e.g., CCM8, EAX, GCM, Salsa20, Tiny AES) was used to encrypt identical payloads, representing typical IoT data (e.g., JPEG images from medical sensors). The resulting ciphertexts were subjected to the ApEn test across multiple iterations. The \(p\)-values generated by the test were analyzed to determine whether the output se

Figure 4: Testbed hardware and software components. quences exhibit sufficient randomness. A \(p\)-value greater than 0.01, as per NIST criteria [26], suggests that the ciphertext passes the test and is statistically indistinguishable from a random sequence. The proposed framework uses Salsa20-Blake2b at the edge layer for its efficiency and cryptographic robustness. NIST test results show that Salsa20 achieves high \(p\)-values in Approximate Entropy, typically above 0.40, and in some cases exceeding 0.90, confirming that it produces statistically unpredictable ciphertext. Table 2 presents the Approximate Entropy \(p\)-values obtained for the Salsa20-Blake2b encryption scheme over eight test rounds. For each round, the ciphertext was captured and analyzed using the NIST Statistical Test Suite to evaluate its randomness properties. The average \(p\)-values observed across other protocols were as follows: AES-CCM8--0.457, AES-EAX--0.403, AES-GCM--0.846, TinyAES--0.296 and Salsa20-Blake2b--0.607. These results highlight the suitability of Salsa20-Blake2b for resource-constrained edge devices, offering high entropy with low computational cost, while also affirming the robust randomness characteristics of AES-GCM, making it an effective choice for cloud-layer encryption within the proposed multi-broker architecture. To ensure message integrity and authentication at the edge, the proposed framework utilizes the Blake2b hash function in conjunction with the Salsa20 encryption scheme. Blake2b is a cryptographically secure and efficient hash function, well-suited for constrained devices due to its speed and simplicity. At the publishing node, each outgoing message is encrypted using Salsa20 and appended with a keyed HMAC generated using Blake2b. As shown in Figure 5, when the ciphertext was altered or transmitted with an invalid or mismatched HMAC, the bridge failed to authenticate the message, generating repeated errors: \"HMAC verification failed at local broker.\" Similarly, AES-GCM authentication tag and TLS1.3 MAC are utilized to ensure data integrity when the data leave the local broker. To assess the resilience of the proposed HECS4 MQTT multi-layer encryption framework, we conduct a structured security analysis based on the MITRE ATT&CK framework [27]. This methodology allows us to map real-world adversarial tactics and techniques to potential vulnerabilities in the system and to evaluate the effectiveness of our mitigation strategies. HECS4 MQTT demonstrates robust protection against several prevalent attack vectors, particularly in the domains of network interception, credential compromise, and payload tampering. One of the most significant strengths of the framework lies in its defense against network-based attacks, including traffic interception and man-in-the-middle (MitM) attacks. \begin{table}
\begin{tabular}{c c c c c c c c c} \hline
**Protocol** & **Round 1** & **Round 2** & **Round 3** & **Round 4** & **Round 5** & **Round 6** & **Round 7** & **Round 8** \\ \hline Salsa20-Blake2b & 0.88381 & 0.283651 & 0.987717 & 0.411331 & 0.928822 & 0.696591 & 0.213525 & 0.452711 \\ \hline \end{tabular}
\end{table} 
Table 2: \(p\)-values in approximate entropy for Salsa20-Blake2b. Figure 5: Detecting tampering at local broker. By employing Salsa20-Blake2b encryption at the edge layer and AES-256 encryption with TLS 1.3 at the cloud layer, HECS4 MQTT ensures that sensitive healthcare data is encrypted during the entire transmission path. The use of authenticated encryption further protects against data manipulation and unauthorized modifications (aligned with MITRE technique T1565--Data Manipulation).