7.2 Implementation of Initial Device Registration
On its initial startup, a device creates a 512-bit seed using Java’s function
SecureRandom.getInstanceStrong(). Through
Equation (1) from
Section 5.1.2, i.e.,
\(H(seed\|i)\) where
\(H\) is the hashing function (SHA3) and
\(i\) is the key index, this initial seed is used to spawn new seeds to be used when creating the asymmetric keys. These new seeds are used as input to the pseudo-random number generator that generate the asymmetric keys.
In our implementation, each seed is used to creates two key pairs—one for key encapsulation (Kyber) and the other for signing (Dilithium). The public keys are used as leaves to construct a Merkle tree, as described in
Section 5.2. The root hash of this tree, once base-64 encoded for brevity and readability, is used to represent the device ID. Lastly, the device securely stores the initial seed and the current key index. For more efficient key rotations, our implementation also caches all the leaf hashes of the Merkle tree.
Performance evaluations for the device initialization was performed on a cold Java Virtual Machine (JVM) to reflect the one-time nature of this process at startup. To mitigate variability, the evaluations were repeated 50 times for each tree height, with a new JVM instance for each iteration.
The results are summarized in
Table 2. They include the number of keys generated (
Keys column) and an estimated lifespan for the device ID (
Lifespan column), assuming monthly key rotations. The average time for the initialization process is broken down into the three columns
Create Keys (time to generate keys),
Build Tree (time to construct Merkle tree), and
Other (all remaining tasks). Lastly, the column
Total shows the total time for the process, along with a 95% confidence interval.
These results demonstrate practical feasibility; For example, generating 1,024 keys for a tree of height 10 takes roughly 10 s on a Raspberry Pi 3, and ensures an expected lifespan of 80 years with monthly key rotations.
7.3 Implementation of Secure Connections between Devices
Establishing a secure connection between two entities with mutual authentication is a two-part process. The first part is about device discovery, which is handled by PalCom’s heartbeat functionality. The second part is that of establishing the secure communication itself. Conceptually, this is precisely what a TLS connection provides.
While using a (any) standard implementation of TLS would suffice for a proof of concept, for the purpose of performance evaluation, we provide a simple and lightweight and yet concrete and explicit example of a handshake protocol tailored to integrate with PalCom. An advantage of this approach is that we can make the usage of the techniques we have described explicit for the reader.
Our protocol enables two devices to discover each other and establish a secure connection. Specifically, it serves three primary functions as follows.
(1)
Devices exchange IDs, public keys, and cryptographic proofs linking the keys to their ID.
(2)
Each device demonstrates possession of its corresponding private key.
(3)
Both devices agree on a symmetric session key for efficient bulk encryption.
Our example protocol is detailed below and depicted in the message sequence diagram shown in
Figure 7.
The handshake begins when device \(D_{1}\) receives a heartbeat message from device \(D_{2}\). In response, \(D_{1}\) sends its ID (\(ID_{D_{1}}\)), public keys, proof of inclusion (\(PK_{D_{1}}^{+}\)), and a nonce challenge (\(NONCE_{D_{1}}\))—a unique number used once to prevent replay attacks—to \(D_{2}\). \(D_{1}\) additionally signs the message (\(SIG_{D_{1}}\)) to allow \(D_{2}\) to verify its integrity. Upon receiving this message, \(D_{2}\) verifies the signature and that the public keys are cryptographically linked to \(D_{1}\)’s ID using the provided proof.
Device \(D_{2}\) responds with its ID (\(ID_{D_{2}}\)), public keys, and proof (\(PK_{D_{2}}^{+}\)). It also generate a (symmetric) session key \(k\) and encapsulates this key in a Key Encapsulation Message (KEM) \(KEM_{PK_{D_{2}}}\) using \(D_{1}\)’s public encryption key. This ensures that only \(D_{1}\) can decrypt it to retrieve \(k\). \(D_{1}\)’s challenge (\(NONCE_{D_{1}}\)) is encrypted with \(D_{2}\)’s private key and sent back, allowing \(D_{1}\) to confirm that \(D_{2}\) is in possession of its corresponding private key. Likewise, \(D_{2}\) sends its own nonce challenge (\(NONCE_{D_{2}}\)) to \(D_{1}\), and signs the message (\(SIG_{D_{2}}\)) before sending it.
Next, \(D_{1}\) similarly verifies \(D_{2}\)’s signature and ID, and decrypts the nonce (\(NONCE_{D_{1}}\)) to confirm that \(D_{2}\) has the private key to match its public one. With its own private key, \(D_{1}\) decrypts the KEM to retrieve the session key \(k\). Lastly, \(D_{1}\) encrypts \(D_{2}\)’s challenge (\(NONCE_{D_{2}}\)) with the session key, to demonstrate its possession of it, and thus also its possession of its private key needed to retrieve it.
At the end of the protocol execution, both devices have identified themselves and demonstrated ownership of their ID, and now have a shared session key for further encrypted communication.
Now, let us consider a scenario where an attacker
\(D_{t}\) tries to connect to a Device
\(D_{1}\), pretending to be a legitimate device. To do so,
\(D_{t}\) follows the above handshake protocol and gives its ID to device
\(D_{1}\). As we explained in
Section 5.2, the device IDs are signed by the system administrator in the initial registration phase. Therefore,
only authenticated devices have their IDs signed and stored. Moreover, and still in the initial device registration phase, the system administrator stores its public key in each registered device. Thus, in the above attack scenario, device
\(D_{1}\) can utilize the administrator’s public key and verify that the device
\(D_{t}\) is not a registered device, and safely stop the communication with this malicious device. Moreover, the utilization of the nonce challenges prevent
\(D_{t}\) from performing a replay attack, i.e., to send the same messages it received from
\(D_{1}\) to another benign device in the system and pretend to be
\(D_{1}\). Therefore, the proposed handshake protocol is secure and prevents establishing a connection between an attacker’s device and a registered one.
Considering the handshake procedure is integral to establishing secure connections and may be initiated multiple times throughout a device’s operational period, we evaluate its performance under steady state conditions. We measured four key durations
\(T_{1},T_{2},T_{3}\), and
\(T_{4}\), as illustrated in
Figure 7. Each such duration comprises the time each device takes to process a received a message and send a response within the handshake sequence.
To ensure the accuracy of our results, we repeated the experiment on all 50 devices created during the initialization experiment, organized into 25 pairs. For each device within a pair, we regenerated the signing and encryption keys for a predefined key index and executed the handshake protocol 100 times. To mitigate the JVM warm-up effect, we excluded the first 10 iterations from our analysis. This procedure was repeated with a new JVM instance for each of the 25 device pairs, yielding a total of 2,250 measurements for each tree height.
The results are detailed in
Table 3, with columns 2–5 presenting the average times for the four individual deltas, and the final column showing the total handshake duration alongside a 95% confidence interval.
The analysis reveals that the tree height has negligible impact on the handshake execution time. Despite the confidence interval’s fairly wide range, the overall handshake duration remains reasonably small, with the worst case scenario being approximately 100 ms.
In addition to the time deltas, we evaluated the size of the messages exchanged during the handshake, the result of which is presented in
Table 4. These messages, sent between each time delta, correspond to the transitions indicated by the column headers. Specifically, the column labeled
\((T_{1})\rightarrow(T_{2})\) shows the size (in bytes) of messages sent following
\(T_{1}\), which triggers
\(T_{2}\).
This analysis shows that even though the message sizes for transitions
\((T_{1})\rightarrow(T_{2})\) and
\((T_{2})\rightarrow(T_{3})\) tend to grow with tree size—explainable by the increased proof sizes—the increment is minor relative to the more considerable constant components of the message, comprised by the post-quantum asymmetric keys and the message signature. For detailed sizes of these message components, see
Table 5.
Given the healthcare application scenario, it would be reasonable to require that the total data transfer time for the complete handshake is no more than one second, even if a low power network is used. From
Table 4, we see that the total amount of data for all three messages is less than 20 Kbyte, i.e., 200 Kbit, regardless of tree height. It would then be required that the network has a bandwidth of at least 200 Kbit/s, which is compatible with what low power networks typically give. For example, for Zigbee, the bandwidth is 250 Kbit/s, and for Bluetooth Low Energy, it varies, but is typically 1 Gbit/s.
7.4 Implementation of Device Re-Discovery with Key Rotation
In our implementation, we optimize key rotation performance by storing the hashes of the leaves on disk. To perform a key rotation, we retrieve all of these hashes, and construct a Merkle tree. Then, given the index of the next key to rotate to, we can generate a proof of inclusion by traversing the tree. With the initial seed and the key index we also recreate the set of asymmetric keys.
Our evaluation of key rotation efficiency is split into two parts. First, the focus is on constructing the tree and generating the proof of inclusion. We timed both of these steps, and included the process of reading the leaves from disk. Including this additional load time in the measurements is justified by the infrequent need of having the tree in memory—typically this is only required during key rotations. Second, we timed the recreation of the keys using the seed and the new key index.
As before, we reused the devices from the device initialization evaluation in
Section 7.2, i.e., 50 devices per tree height. For every device, 10 key indices was randomly selected and recreated, resulting in 500 measurements per tree height. Each measurement was performed in a fresh JVM instance, so as to measure startup performance. This is again motivated by the extended time between key rotations, which implies that the JVM may not have fully optimized the key rotation code.
The measurement results are detailed in
Table 6, showing the average time required to read leaves from disk and create a proof (
Tree column), and the average time required to generate the signature and key encapsulation keys from the seed and index (
Key column). The
Total column is the sum of these averages, presenting the mean total alongside a 95% confidence interval.
This analysis indicates that the duration for creating a new proof depend on the size of the tree, while key recreation remains largely constant. Importantly, therefore, proof creation time becomes significantly impactful for large trees. Nonetheless, given the infrequency of such operations, we consider the associated times to be manageable.
7.5 Real-World Deployment Challenges
Our implementation demonstrates the viability of the proposed approach, solving the identified technical challenges. To deploy the solution in a real-world healthcare application, such as the itACiH Hospital-at-Home system, there are several additional technical and non-technical challenges to address. One challenge is to get the system approved by the IT support organizations at hospitals. This is a process that can take quite some time and effort due to the complexity of the area. To use post-quantum cryptographic algorithms is not yet mainstream, yet of importance not only for long-term usage of devices, but also because malicious actors are reported to already now collect traditionally encrypted data in order to be able to break it in the future with quantum computers.
Another challenge is to ensure that patients are able to trust the system with their data. Some data can be very sensitive, such as photographs of a child’s body. Research shows that to accept using an e-health system, it is very important for patients to know what happens to the information entered into it [
19]. One suggestion to support this has been to specifically inform patients about security when introducing them to a new e-health system. For example, they can be informed and reassured that all communication is end-to-end encrypted between the device and the database [
11].
Another security-related challenge is to ensure that the system application code can be updated in an agile way, and that updates can be done securely. This is important both to achieve patient satisfaction by improving the function of the application, but also for security reasons, to be able to patch newly found vulnerabilities in the code. Such update is challenging for IoT systems as it requires automatic remote management of the distributed IoT devices [
10]. For PalCom, we have recently developed such an automatic update method, supporting minimal downtime for end users [
31].
Apart from challenges directly related to security, there are general challenges in developing and introducing new IT systems for healthcare, in particular ensuring that the system does not only help patients but also the medical personnel, saving them time and effort. This can be accomplished by using participatory design [
8,
11] and implies highly iterative development with users in the loop, accentuating the need for simple and secure mechanisms for system update.