## 3 The Proposed IoMT Model
### Secure Data Transmission and Storage
END FOR
10. encmanipulatedbits = manipbit
11. STOP
```  
**Algorithm 5c** Pseudocode for reshuffling ASCII characters  
During the encryption/decryption process, ASCII characters are reshuffled to form a lookup table for the determination of ciphertext/plaintext in each block. The algorithm to achieve the procedure is given in Algorithm 5c. ```
Module encryptionnewthplement (pblocktext, ckey) Output
0. rearrangedtext [1... C]: array of characters Variables t, col, a, C message[1 C]: arrays of characters
1. START
2. C = COUN T the number of characters in pblocktext
3. msg = ''
4. t = 1
5. FOR col = 1 TO C
6. a = ckey[col]
7. msg[ t] = pblocktext[a]
8. t = t + 1
9. ENDFOR
10. rearrangedtext = message
11. STOP
```  
**Algorithm 6** Pseudocode for reshuffling ASCII characters  
Algorithm 5d generates an array of random number. This array of random numbers, designates the pattern that is used for scrambling ASCII characters or bits. ```
Module Randgen (seed, n) Output: R[1... n]: Array of randomly generated integers
1. START
2. INITIALIZE random number generator with seed
3. GENERATE array R of n random integers from Random number generator
4. STOP
```  
**Algorithm 5d:** Pseudocode for random number generation  
By encrypting the message to be sent, the confidentiality of the message is achieved. However, the integrity of the message is not achieved because a third party can modify the encrypted message without the knowledge of both the client and HC. Therefore, to be convinced of the integrity of the message, the client appends a signature to the encrypted message using its private key \(pr_{NiA}\), which depends on the Elliptic Curve Digital Signature Algorithm (ECDSA). The description of how the sending node A appends its signature to the encrypted message is given in Algorithm 6. ```
INPUT: encrypted points OUTPUT: Signed message
1. START
2. LET \(C_{m}\leftarrow encrypted\) points
3. LET \(M_{sent}=(C_{m},\ t_{o},\ )\) // Append timestamp \(t_{o}\) to the encrypted message
4. COMPUTE e = HASH(M\({}_{sent}\))
5. COMPUTE z = the first p bits of e starting from left
6. GENERATE an integer k randomly
7. COMPUTE (x, y) = k \(\times\) G
8. COMPUTE c = x mod p where c \(\
eq\) 0
9. If c = 0 go to 6
10. COMPUTE d = (z + \(pr_{NiA}*\) c) k \({}^{-1}\)
11. If d = 0 go to 6
12. (c,d) \(\leftarrow\) ciphertext signature
13. STOP
```  
**Algorithm 6** Appending signature of the sending node to the encrypted message  
The receiving HC B does not just start the decryption of any received message. It first verifies the authenticity of the received message to verify that the received message originated from the sending client A. HC B verifies the received message using the public key \(pub_{NiA}\) of node A. Algorithm 7 describes the procedure taken by receiving node B in verifying the received message \(M_{received}\). ```
Input: \(M_{received}\), \(pub_{NiA}\), ciphertextsignature (c,d) Output: Verified ciphertexts
1. START
2. Verify that the integers (c,d) \(\in\) 1, 2, 3,... \(p-1\))
3. COMPUTE e = HASH(\(M_{received}\))
4. COMPUTE z = the first p bits of e starting the left hand side
5. COMPUTE \(u1=e*d^{-1}\ mod\ p\)
6. COMPUTE \(u2=c*d^{-1}\ mod\ p\)
7. COMPUTE (x, y) = u1 * G + u2 * \(pub_{NiA}\)
8. Verified \(\leftarrow\) c \(\equiv\) x mod p
9. STOP. iv. **The decryption of the verified received message \(M_{received}\)**

The same information obtained from the modified Caesar key for generating the seed used in generating the confusion key is also obtained to ensure that the random number generated during the encryption process is also generated during the decryption process. Again, the module Reshuffleforencryption used for scrambling ASCII characters during the encryption process is also used during the decryption process. This is also done to ensure that the same arrangement used for the ASCII characters during the encryption process is used during the decryption process. However, without knowing the key, it is extremely hard to know this arrangement.