Example #1
0
 public override void WritePayload(IValueWriter writer)
 {
     base.WritePayload(writer);
     writer.WriteBytes(InternalPeerEndPoint.Address.GetAddressBytes());
     writer.WriteInt32(InternalPeerEndPoint.Port);
     writer.WriteBytes(ExternalPeerEndPoint.Address.GetAddressBytes());
     writer.WriteInt32(ExternalPeerEndPoint.Port);
 }
 public override void WritePayload(IValueWriter writer)
 {
     base.WritePayload(writer);
     writer.WriteBytes(InternalOwnEndPoint.Address.GetAddressBytes());
     writer.WriteInt32(InternalOwnEndPoint.Port);
     writer.WriteBytes(ExternalPeerEndPoint.Address.GetAddressBytes());
     writer.WriteInt32(ExternalPeerEndPoint.Port);
 }
Example #3
0
        public void Serialize(ISerializationContext context, IValueWriter writer, IAsymmetricCrypto crypto)
        {
            if (!writer.WriteBool(this.publicKey != null))
            {
                return;
            }

            writer.WriteBytes(crypto.Encrypt(Exponent));

            int first = this.Modulus.Length / 2;

            writer.WriteBytes(crypto.Encrypt(Modulus.Copy(0, first)));
            writer.WriteBytes(crypto.Encrypt(Modulus.Copy(first, Modulus.Length - first)));
        }
Example #4
0
 public override void WritePayload(ISerializationContext context, IValueWriter writer)
 {
     using (var ms = new MemoryStream())
     {
         ScreenFrame.Save(ms, ImageFormat.Png);
         writer.WriteBytes(ms.GetBuffer());
     }
 }
 public override void WritePayload(ISerializationContext context, IValueWriter writer)
 {
     using (var ms = new MemoryStream())
     {
         ScreenFrame.Save(ms, ImageFormat.Png);
         writer.WriteBytes(ms.GetBuffer());
     }
 }
Example #6
0
 public void Serialize(ISerializationContext context, IValueWriter writer, RSAParameters element)
 {
     writer.WriteBytes(element.D);
     writer.WriteBytes(element.DP);
     writer.WriteBytes(element.DQ);
     writer.WriteBytes(element.Exponent);
     writer.WriteBytes(element.InverseQ);
     writer.WriteBytes(element.Modulus);
     writer.WriteBytes(element.P);
     writer.WriteBytes(element.Q);
 }
Example #7
0
        public void Serialize(ISerializationContext context, IValueWriter writer)
        {
            if (!writer.WriteBool(this.publicKey != null))
            {
                return;
            }

            writer.WriteBytes(this.publicKey);
            writer.WriteInt32(this.exponentOffset);
        }
Example #8
0
        public override void WritePayload(ISerializationContext context, IValueWriter writer)
        {
            writer.WriteInt32(SourceId);
            writer.WriteInt32(Sequence);

            writer.WriteByte((byte)Data.Length);
            for (int i = 0; i < Data.Length; ++i)
            {
                writer.WriteBytes(Data[i]);
            }
        }
        private void SerializableSerializer(IValueWriter writer, object value)
        {
            if (this.type.IsClass)
            {
                writer.WriteBool(value == null);
            }

            using (MemoryStream stream = new MemoryStream())
            {
                new BinaryFormatter().Serialize(stream, value);
                writer.WriteBytes(stream.ToArray());
            }
        }
        public void ReadWriteBytesSubset()
        {
            IValueWriter writer = GetWriter();

            byte[] data = new byte[] { 0x4, 0x8, 0xF, 0x10, 0x17, 0x2A };
            writer.WriteBytes(data, 2, 3);
            writer.Flush();

            data = GetReader(writer).ReadBytes();
            Assert.AreEqual(3, data.Length);
            Assert.AreEqual(0xF, data[0]);
            Assert.AreEqual(0x10, data[1]);
            Assert.AreEqual(0x17, data[2]);
        }
Example #11
0
        public override void WritePayload(ISerializationContext context, IValueWriter writer)
        {
            writer.WriteByte((byte)TargetType);

            writer.WriteUInt16((ushort)TargetIds.Length);
            for (int i = 0; i < TargetIds.Length; ++i)
            {
                writer.WriteInt32(TargetIds[i]);
            }

            writer.WriteInt32(Sequence);
            writer.WriteInt32(SourceId);

            writer.WriteByte((byte)Data.Length);
            for (int i = 0; i < Data.Length; ++i)
            {
                writer.WriteBytes(Data[i]);
            }
        }
