# A Framework for Constructing a Secure Domain of Sensor Nodes
## 4 Procedures for Creating a Secure Domain of Sensor Nodes
### The Procedure for the Registration Node in the Security Domain
remains unchanged (the field is not encrypted); RN = \"R + G\" if it is the first R node registered in the security domain; RN = \"R\" if it is not the first R node registered in the security domain; NSK and IV = the NSK key and IV vector gathered from the _transfer_key_req_ packet; NAD = NAD gathered from _transfer_key_req_ packet; Stat = Active (0); Time = current time. Increase by 1 version number (VER) and update the domain description. * Send a confirmation of registration to node R (_transfer_key_ans_ packet (Figure 11)). The confirmation contains N_ID, RN, NTK, IV, GAD, SQ and is encrypted using the NSK and IV vector of the R node. If the node is the first registered node in the security domain, the NAD address gathered from the _node_description_req_ packet is stored in NVRAM of TPM as the gateway address (GAD) in the domain of transmitting sensory data. In another case, the GAD is acquired from NVRAM of the TPM. Figure 11: The confirmation frame for node registration. SQ: sequence number. Figure 9: The data updated on the M node and R node (highlighted in yellow) at the end of the procedure of registering the SECOND R node in the security domain. (7) Acquire the NTK key. Do the following:  
* On the R node, decrypt the data from _transfer_key_ans_ packet using the NSK and verify the correctness of the SQ field. If it is not correct, print the message and stop the procedure;
* Based on the contents of the _transfer_key_ans_ packet, update the RN, NTK, IV, GAD, and SQ fields, respectively, in NVRAM of TPM and RAM of the R node. **(10) Acquire the NDK key. ** Do the following:  
* Send a request of diagnostic key (_diagnostic_key_req_ packet (Figure 12)) from the R node to the M node. The sequence number (SQ) is increased by 1. The packet is encrypted using the NSK key of the R node. * On the M node, prepare a diagnostic key and send it to the R node (_diagnostic_key_ans_ packet). The SQ from the _diagnostic_key_req_ packet is increased by 1. The packet is encrypted using the NSK key of the R node;
* Based on the contents of the _diagnostic_key_ans_ packet, update the NDK, IV, and SQ fields, respectively, in NVRAM of TPM and RAM of the R node. **(13) Acquire a copy of the domain description**. Do the following:  
* Send a request of the diagnostic key (_domain_descr_req_ packet (Figure 13)) from the R node to the M node. The SQ is increased by 1. The packet is encrypted using the NSK of the R node;
* Based on the contents of the _domain_descr_ans_ packet, update the DN, VER, PR, PNR, TDV, and SQ fields, respectively, in the EEPROM and RAM of the R node. On R node, the field RN in the domain description is updated to the RN of the node. Figure 12: The frames used by R node to acquire the NDK. **(17) Acquire a copy of the description of the domain nodes**. The number \(N\) of transferred descriptions is limited by the size area of the R node EEPROM or by the number of descriptions on the M node. Only one full description of the node is transferred in one round of using the _back_up_node_req_ packet and _back_up_node_ans_ packet (Figure 14). If the descriptions of the nodes are not filled (this applies to unregistered nodes so far), in one _back_up_node_ans_ packet, it is possible to send no more than nine incomplete descriptions of nodes. Do the following repeatedly:  
* Send a request of the \(i\)th (i belongs to the range \(<\)1; N\(>\)) node description (_back_up_node_req_ packet) from the R node to the M node. The SQ is increased by 1. The packet is encrypted using the NSK of the R node;
* On the M node, prepare the node description (_back_up_node_ans_ packet) and send it to the R node. The received SQ is increased by 1. The Num is a serial number of the first requested node from the _back_up_node_req_ packet. The packet is encrypted using the NSK of the R node. If the requested data concerns a registered node, then a \"0\" type packet containing a full description of this node is sent as an answer. If the requested data does not apply to the registered node, then the type \"1\" packet is sent.