## 3 The Proposed IoMT Model
### Secure Data Transmission and Storage
The description of how ciphertext is converted back to plaintext in modified Caesar is represented by Algorithm 8a, while Algorithm 8b describes the process of reversing the bit modification performed during the encryption process. ```
Module DMCaesar (Blocktext, Binkey) Output: decryptedblocktext: string of characters Variables: caesarchar: 1D array of ASCII characters as reshuffled
1. START
2. LET alphabet = 0:255
3. X = COUNT the number of o in binkey
4. x1 = COUNT the number of zeros in binkey
5. confusionkey = CALL Randgen(X,256)// Algorithm 5d
6. caesarchar = CALL Reshuffleforencryption(confusionkey, alphabet) 5c
7. ptext = \"
8. length = COUNT the number of characters in Blocktext
9. FOR i = 1 TO length
10. ch = Charcaesaror (i)
11. FOR j = 1 TO LENGTH(caesarchar)
12. IF ch = caesarchar(j)
13. t = {j - i} MOD (LENGTH(alphabet))
14. BREAK
15. ENDIF
16. END FOR
17. pcharl = caesarchar(t)
18. p = CONCATENATE (p, pchar)
19. END FOR
20. p = CALL Reversebitmodification(p, \(\times\)1) // Algorithm 9
21. p = P XOR binkey
22. LET decryptedblocktext = P
23. STOP
```
**Algorithm 8a** Modified Caesar Decryption Module

### Privacy Preservation in the proposed IoMT Model

The identity of the patient is not shared by the cloud. In addition, the health records of the patients are stored in encrypted form on the cloud so as to avoid unauthorized access. In order to make it easy to search through the encrypted data, the encrypted data are stored on the cloud using B+ tree file organization, in which the information is stored using (key, value) pair form. Algorithm 9 gives the description of how the key is generated. ```
Module blockbits=DecReversebitmodification(binarystr, radseed) Input: binarystr,randomseedOutput: reversebinarystr
1. START
2. randb=binary value of randomseed
3. reseds=number of bitsin randb
4. Randkeys=array of generated random seeds from radseed
5. bsize=number of bits in binarystr
6. Rbinrystr=binarystr
7. FORi=reseds to 1
1. s1=Randkeys[i]
2. confusionkey=GENERATE bsize random integers from s1
3. Rmanipbit=CALL Reshuffleforencryption(Rbinarystr, confusionkey)//
4. algorithm5
5. nibbleleft=Rmanipbit(1:bsize/2)
6. nibbleleft=Rmanipbit(bssize/2 +1:bssize)
7. nibbleleft=nibbleleft XOR nibbleright
8. Rmanipbit=CONCATENATE(nibblexor, nibbleright)
9. ENDFOR
10. hx=bssize/2
11. Rm1=Rmanipbit(1:hx)
12. Rm2=Rmanipbit(hx+1:bssize)
13. pmsg=\"
14. FORs=1 tohx
1. Lm=Rm1(ss+3)
15. Rm=Rm2(ss+3)
16. pmsg=CONCATENATE(pmsg, Lm, Rm)
17. ENDFOR
18. reversebinarystr=pmsg
19. STOP
```
**Algorithm 8b:** Decryption Reverse Bit Modification Process
```
Input: HC private key (ssk, Cm)
1. START
2. COMPUTE p=number of bits in ssk
3. COMPUTE e=HASH(Cm)
4. ENCRYPT enc=HMCC(e)//encrypt using algorithm5a
5. COMPUTE z=the first p bits of enc starting from the left hand side
6. CONVERT z to an integer
7. COMPUTE z=z+sid+vid//append te sensor id and value that represent the interpretation of the measured value from te sensor
8. UPDATE patient record by adding z
9. STORE value on cloud using z as the key of B+ file organization
10. STOP. ```
**Algorithm 9** Storing encrypted file on cloud storage using B+ file organisation

Cm in Algorithm 9 represents the encrypted data. ssk is the shared secret key between the HC and patient. Integer z is obtained by appending sensor identification number sid and the value measured by the sensor represented by vid to the integer obtained from the hash value of encrypted data from a particular sensor. The data can be decrypted only by the authorized user using a private key provided by the HC. If the patient visits another healthcare centre GHC and there is the need to access the patient's health record from the cloud, the patient will be asked to supply the ssk so as to be able to decrypt the content of the health record. Knowing the hash value of the file location of the encrypted data cannot help an intruder in obtaining the content of the file. Hence, the HC and patient are in full control of determining which information is to be shared and which is not.