# Data Security-Based Routing in MANETs Using Key Management Mechanism
## 3 Secure Data Communication Framework
### Selection of the Calculator Key (CK) and Distribution Key (DK)  
Initially, the network assigns energy levels to each node in its system. The CK and DK nodes are evaluated by following the route discovery, using residual activity levels and route-critical nodes. The CK node generates keys, i.e., public and private keys, and provides them to the DK. The goal of the CK is to obtain secret key pair variables and communicate only the set key to DK. Before the keys are distributed, all nodes in the network connection must be registered with the DK node, which verifies the node's validity. Figure 4 shows the selection of the CK and DK.  
Figure 5 shows the flow of a key distribution process. Initially, the CK generates a key pair set and makes it broadly available for the DK. Thereafter, the  
Figure 4: Selection of the Calculator Key (CK) and Distribution Key (DK).  
to the registered nodes. The following approach is used to create key pairs that contain both public and private keys. Take two numbers that are primary \(l\) and \(p\):  
\[\begin{split}& PUR=l\times p\\ &\Theta(R)=(l-1)(p-1)+l+p\\ & H(j)=\Theta(R)+(l\& p)\\ & PUB(R_{i})=H(R)\& l\& p+PUK\end{split} \tag{8}\]  
where \(PUR\) defines the product of two nodes, \(H(j)\) shows the functions for generating the public key, \(\Theta(R)\) defines the node-to-node distance for small values, and \(H(R)\) is a function of the modified node value.  
For the generation of a private key \(KC\), integer numbers \(w_{1}\), \(w_{2},...,w_{o}\) are assumed to be 1 in the first and last Greatest Common Divisor (GCD) numbers. Consider a new number set, \(n_{1}\), \(n_{2}\),..., \(n_{o}\):  
\[\begin{split}&\text{R}\equiv n_{1}(\text{mod}\,w_{1})\\ &\text{R}\equiv n_{2}(\text{mod}\,w_{2})\ldots\text{R}\equiv n_{o}( \text{mod}\,w_{o})\\ &\text{R}=n_{1}\text{q}\text{1R}1+n_{2}\text{q}\text{R}2+\ldots \ldots\ldots+n_{o}\text{q}_{0}\text{R}_{0}\\ &\text{T}_{i}=\text{V}_{i}/n_{k},\text{q}_{k}=\text{T}_{k}-l( \text{mod}\,n_{k})\\ &\text{PRK}(\text{R}_{k})=\text{T}_{k}\times\text{PUB}(\text{R}_{ k})-l-\text{p}-\text{PUR}.\\ &\text{KeyPair}(\text{RP})=\text{set}\{\text{PUB}(\text{K}_{k}): \text{PUR}(\text{R}_{k})\}\end{split} \tag{9}\]  
Here, \(R\) represents the distance between both key nodes, \(PRK\) shows the private key, \(PUB\) shows public key, \(T_{i}\) shows the trust value of the \(i\)th node, \(R_{K}\) is a modified private key, \(q\) shows the various functions required for the generation of \(PUB\), and \(V_{i}\) represents a velocity of transmission distance for the \(i\)th node.  
The DK receives the key pairs once they have been generated. The public key from the DK is requested based on the routing information of the source node whenever communication is started. The DK searches the routing database for the key and sends it to the encryption unit. Based on the routing table's information, the actual amount of data is divided into data packets and supplied to neighboring nodes (refer to [32,33]). If data is received by the destination node, a request is made to forward the source node ID to the private key. The DK analyzes the destination as legitimate or not and then transfers the data-decryption privacy key to the target node. Figure 6 demonstrates the proposed data-communication framework.  
Figure 5: Flow of the key distribution process.