public void GetSignedFieldsForPingPongHMAC(BinaryWriter writer) { writer.Write((byte)PacketTypes.DmpPing); DirectChannelToken32.Encode(writer); writer.Write(PingRequestId32); if (PublicEcdheKey != null) { PublicEcdheKey.Encode(writer); } }
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; } }); }
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); }
static void GetHeaderFields(BinaryWriter writer, DirectChannelToken32 directChannelToken32, uint pingRequestId32) { writer.Write((byte)PacketTypes.DmpPong); directChannelToken32.Encode(writer); writer.Write(pingRequestId32); }