private static byte[] ComputeM(AKEKeys ake_keys, byte[] my_public_key_mpi_byte_array, byte[] their_public_key_mpi_byte_array, byte[] dsa_public_key_bytes_encoded, byte[] key_id_byte_array, bool is_top_half_keys) { if (my_public_key_mpi_byte_array == null || my_public_key_mpi_byte_array.Length < 1) throw new ArgumentException("ComputeM: My public key mpi byte array cannot be null/empty"); if (their_public_key_mpi_byte_array == null || their_public_key_mpi_byte_array.Length < 1) throw new ArgumentException("ComputeM: Their public key mpi byte array cannot be null/empty"); if (key_id_byte_array == null || key_id_byte_array.Length < 1) throw new ArgumentException("ComputeM: The id byte array cannot be null/empty"); if (dsa_public_key_bytes_encoded == null || dsa_public_key_bytes_encoded.Length < 1) throw new ArgumentException("ComputeM: The encoded DSA public key byte array cannot be null/empty"); if (ake_keys == null) throw new ArgumentException("ComputeM: AKE keys object cannot be null"); byte[] _encoded_key_id_byte_array = null; try { Utility.EncodeOTRInt(key_id_byte_array, ref _encoded_key_id_byte_array); } catch (Exception ex) { throw new InvalidDataException("ComputeM:" + ex.ToString()); } int _m_data_array_length = _encoded_key_id_byte_array.Length + my_public_key_mpi_byte_array.Length + their_public_key_mpi_byte_array.Length + dsa_public_key_bytes_encoded.Length; byte [] _m_data_array = new byte[_m_data_array_length]; Buffer.BlockCopy(my_public_key_mpi_byte_array, 0, _m_data_array, 0, my_public_key_mpi_byte_array.Length); Buffer.BlockCopy(their_public_key_mpi_byte_array, 0, _m_data_array, my_public_key_mpi_byte_array.Length, their_public_key_mpi_byte_array.Length); Buffer.BlockCopy(dsa_public_key_bytes_encoded, 0, _m_data_array, my_public_key_mpi_byte_array.Length + their_public_key_mpi_byte_array.Length, dsa_public_key_bytes_encoded.Length); Buffer.BlockCopy(_encoded_key_id_byte_array, 0, _m_data_array, my_public_key_mpi_byte_array.Length + their_public_key_mpi_byte_array.Length + dsa_public_key_bytes_encoded.Length, _encoded_key_id_byte_array.Length); if (is_top_half_keys == true && (ake_keys.GetMACKey1() == null || ake_keys.GetMACKey1().Length < 1)) throw new ArgumentException("ComputeM: The AKE MAC key 1 cannot be null/empty"); if (is_top_half_keys == false && (ake_keys.GetMACKey3() == null || ake_keys.GetMACKey3().Length < 1)) throw new ArgumentException("ComputeM: The AKE MAC key 3 cannot be null/empty"); if (is_top_half_keys == true) return Utility.SHA256GetKeyedHash(ake_keys.GetMACKey1(),_m_data_array); else return Utility.SHA256GetKeyedHash(ake_keys.GetMACKey3(), _m_data_array); }