## 5 SCODE_plus_: Enhanced Secure Routing and Key Management Scheme
### Secure Data Dissemination Scheme to Mobile Sinks
#### 5.3.2 Three Main Phases.  
(a) Phase 1: Secure Data Announcement:  
When a stimulus is detected, a source \(S\) propagates a _Data-Announcement_ (DA) message to all coordinators using a flooding mechanism. The message contains source ID, cell ID and a MAC:  
\[S\xrightarrow{} broadcast:\ \ \ \ \ \ \ \ \ \ PID\mid ID_{S}\mid CID_{S}\mid\{\text{DA}\}K_{S}\mid\text{ MAC ($K_{S}$, $PID\mid ID_{S}\mid CID_{S}\mid\{\text{DA}\}K_{S}$)}\]  
Every coordinator stores a few piece of information for the route discovery, including the information of the stimulus and its cell ID. Since the coordinator role might be changed every time, cell ID is the best solution for nodes to know the target it should relay the query to. In order to avoid indefinite storing of data-announcement messages in each coordinator, the source attaches a _timeout_ parameter in each message. Within the timeout interval, if the coordinator has not received any further data-announcement message, it removes the information of the stimulus and the source location to free the cache.  
(b) Phase 2: Secure Query Transfer and Route Discovery  
Receiving a data-announcement message, a sink looks up in its \(\{\{\mathit{ID}_{node}\)\(K_{node}\}\}\) table, finds the key _K\({}_{S}\)_ shared with the source, and uses it to decrypt the message. It then constructs a query message using _K\({}_{S}\)_ and sends back to the source via coordinators as follows:  
\(\circ\) The sink first send message to its agent. The agent is a coordinator within the same cell. If the sink locates outside of the network (not belong to any cell), then the agent would be the coordinator in the closest cell.  
\[\begin{array}{l}\mathit{Sink}\rightarrow\mathit{Agent}\text{:}\quad\mathit{PID}\mid \mathit{CID}_{\mathit{This}}\mid\mathit{CID}_{\mathit{Next}}\mid\mathit{ID}_{S} \mid\mathit{CID}_{S}\mid\mathit{ID}_{\mathit{Sink}}\mid\{\text{ QUERY }\}K_{S}\mid\text{MAC }(K_{\mathit{Sink}\mathit{Agent}}\text{,}\\ \mathit{PID}\mid\mathit{CID}_{\mathit{This}}\mid\mathit{CID}_{\mathit{Next}} \text{ })\mid\text{MAC }(K_{S}\text{,}\mathit{ID}_{S}\mid\mathit{CID}_{S}\mid\mathit{ID}_{\mathit{ Sink}}\mid\{\text{QUERY }\}K_{S}\text{ })\end{array}\]  
where \(\mathit{CID}_{\mathit{This}}\) is cell ID of the agent, and \(\mathit{CID}_{\mathit{Next}}\) is cell ID of the next cell (in this case \(\mathit{CID}_{\mathit{This}}\)\(=\mathit{CID}_{\mathit{Sink}}\), and \(\mathit{CID}_{\mathit{Next}}\)\(=\mathit{CID}_{\mathit{Agent}}\)). The source key \(K_{S}\) is used to encrypt the query content. It is also used to build a \(\mathit{MAC}\) of \(\mathit{ID}_{S}\). \(\mathit{CID}_{S}\) and \(\mathit{ID}_{\mathit{Sink}}\) in order to provide data authentication and data integrity of the information sent from the sink. The pair-wise shared key \(K_{\mathit{Sink}\mathit{Agent}}\) is used to build a \(\mathit{MAC}\) of \(\mathit{PID}\), \(\mathit{CID}_{\mathit{This}}\), and \(\mathit{CID}_{\mathit{Next}}\) in order to provide data authentication and data integrity of the packet sent from the current node.
* The agent computes next cell ID (which is the closest cell to the destination) towards the source, and then forwards the packet to it. \[\begin{array}{l}\mathit{Agent}\text{