## 7 Weak Authentication  
As described in Section 5, the message-specific puzzle (MSP) can be used as a weak authentication to prevent nodes from performing complex cryptographic operations when a forged packet arrives. For more details about the behavior of message-specific puzzle, see [30]. Unlike other protocols, in Seluge++, since we are using symmetric cryptography and MAC authentication, it will not be very energy consuming to perform a decryption algorithm compared to asymmetric signature verification. However, we suggest using message-specific puzzles only when needed, in case of attacks taking place in the network. Detection of an attack in which the attacker is sending forged packets is easy; therefore, we will define a threshold after which the node will challenge the server (BS) to send the MSP puzzles, so that, afterward, only packets that have the correct puzzle solutions will be considered as semi-authentic. The authenticity of semi-authentic packets then will be evaluated using MAC authentication. ```
1:Base Station:
2:\(I\Leftarrow\left\lceil\frac{NPPP\times|H(.)|}{B-|MAC_{SK}(. )|}\right\rceil\)
3:\(T\Leftarrow(p,a,b,G,n,h)\) elliptic curve domain parameters
4:\(d_{S}\Leftarrow\) random integer number \((1<d_{S}<n-1)\)
5:\(N_{0}\Leftarrow\) 160\(-bit\) random number
6:\(Q_{S}\Leftarrow d_{S}G\)
7:\(V_{n}\Leftarrow Version\ number\)
8: Sign \(V_{n},I,N_{0},Q_{S}\) using \(GK_{Pri}\)
9: Send \(Sign_{GK_{Pri}}(\{V_{n},I,N_{0},Q_{S}\})\) to node
10:Node:
11:\((I,V_{n},N_{0},Q_{S})\Leftarrow Verify_{GK_{pub}}(Sign_{GK_{Pri}}(\{V_{n},I,N_{0},Q_{S}\}))\)
12:if\(V_{n}\leq previousV_{n}\)then
13: Notify BS of an ongoing replay attack. 14: Halt dissemination protocol for a pre-configured time. 15: Exit
16:endif
17:\(previousV_{n}\Leftarrow V_{n}\)
18:\(d_{N}\Leftarrow\) random integer number \((1<d_{N}<n-1)\)
19:\(Q_{N}\Leftarrow d_{N}G\)
20:\(SK\Leftarrow H^{80}(d_{N}Q_{S})\)
21: Free memory reserved by \(d_{N},Q_{S}\)
22:\(N_{1}\Leftarrow 160-bit\ random\ number\)
23: Execute Algorithm 3 (Input: \(N_{1}\)) {Optional}
24: Send \(\{Q_{N},\ Enc^{80}_{SK}(N_{1}),\ MAC^{160}_{SK}(Q_{N}\oplus N_{0})\}\) to BS
25:Base Station:
26:\(Pkt\Leftarrow\{Q_{N},\ Enc^{80}_{SK}(N_{1}),\ MAC^{160}_{SK}(Q_{N}\oplus N_{0})\}\)
27:\(SK\Leftarrow H^{80}(d_{S}Q_{N})\)
28:\(MSG\Leftarrow Pkt[0]\oplus N_{0}\,\{Pkt[0]=Q_{N}\}\)
29:\(generatedMAC\Leftarrow MAC^{160}_{SK}(MSG)\)
30:if\(generatedMAC<>Pkt[2]\)then
31: Exit. 32:endif
33:\(N_{1}\Leftarrow Dec^{80}_{SK}(Enc^{80}_{SK}(N_{1}))\)
34: Execute Algorithm 3(Input: \(N_{1}\)) {Optional}
35: Encrypt update image with \(SK\)
36: Fragment encrypted data as shown in Figure 4
37:for all\(Pkt_{0,i}\) in Page0 do
38: Send \(\{Enc^{80}_{SK}(Pkt_{0,i}),\ MAC^{160}_{SK}(Enc^{80}_{SK}(Pkt_{0,i}))\}\) to the node
39:endforConsequently, the message-specific puzzle feature will be disabled during the normal state of the network, but in order to use it when needed, we might prefer to generate the hash chain _a priori_. This means that the hash chain must be populated into the BS and the node to be used in the case of any emergency situation. One way of doing so, as proposed in [12], is to store the hash chain in every node before deployment of nodes. This causes vulnerabilities, since most of the hash functions that are suitable to be used in a WSN are vulnerable to collision attacks. Therefore, in the long-time usage of a constant hash chain, the commitment of the chain will be revealed. Seluge++ will generate this key chain in the dissemination of each update. However, only for authentication packets, we suggest using the same approach as [12] suggests to store the offline MSP hash chain during the deployment of the nodes, but with a few changes to make sure that it is less susceptible to collision attacks.