## 3 Long-Range, Low-Power IoT Communication Protocols and Their Security  
Although it has been observed in Section 2.3 that there are many lightweight encryption algorithms and some of them, such as CLEFIA and PRESENT, are part of standards such as ISO/IEC 29192, most IoT communication protocols use the Advanced Encryption Standard (AES) [43] to provide confidentiality, authentication, and integrity. A good example is the IEEE 802.15.4 physical and data link layer protocol. It provides seven security levels, based on AES-128, with 128-bit blocks:  
* security level zero means no security;
* security levels one to three provide only integrity and authentication by generating different sizes of message integrity code (MIC);
* security level four provides only confidentiality and security;
* security levels five to seven provide integrity, authentication, and confidentiality. In addition, other industry standards are based on IEEE 802.15.4, such as Zigbee and LoRaWAN [16]. AES is a symmetric cipher that encrypts data in blocks of 16 bytes or 128 bits. Different confidentiality modes of operation use AES as the cipher function. There are five modes of operation [44; 45]: Counter mode (CTR), Cipher Block Chaining (CBC), Electronic Code Book (ECB), Cipher Feedback (CFB), and Output Feedback (OFB). The AES-CTR mode, for example, is used in most standard IoT communication protocols, such as IEEE 802.15.4, to provide confidentiality. It does not require the plaintext data to be a multiple of the 128-bit or 16-byte block size. Therefore, it is good for smaller data packets. In the AES-CTR mode, the encryption and decryption functions are the same operations. Here, we describe how AES-CTR mode works. First, each input block is a counter value \(T_{1}\), \(T_{2}\),... \(T_{n}\), where \(n\) is the number of blocks into which the plaintext has been divided (\(P_{1}\), \(P_{2}\),... \(P_{n}\)). It is important that each counter value is different from any other [45], and also for the different inputs or plaintext. The AES encryption operations are then applied to each counter value and generate an output block \(O_{1}\), \(O_{2}\),... \(O_{n}\), as in Equation (1). Finally, a logical XOR operation is performed between the output block \(O_{i}\) and the plaintext block \(P_{i}\) to create the ciphertext block \(C_{i}\), as in Equation (2). \[O_{i}=\text{AES128\_encrypt(Key, }T_{i}) \tag{1}\]  
\[C_{i}=P_{i}\text{ XOR }O_{i} \tag{2}\]  
where \(T_{i}\) is the \(i\)th counter value and \(P_{i}\) is the \(i\)th plaintext block. As explained in [PERSON] [11], \"XORing the same value twice restores the original\". Thus, the same output block \(O_{i}\) can be used to decrypt the ciphertext using XOR. This is shown in Equation (3). Moreover, the same hardware or software is used to generate the output block because the same AES encryption function is used for encryption and decryption. This simplifies the security implementation in the IoT device. \[C_{i}=P_{i}\text{ XOR }O_{i}\text{ and }P_{i}=C_{i}\text{ XOR }O_{i} \tag{3}\]  
There are also two other benefits to resource-constrained devices. The encryption of different blocks of data can be done in parallel and be pre-calculated since the counter values can be obtained in advance of the plaintext data [44; 45]. On the other hand, the AES Cipher Block Chaining (CBC mode) is used to compute the message authentication code (MAC), or message integrity code (MIC). The AES-CBC mode is also known as AES cipher-based MAC (CMAC) mode [46]. In general, MIC is used to validate the integrity of the data at the receiving node, and MAC is used to ascertain the origin of data, but each can take both roles. The MAC or MIC is a one-way hash function that uses a secret key [11]. It is verified by the receiving node at the core network. For instance, the gateway node receives a frame from the sensor node, and then calculates theMIC using the received frame as input. If the calculated MIC value is the same as the MIC that was received with the frame, the packet is accepted.