Example #1
0
        public SecureChannelPacket(Stream s)
        {
            _code = (SecureChannelCode)s.ReadByte();

            if (_code == SecureChannelCode.None)
            {
                byte[] buffer = new byte[2];
                OffsetStream.StreamRead(s, buffer, 0, 2);
                ushort dataLen = BitConverter.ToUInt16(buffer, 0);

                if (dataLen > 0)
                {
                    _data = new byte[dataLen];
                    OffsetStream.StreamRead(s, _data, 0, _data.Length);
                }
                else
                {
                    _data = new byte[] { };
                }
            }
            else
            {
                throw new SecureChannelException(SecureChannelCode.RemoteError, null, null, "Remote client sent an error response code: " + _code.ToString());
            }
        }
Example #2
0
        public SecureChannelHandshakePacket(Stream s)
        {
            int code = s.ReadByte();

            if (code == -1)
            {
                throw new EndOfStreamException();
            }

            _code = (SecureChannelCode)code;
            if (_code != SecureChannelCode.None)
            {
                throw new SecureChannelException(SecureChannelCode.RemoteError, null, null, "Remote client sent an error response code: " + _code.ToString());
            }
        }