protected function calculateAuthenticationTag($encrypted_data, $cek, $iv, $aad, $encoded_header)
{
$calculated_aad = $encoded_header;
if (null !== $aad) {
$calculated_aad .= '.' . $aad;
}
$mac_key = mb_substr($cek, 0, mb_strlen($cek, '8bit') / 2, '8bit');
$auth_data_length = mb_strlen($encoded_header, '8bit');
$secured_input = implode('', [$calculated_aad, $iv, $encrypted_data, pack('N2', $auth_data_length / 2147483647 * 8, $auth_data_length % 2147483647 * 8)]);
$hash = hash_hmac($this->getHashAlgorithm(), $secured_input, $mac_key, true);
return mb_substr($hash, 0, mb_strlen($hash, '8bit') / 2, '8bit');
}