예제 #1
0
        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;
                }
            });
        }
예제 #2
0
 public static LowLevelUdpResponseScanner GetScanner(DirectChannelToken32 senderToken32, uint pingRequestId32, InviteSession session)
 {
     BinaryProcedures.CreateBinaryWriter(out var ms, out var w);
     GetHeaderFields(w, senderToken32, pingRequestId32);
     return(new LowLevelUdpResponseScanner
     {
         ResponseFirstBytes = ms.ToArray(),
         OptionalFilter = (udpData) =>
         {
             var pong = Decode(udpData);
             if (pong.PingPongHMAC.Equals(
                     session.GetPingPongHMAC(pong.GetSignedFieldsForPingPongHMAC)
                     ) == false)
             {
                 return false;
             }
             return true;
         }
     });
 }
예제 #3
0
 static void GetHeaderFields(BinaryWriter writer, DirectChannelToken32 directChannelToken32, uint pingRequestId32)
 {
     writer.Write((byte)PacketTypes.DmpPong);
     directChannelToken32.Encode(writer);
     writer.Write(pingRequestId32);
 }