# Automatic Selective Encryption of DICOM Images
## Appendix A  
The multi-region approach depends on the calculation of regions' sizes to minimize the required encryption time. In this research, an approach that exploits a straightforward linear system was developed to estimate regions' sizes that guarantee optimal performance. Under the assumption that encryption cost is linear with respect to data size as investigated in Section 3.1.1, the encryption cost can be expressed as shown in Equation (A1):  
\[T_{i,r}=B_{i}\times S_{r}+C_{i}\] (A1)  
where \(T_{i}\) is the encryption cost of region \(r\) using encryption algorithm \(i\), \(S_{r}\) is the region \(r\) size, \(B_{i}\) is the slope, and \(C_{i}\) is the intercept value for the encryption algorithm \(i\). Assuming that ROI can be split into three different regions and each region will be encrypted using a different encryption approach, then the overall encryption time (including segmentation time) can be determined as shown in Equation (A2). Henceforth, our goal is to split the ROI into three different regions while guaranteeing that the processing time is less than the Naive approach processing time. At the same time, it is important to facilitate different security requirements. \[T_{total}=T_{1\_AES256}+T_{2\_AES128}+T_{3\_XXTEA128}+segmentation\_time\] (A2)  
Equation (A2) must satisfy the condition that is shown in Equation (A3), where \(T_{ROI\_AES256}\) represents the Naive encryption approach for the ROI. \[T_{total}<T_{ROI\_AES256}\] (A3)Let us assume that \(\in\) is a positive integer number that represents the desired saving time, then Equation (A3) can be rewritten as in Equation (A4):  
\[T_{total}+\in=T_{ROI\_AES256}\] (A4)  
Based on Section 3.1.1, the processing time of different encryption algorithms is estimated using linear equations that correspond to encryption algorithms and have the form of (\(T_{i}=B_{i}\times S_{r}+C_{i}\)). Each algorithm has a linear relationship that estimates its processing time, as shown in Equation (A5):  
\[T_{1\_AES256}=B_{1}\times S_{r1}+C_{1}\]  
\[T_{2\_AES128}=B_{2}\times S_{r2}+C_{2}\] (A5)  
\[T_{3\_XXXTEA128}=B_{3}\times S_{r3}+C_{3}\]  
Image size can be defined as in Equation (A6a):  
\[S_{img}=S_{ROB}+S_{ROI}\] (A6a) ROI size can be defined as in Equation (A6b):  
\[S_{ROI}=S_{r1}+S_{r2}+S_{r3}\] (A6b)  
Let us assume that we have constants \(K_{1},\,K_{2},\,K_{3}\), where:  
\[K_{1}+K_{2}+K_{3}=1\] (A7)  
Then regions' sizes, which are within ROI (\(r_{1},\ r_{2},r_{3}\)), can be considered as shown in Equations (A8)-(A10):  
\[T_{total}=T_{1\_AES256}+T_{2\_AES128}+T_{3\_XXTEA128}+segmentation\_time\]0 (A8)  
\[T_{total}=T_{1\_AES256}+T_{2\_AES128}+T_{3\_XXTEA128}+segmentation\_time\]1 (A9)  
\[T_{total}=T_{1\_AES256}+T_{2\_AES128}+T_{3\_XXTEA128}+segmentation\_time\]2 (A10)  
Accordingly, Equation (A5) can be written using Equations (A8)-(A10), as shown in Equation (A11):  
\[ \begin{array}{c}T_{1}=B_{1}K_{1}S_{ROI}+C_{1}\\ T_{2}=B_{2}K_{2}S_{ROI}+C_{2}\\ T_{3}=B_{3}K_{3}S_{ROI}+C_{3}\end{array} \] (A11)  
Equation (A11) can be rewritten in matrix form as in Equation (A12):  
\[ \begin{bmatrix}T_{1}\\ T_{2}\\ T_{3}\end{bmatrix} = \begin{bmatrix}B_{1}S_{ROI}&0&0\\ 0&B_{2}S_{ROI}&0\\ 0&0&B_{3}S_{ROI}\end{bmatrix}\begin{bmatrix}K_{1}\\ K_{2}\\ K_{3}\end{bmatrix} + \begin{bmatrix}C_{1}\\ C_{2}\\ C_{3}\end{bmatrix} \] (A12)  
The overall desired encryption time can be expressed as shown in Equation (A13):  
\[T_{d}=T_{ROI\_AES256}-segmentation\_time-\in\] (A13)  
Selective multi-region encryption must cover all security requirements, and this requires an adaptive security profile that can adapt to different levels of security risks. Such that, high-risk scenarios require that most of the ROI must be encrypted using AES-256 and AES-128. Hence, \(r_{1}\) and \(r_{2}\) sizes must be large in comparison with \(r_{3}\). Then, \(r_{1}\) and contributing to saving time will be minimum. On the other hand, for low-risk scenarios, \(r_{1}\) and \(r_{2}\) must highly contribute to saving processing time.