示例#1
0
        internal byte[] EncodeHandshakeRecord(HandshakeMessage message)
        {
            var buffer = message.EncodeMessage();

            int fragmentSize = MAX_FRAGMENT_SIZE;

                        #if INSTRUMENTATION
            if (message.Type == HandshakeType.ServerHello && HasInstrument(HandshakeInstrumentType.FragmentServerHello))
            {
                fragmentSize = 30;
            }
            else if (HasInstrument(HandshakeInstrumentType.FragmentHandshakeMessages))
            {
                fragmentSize = 512;
            }
                        #endif

            var encoded = EncodeRecord_internal(ContentType.Handshake, buffer, fragmentSize);
            if (message.Type != HandshakeType.HelloRequest)
            {
                HandshakeParameters.HandshakeMessages.Add(message, buffer);
            }
                        #if DEBUG_FULL
            if (EnableDebugging)
            {
                DebugHelper.WriteLine("EncodeHandshakeRecord: {0}", message.Type);
                DebugHelper.WriteLine("Encoded", encoded);
            }
                        #endif
            return(encoded);
        }
        public IAsyncResult BeginSendRecord(HandshakeType handshakeType, AsyncCallback callback, object state)
        {
            HandshakeMessage message = this.GetMessage(handshakeType);

            message.Process();
            RecordProtocol.SendRecordAsyncResult sendRecordAsyncResult = new RecordProtocol.SendRecordAsyncResult(callback, state, message);
            this.BeginSendRecord(message.ContentType, message.EncodeMessage(), new AsyncCallback(this.InternalSendRecordCallback), sendRecordAsyncResult);
            return(sendRecordAsyncResult);
        }
示例#3
0
        public IAsyncResult BeginSendRecord(HandshakeType handshakeType, AsyncCallback callback, object state)
        {
            HandshakeMessage message = GetMessage(handshakeType);

            message.Process();
            SendRecordAsyncResult sendRecordAsyncResult = new SendRecordAsyncResult(callback, state, message);

            BeginSendRecord(message.ContentType, message.EncodeMessage(), InternalSendRecordCallback, sendRecordAsyncResult);
            return(sendRecordAsyncResult);
        }
示例#4
0
        public IAsyncResult BeginSendRecord(HandshakeType handshakeType, AsyncCallback callback, object state)
        {
            HandshakeMessage msg = this.GetMessage(handshakeType);

            msg.Process();

            DebugHelper.WriteLine(">>>> Write handshake record ({0}|{1})", context.Protocol, msg.ContentType);

            SendRecordAsyncResult internalResult = new SendRecordAsyncResult(callback, state, msg);

            this.BeginSendRecord(msg.ContentType, msg.EncodeMessage(), new AsyncCallback(InternalSendRecordCallback), internalResult);

            return(internalResult);
        }
示例#5
0
        public byte[] EncodeHandshakeRecord(HandshakeType handshakeType)
        {
            HandshakeMessage msg = this.GetMessage(handshakeType);

            msg.Process();

            var bytes = this.EncodeRecord(msg.ContentType, msg.EncodeMessage());

            msg.Update();

            msg.Reset();

            return(bytes);
        }
示例#6
0
        internal byte[] EncodeHandshakeRecord(HandshakeMessage message)
        {
            var buffer = message.EncodeMessage();

            var encoded = EncodeRecord(ContentType.Handshake, buffer);

            if (message.Type != HandshakeType.HelloRequest)
            {
                HandshakeParameters.HandshakeMessages.Add(message, buffer);
            }
                        #if DEBUG_FULL
            if (EnableDebugging)
            {
                DebugHelper.WriteLine("EncodeHandshakeRecord: {0}", message.Type);
                DebugHelper.WriteLine("Encoded", encoded);
            }
                        #endif
            return(encoded);
        }
示例#7
0
        protected void WriteOperations(MemoryStream ms, params HandshakeMessage [] msgs)
        {
            List <byte []> rawbufs = new List <byte []> ();
            int            total   = 0;

            for (int i = 0; i < msgs.Length; i++)
            {
                HandshakeMessage msg = msgs [i];
                msg.Process();
                rawbufs.Add(msg.EncodeMessage());
                total += rawbufs [i].Length;
                msg.Update();
            }
            // FIXME: split packets when the size exceeded 0x10000 (or so)
            ms.WriteByte((byte)(total / 0x100));
            ms.WriteByte((byte)(total % 0x100));
            foreach (byte [] bytes in rawbufs)
            {
                ms.Write(bytes, 0, bytes.Length);
            }
        }
示例#8
0
		internal byte[] EncodeHandshakeRecord (HandshakeMessage message)
		{
			var buffer = message.EncodeMessage ();

			var encoded = EncodeRecord (ContentType.Handshake, buffer);
			if (message.Type != HandshakeType.HelloRequest)
				HandshakeParameters.HandshakeMessages.Add (message, buffer);
			#if DEBUG_FULL
			if (EnableDebugging) {
				DebugHelper.WriteLine ("EncodeHandshakeRecord: {0}", message.Type);
				DebugHelper.WriteLine ("Encoded", encoded);
			}
			#endif
			return encoded;
		}
示例#9
0
		internal byte[] EncodeHandshakeRecord (HandshakeMessage message)
		{
			var buffer = message.EncodeMessage ();

			int fragmentSize = MAX_FRAGMENT_SIZE;
			#if INSTRUMENTATION
			if (message.Type == HandshakeType.ServerHello && HasInstrument (HandshakeInstrumentType.FragmentServerHello))
				fragmentSize = 30;
			else if (HasInstrument (HandshakeInstrumentType.FragmentHandshakeMessages))
				fragmentSize = 512;
			#endif

			var encoded = EncodeRecord_internal (ContentType.Handshake, buffer, fragmentSize);
			if (message.Type != HandshakeType.HelloRequest)
				HandshakeParameters.HandshakeMessages.Add (message, buffer);
			#if DEBUG_FULL
			if (EnableDebugging) {
				DebugHelper.WriteLine ("EncodeHandshakeRecord: {0}", message.Type);
				DebugHelper.WriteLine ("Encoded", encoded);
			}
			#endif
			return encoded;
		}