ted by upper layers for downlink and uplink transmissions. The COUNT value is composed of a hyper- frame number (HFN) and the PDCP SN. The size of the HFN part in bits is equal to 32 230 Chapter 2 Count Bearer Direction Length Count Bearer Direction Length Encryption algorithm for 5G Encryption algorithm for 5G (NEA) (NEA) Keystream Keystream block block Plaintext block Ciphertext block Plaintext block Transmitter Receiver PDCP SN Count Figure 2.17 Illustration of the ciphering and deciphering procedures [2,11]. minus the length of the PDCP SN. The PDCP does not allow COUNT to wrap around in the downlink and uplink; thus it is up to the network to prevent it from happening [2,8,11]. As shown in Fig. 2.18, the input parameters to the 128-bit NR integrity protection algorithm (NIA) (or alternatively integrity protection algorithm for 5G) are the RRC messages denoted as MESSAGE, 128-bit integrity key KRRCint referred to as KEY, 5-bit bearer identity BEARER, 1-bit direction of transmission denoted as DIRECTION, and a bearer specific direction-dependent 32-bit input COUNT which corresponds to the 32-bit PDCP COUNT. The RRC integrity checks are performed both in the UE and the gNB. If the gNB or the UE receives a PDCP PDU which fails the integrity check with faulty or missing message authentication code (MAC-I) after the start of integrity protection, the PDU will be dis- carded. The DIRECTION bit set to zero for uplink and one for downlink. The bit length of the MESSAGE is LENGTH. Based on these input parameters, the sender computes a 32-bit message authentication code (MAC-I/NAS-MAC)™ 5 using the integrity protection algorithm In cryptography a MAC-I is a cryptographic checksum on data that uses a session key to detect both acciden- tal and intentional modifications of the data. A MAC (not to be confused with medium access control MAC) requires two inputs: a message and a secret key known only to the originator of the message and its intended recipient(s). This allows the recipient of the message to verify the integr