Exemplo n.º 1
0
        public void Deserialize(IValueReader reader, RSACrypto crypto)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            if (crypto == null)
            {
                throw new ArgumentNullException("crypto");
            }

            if (reader.ReadBool())
            {
                byte[] exponent = crypto.Decrypt(reader.ReadBytes());

                byte[] modulus1 = crypto.Decrypt(reader.ReadBytes());
                byte[] modulus2 = crypto.Decrypt(reader.ReadBytes());
                byte[] modulus  = modulus1.Concat(modulus2).ToArray();

                this.exponentOffset = modulus.Length;
                this.publicKey      = new byte[exponent.Length + modulus.Length];
                Buffer.BlockCopy(modulus, 0, this.publicKey, 0, modulus.Length);
                Buffer.BlockCopy(exponent, 0, this.publicKey, exponentOffset, exponent.Length);
            }

            SetupSignature();
        }
 public override void ReadPayload(IValueReader reader)
 {
     base.ReadPayload(reader);
     var internalEndPointAddress = new IPAddress(reader.ReadBytes());
     InternalOwnEndPoint = new IPEndPoint(internalEndPointAddress, reader.ReadInt32());
     var externalEndPointAddress = new IPAddress(reader.ReadBytes());
     ExternalPeerEndPoint = new IPEndPoint(externalEndPointAddress, reader.ReadInt32());
 }
Exemplo n.º 3
0
        public override void ReadPayload(IValueReader reader)
        {
            base.ReadPayload(reader);
            var internalEndPointAddress = new IPAddress(reader.ReadBytes());

            InternalPeerEndPoint = new IPEndPoint(internalEndPointAddress, reader.ReadInt32());
            var externalEndPointAddress = new IPAddress(reader.ReadBytes());

            ExternalPeerEndPoint = new IPEndPoint(externalEndPointAddress, reader.ReadInt32());
        }
Exemplo n.º 4
0
        public override void ReadPayload(IValueReader reader)
        {
            base.ReadPayload(reader);
            var endPointAddress = new IPAddress(reader.ReadBytes());

            RegisteredEndPoint = new IPEndPoint(endPointAddress, reader.ReadInt32());
        }
Exemplo n.º 5
0
        public override void ReadPayload(ISerializationContext context, IValueReader reader)
        {
            this.TargetType = (TargetType)reader.ReadByte();

            ushort numTargets = reader.ReadUInt16();

            int[] targets = new int[numTargets];
            for (int i = 0; i < targets.Length; ++i)
            {
                targets[i] = reader.ReadInt32();
            }

            TargetIds = targets;

            Sequence = reader.ReadInt32();
            SourceId = reader.ReadInt32();

            byte frames = reader.ReadByte();

            Data = new byte[frames][];

            for (int i = 0; i < frames; ++i)
            {
                Data[i] = reader.ReadBytes();
            }
        }
Exemplo n.º 6
0
 public RSAParameters Deserialize(ISerializationContext context, IValueReader reader)
 {
     return(new RSAParameters {
         D = reader.ReadBytes(),
         DP = reader.ReadBytes(),
         DQ = reader.ReadBytes(),
         Exponent = reader.ReadBytes(),
         InverseQ = reader.ReadBytes(),
         Modulus = reader.ReadBytes(),
         P = reader.ReadBytes(),
         Q = reader.ReadBytes()
     });
 }
Exemplo n.º 7
0
        public override void ReadPayload(ISerializationContext context, IValueReader reader)
        {
            SourceId = reader.ReadInt32();
            Sequence = reader.ReadInt32();

            byte frames = reader.ReadByte();

            Data = new byte[frames][];

            for (int i = 0; i < frames; ++i)
            {
                Data[i] = reader.ReadBytes();
            }
        }
Exemplo n.º 8
0
        public void Deserialize(ISerializationContext context, IValueReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            if (reader.ReadBool())
            {
                this.publicKey      = reader.ReadBytes();
                this.exponentOffset = reader.ReadInt32();
            }

            SetupSignature();
        }
