ity of the message and authenticate that the message sender has the shared secret key. Any mismatch between the sender's and receiver's calcu- lated MAC-I values would invalidate the message. There are four types of message authentication codes: unconditionally secure, hash function-based, stream cipher-based, and block cipher-based. In the past, the most common approach to creating a message authentication code was to use block ciphers; however, hash- based MACs which use a secret key in conjunction with a cryptographic hash function to produce a hash, have become more widely used. New Radio Access Layer 2/3 Aspects and System Operation 231 Count Bearer Direction Message Count Bearer Direction Message Integrity algorithm for 5G Integrity algorithm for 5G (NIA) (NIA) MAC-I/NAS-MAC XMAC-I/XNAS-MAC Compare MAC-I/NAS- Valid/ Message Message + MAC-I (NAS-MAC) MAC and XMAC-I/XNAS- invalid Transmitter Receiver PDCP SN Count Figure 2.18 Integrity protection and verification procedures [2,11]. NIA. The message authentication code is then appended to the message when sent. For integrity protection algorithms, the receiver computes the expected message authentication code (XMAC-I/XNAS-MAC) on the message received in the same way that the sender computed its message authentication code on the message sent and verifies the integrity of the message by comparing it to the received message authentication code, that is, MAC-I/ NAS-MAC. The integrity protection algorithm and key to be used by the PDCP entity are configured by upper layers and the integrity protection method is applied according to secu- rity architecture of 3GPP SAE [2]. The integrity protection function is activated by upper layers. Following the security activation, the integrity protection function is applied to all PDUs including and subsequent to the PDU indicated by upper layers for downlink and uplink transmissions. As the RRC message which activates the integrity protection function is itself integrity protected with the configuration included in that RRC