# A Novel Software Architecture Solution with a Focus on Long-Term IoT Device Security Support
## 4 Device Architecture
### Security Protocol  
The security concept is presented in Figure 11. The smart beverage cooling device uses a public and secret key for communication. Both keys are generated separately for each device during manufacturing and inserted into the device EEPROM on the production line. On the last step of the production line, the device was registered with the cloud. During that process, a serial number is generated and placed together with both keys in the cloud database.  
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Calibrated Flow Meter** & \multicolumn{2}{c}{**Telemetry Results**} & \multicolumn{2}{c}{**Deviation**} \\ \hline
**Python \#1** & **Python \#2** & **Python \#1** & **Python \#2** & **Python \#1** & **Python \#2** \\ \hline
379 & 382 & 396 & 409 & 17 & 27 \\
380 & 375 & 396 & 399 & 16 & 24 \\
383 & 383 & 399 & 407 & 16 & 24 \\
382 & 380 & 398 & 402 & 16 & 22 \\
384 & 383 & 401 & 406 & 17 & 23 \\ \hline \hline \end{tabular}
\end{table}
Table 2: Number of impulses in fast tapping during 10 s period for 1 L.  
The public key can be easily retrieved as it is printed on each device (QR code), while the secret key is only stored in the cloud and on the erasable programmable read-only memory (EPROM) of the device itself. The mobile application connects to the smart beverage cooling device using wireless technology, with the smart beverage cooling device acting as the access point. The access point is protected by the Wireless Fidelity Protected Access II (WPA2) encryption standard. Before connecting the mobile application to the device, it is necessary to read the public key of the device in the form of Quick Response (QR) code printed on the smart beverage cooling device through the mobile device application to retrieve the wireless password and secret key of the smart beverage cooling device from the cloud. Once connected, the smart beverage cooling device communicates with the mobile application through the Representational State Transfer (RESTful) service. All the communication takes place over a JavaScript Object Notation (JSON) data structure. The communication protocol used is Hypertext Transfer Protocol Secure (HTTPS). To gain further security, each JSON message that is sent to the device must be signed with a secret key that is not permanently stored anywhere on the mobile device for security reasons.  
For a mobile application to access RESTful cloud services, a service technician must have created a cloud account. This account can only be assigned by a person with elevated cloud privileges (e.g., cloud administrator). This eliminates the problem of unauthorised login of service technicians to the cloud. All communication between the cloud and the mobile application is encrypted using the HTTPS protocol. After the person logs in to the application with a username and password, all further communication is signed with  
Figure 11: The security concept of the device.  
a token that is issued by the cloud after each login. This token expires after predefined period of time and the service technician must log in to the application again to confirm their identity.  
When the smart beverage cooling device communicates with the cloud, the public and private keys are used again. Each message must contain the device identifier which identifies the device on the cloud, and the message is signed with a private key to ensure authenticity. Since only the smart beverage cooling device and the cloud possess the private key, it is simply validated on the cloud. All data are sent to the RESTful service encrypted using the HTTPS protocol, which provides additional data protection. The communication between the cloud and the smart beverage cooling device is always one-way, in a sense that the smart beverage cooling device only sends data to the cloud. This behaviour avoids the possibility of unauthorised device adjustment over the Internet.