Example #12
0
        public void Serialize(ISerializationContext context, IValueWriter writer)
        {
            if (!writer.WriteBool (this.publicKey != null))
                return;

            writer.WriteBytes (this.publicKey);
            writer.WriteInt32 (this.exponentOffset);
        }
 public override void WritePayload(IValueWriter writer)
 {
     base.WritePayload(writer);
     writer.WriteBytes(RegisteredEndPoint.Address.GetAddressBytes());
     writer.WriteInt32(RegisteredEndPoint.Port);
 }
Example #14
0
 public override void WritePayload(IValueWriter writer)
 {
     base.WritePayload(writer);
     writer.WriteBytes(RegisteredEndPoint.Address.GetAddressBytes());
     writer.WriteInt32(RegisteredEndPoint.Port);
 }
Example #15
0
        public void Serialize(ISerializationContext context, IValueWriter writer)
        {
            if (writer.WriteBool (D != null))
            {
                writer.WriteBytes (D);
                writer.WriteBytes (DP);
                writer.WriteBytes (DQ);
                writer.WriteBytes (InverseQ);
                writer.WriteBytes (P);
                writer.WriteBytes (Q);
            }

            if (writer.WriteBool (this.publicKey != null))
            {
                writer.WriteBytes (this.publicKey);
                writer.WriteInt32 (this.exponentOffset);
            }
        }
Example #16
0
        public void Serialize(IValueWriter writer, IPublicKeyCrypto crypto)
        {
            if (writer.WriteBool (D != null))
            {
                writer.WriteBytes (crypto.Encrypt (D));
                writer.WriteBytes (crypto.Encrypt (DP));
                writer.WriteBytes (crypto.Encrypt (DQ));
                writer.WriteBytes (crypto.Encrypt (InverseQ));
                writer.WriteBytes (crypto.Encrypt (P));
                writer.WriteBytes (crypto.Encrypt (Q));
            }

            if (writer.WriteBool (this.publicKey != null))
            {
                writer.WriteBytes (crypto.Encrypt (Exponent));

                int first = Modulus.Length / 2;
                writer.WriteBytes (crypto.Encrypt (Modulus.Copy (0, first)));
                writer.WriteBytes (crypto.Encrypt (Modulus.Copy (first, Modulus.Length - first)));
            }
        }
Example #17
0
        public void Serialize(ISerializationContext context, IValueWriter writer, IAsymmetricCrypto crypto)
        {
            if (!writer.WriteBool (this.publicKey != null))
                return;

            writer.WriteBytes (crypto.Encrypt (Exponent));

            int first = this.Modulus.Length / 2;
            writer.WriteBytes (crypto.Encrypt (Modulus.Copy (0, first)));
            writer.WriteBytes (crypto.Encrypt (Modulus.Copy (first, Modulus.Length - first)));
        }
Example #18
0
 public override void WritePayload(ISerializationContext context, IValueWriter writer)
 {
     writer.WriteBytes (AESKey);
     writer.WriteString (PublicAuthenticationKeyType.GetSimpleName());
     writer.WriteBytes (PublicAuthenticationKey);
 }
 public override void WritePayload(ISerializationContext context, IValueWriter writer)
 {
     writer.WriteBytes(AESKey);
     writer.WriteString(PublicAuthenticationKeyType.GetSimplestName());
     writer.WriteBytes(PublicAuthenticationKey);
 }
Example #20
0
        public void Serialize(IValueWriter writer, RSACrypto crypto)
        {
            if (!writer.WriteBool (this.publicKey != null))
                return;

            writer.WriteBytes (crypto.Encrypt (this.Exponent));

            int first = this.Modulus.Length / 2;
            writer.WriteBytes (crypto.Encrypt (this.Modulus.Copy (0, first)));
            writer.WriteBytes (crypto.Encrypt (this.Modulus.Copy (first, this.Modulus.Length - first)));
        }
Example #21
0
 public override void WritePayload(ISerializationContext context, IValueWriter writer)
 {
     writer.WriteUInt16(OriginalMessageId);
     writer.WriteByte(Count);
     writer.WriteBytes(Payload, this.offset, this.length);
 }
Example #22
0
 public override void WritePayload(ISerializationContext context, IValueWriter writer)
 {
     writer.WriteUInt16 (OriginalMessageId);
     writer.WriteByte (Count);
     writer.WriteBytes (Payload, this.offset, this.length);
 }
Example #23
0
        public override void WritePayload(ISerializationContext context, IValueWriter writer)
        {
            writer.WriteInt32 (SourceId);
            writer.WriteInt32 (Sequence);

            writer.WriteByte ((byte)Data.Length);
            for (int i = 0; i < Data.Length; ++i)
                writer.WriteBytes (Data[i]);
        }