internal static LowLevelUdpResponseScanner GetScanner(DirectChannelToken32 localDirectChannelToken32, InviteSession session) { if (!session.DerivedDirectChannelSharedDhSecretsAE) { throw new InvalidOperationException("DerivedDirectChannelSharedDhSecretsAE=false"); } BinaryProcedures.CreateBinaryWriter(out var ms, out var w); w.Write((byte)PacketTypes.MessageStart); localDirectChannelToken32.Encode(w); return(new LowLevelUdpResponseScanner { ResponseFirstBytes = ms.ToArray(), OptionalFilter = (udpData) => { if (!session.DerivedDirectChannelSharedDhSecretsAE) { return false; } var msgStart = Decode(udpData); if (msgStart.MessageHMAC.Equals( session.GetMessageHMAC(w2 => msgStart.GetSignedFieldsForMessageHMAC(w2, true)) ) == false) { return false; } return true; } }); }
internal static LowLevelUdpResponseScanner GetScanner(uint messageId32, InviteSession session, MessageSessionStatusCode statusCode) { BinaryProcedures.CreateBinaryWriter(out var ms, out var w); w.Write((byte)PacketTypes.MessageAck); w.Write(messageId32); w.Write((byte)statusCode); return(new LowLevelUdpResponseScanner { ResponseFirstBytes = ms.ToArray(), OptionalFilter = (udpData) => { var msgAck = Decode(udpData); if (msgAck.MessageHMAC.Equals( session.GetMessageHMAC(msgAck.GetSignedFieldsForMessageHMAC) ) == false) { return false; } return true; } }); }