**1. Introduction**

Wireless sensor networks (WSNs) are made up of a large number of tiny sensors, which can sense, analyze, and communicate information about the outside world. These networks play a significant role in a broad range of fields, from crucial military surveillance applications to monitoring building security [1]. In these networks, a sizable number of sensor nodes are placed throughout a big field, where the operational environment is frequently hostile or severe, to monitor it. However, because of their low processing speed, little memory, and insufficient energy, WSN nodes face significant resource limitations. Hence, these networks need to include security features to protect against attacks like physical tampering, node capture, denial of service, eavesdropping, etc. as they are typically placed in distant locations and left unattended.

Unfortunately, resource-constrained sensor nodes cannot implement typical security measures because of their large overhead. Researchers in WSN security have put out many security protocols that are tailored to these networks' resource limitations.

Researchers in WSN security have proposed several protocols for secure and efficient routing [2–5], securely aggregating data for protecting data privacy [6–11], etc.

Since WSN architectures are mostly decentralized, and due to the lack of any infrastructure, security procedures used in WSNs need also to incorporate cooperation among the nodes along with addressing more security challenges like secure routing and aggregation of data. In the real-world deployment scenario, WSNs cannot be a priori taken to be reliable. To address the issues that standard cryptographic algorithms are unable to address, researchers have concentrated on developing a sensor trust model [12–19].

Vulnerability to physical attacks is a significant concern in WSNs since the sensor nodes are typically unattended and physically unsafe. There are several ideas in the literature for protecting sensor nodes from physical attack [20–29].

The choice of the cryptographic scheme and the key distribution and management protocol for a WSN is an extremely critical decision as the entire security of the network is based on these schemes. However, designing a computationally efficient yet highly secure key management scheme is a challenging task. While these resourceconstrained sensor nodes should not be exposed to computationally demanding public key-based algorithms, the use of symmetric key cryptography leaves the network vulnerable to several attacks. This chapter provides a comprehensive survey and a comparative analysis of various cryptographic mechanisms and key management schemes in the current literature.

The rest of the chapter is organized as follows. Section 2 presents different cryptographic schemes used in WSNs including the public key and the symmetric key-based algorithms and systems. Section 3 discusses several key management schemes including the network architecture-based protocols and deterministic, and probabilistic key distribution mechanisms. Finally, Section 4 concludes the chapter and highlights some future research directions.
