# Technique for Searching Data in a Cryptographically Protected SQL Database
## 4 The Proposed Technique for Searching the Required Data
At that, we use the same scheme that is used to encrypt the data of row \(\gamma\) for the corresponding column \(j\) of some table \(R\) of the database. Namely, an encryption scheme based on the use of some encryption algorithm (\(A_{enc}\)), encryption mode (\(M_{enc}\)) and secret key (\(K_{T}\)) selected from the list, as a function of \(K_{T}=f(K_{1}^{R},K_{2}^{j},x_{k})\). That is \(T_{k}=\text{Enc}_{f(K_{1}^{R},K_{2}^{j},x_{k})}(R,j,A_{enc},M_{enc},w_{k})\). The proposed solution has no fundamental restrictions on the encryption algorithm that will be used in it. It can be any, either existing or newly developed; the only requirement is the presence of its implementation at the time of the solution. For example, for definiteness, let these be the DES, Triple DES, AES algorithms with various modifications: \(A_{enc}=\{^{\prime}\text{DES}^{\prime},^{\prime}\text{3 DES}^{\prime},^{\prime }\text{3 DES}\_2\text{KEY}^{\prime},^{\prime}\text{AES128}^{\prime},^{\prime} \text{AES192}^{\prime},^{\prime}\text{AES256}^{\prime}\}\}\). There are also no fundamental restrictions on encryption modes. Example modes: \(M_{enc}=\{^{\prime}\text{CBC}^{\prime},^{\prime}\text{CCB}^{\prime},^{\prime} \text{CFB}^{\prime},^{\prime}\text{CFB}^{\prime}\}\). It should be noted that the encrypted trapdoor values for the same keyword \(w_{k}\) may differ (including due to the arbitrary choice of the number \(x_{k}\)). That is, trapdoors are non-deterministic, which makes it difficult to leak the search pattern. 6. Stages 4 and 5 are repeated for all \(w_{k}\) (\(w_{k}\in W\)). However, instead of generating a random number \(x_{k}\) each time, an increment of its initially generated value is allowed: \(x_{k+1}=x_{k}+1\), \(k=1,\ldots,|W|\), where \(|W|\) is the cardinality of the set of keywords \(w_{k}\). 7. Formation of the final query (\(Q_{M}\)) to the database that does not disclose sensitive data. 8. Launching some procedure stored on the DBMS server (\(P_{DS}\)), which determines the session parameters based on the data extracted from the transferred stegocontainers file\({}_{i}^{1}(K_{sec})\), file\({}_{i}^{2}(K_{ss})\), and key \(K_{pd}\). These parameters are valid for a legitimate user only in his active session. They are used in the corresponding modules of special software that support the functionality of the proposed solution. 9. Transferring the modified user query to the DBMS server for execution. The general scheme of the search query formation algorithm (Algorithm 1) is presented below. The essence of this query is to determine what actions were performed using bank cards '4454102135347018' and '5167135104128196' for a certain time interval (for simplicity. This period is not explicitly indicated; for example, it is assumed that this is the all time report), where at_1 _is the_ TABLE_1 (\(R\)) attribute of the remote database, the values of which are stored in encrypted form (in this case, this is the card number); _at_2_ is an attribute of _TABLE_1_ whose values are stored in plaintext (for example, an opcode); _id_ is a unique row identifier (primary key--_PK_) of the _TABLE_1_ table. Then, in accordance with the above algorithm, the following actions will be performed. After receiving the compressed encrypted file file\({}_{i-zip}^{enc}\), decrypting it (Dec\({}_{P_{i}}(\text{file}_{i-zip}^{enc})\)) with extracting the corresponding stegocontainers, as well as receiving the original SQL query with plaintext, the latter is parsed on the DB proxy server. **Example 1. ** Let the following query come from a legitimate user:  
select id, at_1, at_2 from TABLE_1  
where at_1 in ('4454102135347018', '5167135104128196')  
order by id;. Keywords \(w_{k}\) are extracted first. In this case, such keywords are bank card numbers \(w_{1}\) = '4454102135347018', \(w_{2}\) = '5167135104128196'. After that, using the existing PRNG, a random number is generated. For example, suppose the PRNG generated a random number \(c=160634721428732436748471615956417046369\).