コード例 #1
0
ファイル: DmpPingPackets.cs プロジェクト: ciprianp/dcomms
 public void GetSignedFieldsForPingPongHMAC(BinaryWriter writer)
 {
     writer.Write((byte)PacketTypes.DmpPing);
     DirectChannelToken32.Encode(writer);
     writer.Write(PingRequestId32);
     if (PublicEcdheKey != null)
     {
         PublicEcdheKey.Encode(writer);
     }
 }
コード例 #2
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;
                }
            });
        }
コード例 #3
0
        public byte[] Encode()
        {
            BinaryProcedures.CreateBinaryWriter(out var ms, out var writer);
            writer.Write((byte)PacketTypes.MessageStart);
            DirectChannelToken32.Encode(writer);
            writer.Write(MessageId32);
            byte flags = 0;

            writer.Write(flags);
            writer.Write(MessageTimestamp64);
            BinaryProcedures.EncodeByteArray65536(writer, EncryptedMessageData);
            MessageHMAC.Encode(writer);

            var r = ms.ToArray();

            if (r.Length > 500)
            {
                throw new ArgumentException();
            }
            return(r);
        }
コード例 #4
0
ファイル: DmpPingPackets.cs プロジェクト: ciprianp/dcomms
 static void GetHeaderFields(BinaryWriter writer, DirectChannelToken32 directChannelToken32, uint pingRequestId32)
 {
     writer.Write((byte)PacketTypes.DmpPong);
     directChannelToken32.Encode(writer);
     writer.Write(pingRequestId32);
 }