# A Novel Security Architecture for WSN-Based Applications in Smart Grid
## 4 Methodology
### The Characteristics of the Proposed PKI  
The clustering algorithm allows us to build a distributed and self-organized PKI. Each cluster consists of one CA, one or more RA, and a lot of ordinary MNs. Their roles are described as follows:  
* CA: it is the CH of the cluster. Its role is to manage short-term certificates for RAs and MNs.
* RA: it is a truthful node at 1 hop of the CA. Its role is to check certification requests received from MNs before forwarding them to the CA. The certification request is valid only if the requester node has a valid long-term certificate.
* MN: It is a regular node with no particular role in the cluster.  
We suppose that initially, all the sensor nodes have long-term certificates issued offline by a centralized CA, it is useful to authenticate the sensor nodes upon their entry into the network. Generally speaking, in a traditional PKI, all sensor nodes need to periodically communicate with the centralized CA to renew their certificates and avoid spoofing attacks. Since the considered WSN is deployed in a SG environment characterized by its wide area of coverage, a large number of sensor nodes, and the intermittent connection, this frequent communications risk failing, consequently, the sensor node will not be able to cooperate with its neighbors. To mitigate this problem, in the proposed architecture each sensor node belonging to a cluster asks for a short-term certificate from its CH, this certificate will be used to communicate within the cluster. If the sensor node is compromised or it needs to renew its expired short-term certificate, it must contact its CH. The CH issues the short-term certificate to the sensor nodes in its cluster after authenticating them using their long-term certificate. On one hand, this will reduce the delay in renewing the long-term certificates. On the other hand, it will avoid spoofing attacks. If the key of the sensor node is compromised, it can be easily and quickly revoked by the CH and a new certificate is issued instead of contacting the centralized CA.  
The new distributed architecture of the PKI circumvents many issues of the centralized approach. First, it allows the avoiding of the problem of a single point of failure by distributing the role of the CA among many sensor nodes elected based on many parameters that rely on the network topology. If one CA is compromised or no longer available, the certification process fails only in one cluster. More importantly, the RA sensor node will play a crucial role in the availability of the CA. Particularly, their role consists of filtering the certification requests intended for the CA and avoiding DoS attacks on it. The clustering process is based on a trust metric that allows filtering out malicious nodes upon the election of the CA. In addition, the asymmetric encryption feature provides non-repudiation, authentication, and confidentiality. Furthermore, the use of short-term certificates allows the mitigation of the sinkhole and Sybil attacks. Instead of storing short-term keys in the CA, periodically the sensor node renews its keys by contacting the CA in its cluster.  
Figure 1: Flowchart of the proposed clustering algorithm.