Exemplo n.º 9
0
        private object SerializableDeserializer(IValueReader reader)
        {
            bool isNull = false;

            if (this.type.IsClass)
            {
                isNull = reader.ReadBool();
            }

            if (isNull)
            {
                return(null);
            }

            byte[] data = reader.ReadBytes();
            using (MemoryStream stream = new MemoryStream(data))
                return(new BinaryFormatter().Deserialize(stream, null));
        }
 public override void ReadPayload(ISerializationContext context, IValueReader reader)
 {
     var ms = new MemoryStream(reader.ReadBytes());
     ScreenFrame = new Bitmap(ms);
 }
Exemplo n.º 11
0
        public override void ReadPayload(ISerializationContext context, IValueReader reader)
        {
            this.TargetType = (TargetType)reader.ReadByte();

            ushort numTargets = reader.ReadUInt16();
            int[] targets = new int[numTargets];
            for (int i = 0; i < targets.Length; ++i)
                targets[i] = reader.ReadInt32();

            TargetIds = targets;

            Sequence = reader.ReadInt32();
            SourceId = reader.ReadInt32();

            byte frames = reader.ReadByte();
            Data = new byte[frames][];

            for (int i = 0; i < frames; ++i)
                Data[i] = reader.ReadBytes();
        }
 public override void ReadPayload(IValueReader reader)
 {
     base.ReadPayload(reader);
     var endPointAddress = new IPAddress(reader.ReadBytes());
     InternalClientEndPoint = new IPEndPoint(endPointAddress, reader.ReadInt32());
 }
Exemplo n.º 13
0
 public override void ReadPayload(ISerializationContext context, IValueReader reader)
 {
     AESKey = reader.ReadBytes();
     PublicAuthenticationKeyType = Type.GetType (reader.ReadString());
     PublicAuthenticationKey = reader.ReadBytes();
 }
Exemplo n.º 14
0
 public override void ReadPayload(ISerializationContext context, IValueReader reader)
 {
     AESKey = reader.ReadBytes();
     PublicAuthenticationKeyType = Type.GetType(reader.ReadString());
     PublicAuthenticationKey     = reader.ReadBytes();
 }
Exemplo n.º 15
0
        public override void ReadPayload(ISerializationContext context, IValueReader reader)
        {
            SourceId = reader.ReadInt32 ();
            Sequence = reader.ReadInt32();

            byte frames = reader.ReadByte();
            Data = new byte[frames][];

            for (int i = 0; i < frames; ++i)
                Data[i] = reader.ReadBytes();
        }
Exemplo n.º 16
0
        public override void ReadPayload(ISerializationContext context, IValueReader reader)
        {
            var ms = new MemoryStream(reader.ReadBytes());

            ScreenFrame = new Bitmap(ms);
        }
Exemplo n.º 17
0
 public override void ReadPayload(ISerializationContext context, IValueReader reader)
 {
     OriginalMessageId = reader.ReadUInt16();
     Count = reader.ReadByte();
     Payload = reader.ReadBytes();
 }
Exemplo n.º 18
0
 public override void ReadPayload(ISerializationContext context, IValueReader reader)
 {
     OriginalMessageId = reader.ReadUInt16();
     Count             = reader.ReadByte();
     Payload           = reader.ReadBytes();
 }
Exemplo n.º 19
0
        public void Deserialize(IValueReader reader, RSACrypto crypto)
        {
            if (reader == null)
                throw new ArgumentNullException ("reader");
            if (crypto == null)
                throw new ArgumentNullException ("crypto");

            if (reader.ReadBool())
            {
                byte[] exponent = crypto.Decrypt (reader.ReadBytes());

                byte[] modulus1 = crypto.Decrypt (reader.ReadBytes());
                byte[] modulus2 = crypto.Decrypt (reader.ReadBytes());
                byte[] modulus = modulus1.Concat (modulus2).ToArray();

                this.exponentOffset = modulus.Length;
                this.publicKey = new byte[exponent.Length + modulus.Length];
                Buffer.BlockCopy (modulus, 0, this.publicKey, 0, modulus.Length);
                Buffer.BlockCopy (exponent, 0, this.publicKey, exponentOffset, exponent.Length);
            }

            SetupSignature();
        }
Exemplo n.º 20
0
        public void Deserialize(ISerializationContext context, IValueReader reader)
        {
            if (reader == null)
                throw new ArgumentNullException ("reader");

            if (reader.ReadBool())
            {
                this.publicKey = reader.ReadBytes();
                this.exponentOffset = reader.ReadInt32();
            }

            SetupSignature();
        }