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); }
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); }
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); }
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); }
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); }
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); } }
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; }
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; }