public CompatibilityLayer(SocketController controller, SecurityOptions options) { m_Buffer = new byte[0]; m_MinVersion = GetMinProtocol(options.Protocol); m_MaxVersion = GetMaxProtocol(options.Protocol); if (m_MinVersion.GetVersionInt() == 30) // SSL 3.0 { if (options.Entity == ConnectionEnd.Client) { m_MinLayer = new RecordLayer(controller, new Ssl3ClientHandshakeLayer(null, options)); } else { m_MinLayer = new RecordLayer(controller, new Ssl3ServerHandshakeLayer(null, options)); } } else // TLS 1.0 { if (options.Entity == ConnectionEnd.Client) { m_MinLayer = new RecordLayer(controller, new Tls1ClientHandshakeLayer(null, options)); } else { m_MinLayer = new RecordLayer(controller, new Tls1ServerHandshakeLayer(null, options)); } } m_MinLayer.HandshakeLayer.RecordLayer = m_MinLayer; m_Options = options; }
public HandshakeLayer(RecordLayer recordLayer, SecurityOptions options) { connectionEnd = options.Entity; m_Disposed = false; m_Options = options; m_IsNegotiating = true; m_RNG = new RNGCryptoServiceProvider(); m_RecordLayer = recordLayer; m_State = HandshakeType.Nothing; m_IncompleteMessage = new byte[0]; m_LocalMD5Hash = new MD5CryptoServiceProvider(); m_LocalSHA1Hash = new SHA1CryptoServiceProvider(); m_RemoteMD5Hash = new MD5CryptoServiceProvider(); m_RemoteSHA1Hash = new SHA1CryptoServiceProvider(); m_CertSignHash = new MD5SHA1CryptoServiceProvider(); m_CertSignHash.Protocol = this.GetProtocol(); if (options.Entity == ConnectionEnd.Server && ((int)options.Flags & (int)SecurityFlags.MutualAuthentication) != 0) { m_MutualAuthentication = true; } else { m_MutualAuthentication = false; } }
public CompatibilityLayer(SocketController controller, SecurityOptions options) { m_Buffer = new byte[0]; m_MinVersion = GetMinProtocol(options.Protocol); m_MaxVersion = GetMaxProtocol(options.Protocol); this.handshakeMonitor = new SslTlsHandshakeMonitor(); HandshakeLayer layer = null; if (m_MinVersion.GetVersionInt() == 30) { // SSL 3.0 if (options.Entity == ConnectionEnd.Client) { layer = new Ssl3ClientHandshakeLayer(null, options); m_MinLayer = new RecordLayer(controller, layer as ClientHandshakeLayer); this.handshakeMonitor.Attach(controller.Parent, layer as ClientHandshakeLayer); } else { layer = new Ssl3ServerHandshakeLayer(null, options); m_MinLayer = new RecordLayer(controller, layer as ServerHandshakeLayer); this.handshakeMonitor.Attach(controller.Parent, layer as ServerHandshakeLayer); } } else { // TLS 1.0 if (options.Entity == ConnectionEnd.Client) { layer = new Tls1ClientHandshakeLayer(null, options); m_MinLayer = new RecordLayer(controller, layer as ClientHandshakeLayer); this.handshakeMonitor.Attach(controller.Parent, layer as ClientHandshakeLayer); } else { layer = new Tls1ServerHandshakeLayer(null, options); m_MinLayer = new RecordLayer(controller, layer as ServerHandshakeLayer); this.handshakeMonitor.Attach(controller.Parent, layer as ServerHandshakeLayer); } } m_MinLayer.HandshakeLayer.RecordLayer = m_MinLayer; m_Options = options; }
public CompatibilityLayer(SocketController controller, SecurityOptions options) { m_Buffer = new byte[0]; m_MinVersion = GetMinProtocol(options.Protocol); m_MaxVersion = GetMaxProtocol(options.Protocol); if (m_MinVersion.GetVersionInt() == 30) { // SSL 3.0 if (options.Entity == ConnectionEnd.Client) m_MinLayer = new RecordLayer(controller, new Ssl3ClientHandshakeLayer(null, options)); else m_MinLayer = new RecordLayer(controller, new Ssl3ServerHandshakeLayer(null, options)); } else { // TLS 1.0 if (options.Entity == ConnectionEnd.Client) m_MinLayer = new RecordLayer(controller, new Tls1ClientHandshakeLayer(null, options)); else m_MinLayer = new RecordLayer(controller, new Tls1ServerHandshakeLayer(null, options)); } m_MinLayer.HandshakeLayer.RecordLayer = m_MinLayer; m_Options = options; }
public HandshakeLayer(RecordLayer recordLayer, SecurityOptions options) { m_Disposed = false; m_Options = options; m_IsNegotiating = true; m_RNG = new RNGCryptoServiceProvider(); m_RecordLayer = recordLayer; m_State = HandshakeType.Nothing; m_IncompleteMessage = new byte[0]; m_LocalMD5Hash = new MD5CryptoServiceProvider(); m_LocalSHA1Hash = new SHA1CryptoServiceProvider(); m_RemoteMD5Hash = new MD5CryptoServiceProvider(); m_RemoteSHA1Hash = new SHA1CryptoServiceProvider(); m_CertSignHash = new MD5SHA1CryptoServiceProvider(); m_CertSignHash.Protocol = this.GetProtocol(); if (options.Entity == ConnectionEnd.Server && ((int)options.Flags & (int)SecurityFlags.MutualAuthentication) != 0) m_MutualAuthentication = true; else m_MutualAuthentication = false; }
public Ssl3ServerHandshakeLayer(RecordLayer recordLayer, SecurityOptions options) : base(recordLayer, options) { }
public ClientHandshakeLayer(RecordLayer recordLayer, SecurityOptions options) : base(recordLayer, options) { this.clientHelloExts = options.ExtensionList; }
public Tls1ClientHandshakeLayer(RecordLayer recordLayer, SecurityOptions options) : base(recordLayer, options) { }
public HandshakeLayer(HandshakeLayer handshakeLayer) { m_Disposed = false; m_RecordLayer = handshakeLayer.m_RecordLayer; m_Options = handshakeLayer.m_Options; m_IsNegotiating = handshakeLayer.m_IsNegotiating; m_RNG = handshakeLayer.m_RNG; m_State = handshakeLayer.m_State; m_IncompleteMessage = handshakeLayer.m_IncompleteMessage; m_LocalMD5Hash = handshakeLayer.m_LocalMD5Hash; m_LocalSHA1Hash = handshakeLayer.m_LocalSHA1Hash; m_RemoteMD5Hash = handshakeLayer.m_RemoteMD5Hash; m_RemoteSHA1Hash = handshakeLayer.m_RemoteSHA1Hash; m_CertSignHash = handshakeLayer.m_CertSignHash; m_CertSignHash.Protocol = this.GetProtocol(); m_MutualAuthentication = handshakeLayer.m_MutualAuthentication; m_ClientTime = handshakeLayer.m_ClientTime; m_ClientRandom = handshakeLayer.m_ClientRandom; handshakeLayer.Dispose(false); }
public CompatibilityResult(RecordLayer rl, SslRecordStatus status) { this.RecordLayer = rl; this.Status = status; }
public ServerHandshakeLayer(RecordLayer recordLayer, SecurityOptions options) : base(recordLayer, options) { this.serverHelloExts = options.ExtensionList; }
protected void OnReceive(IAsyncResult ar) { lock (this) { // synchronize try { int size = m_Socket.EndReceive(ar); if (size == 0) { CloseConnection(null); // connection has been shut down } else { SslRecordStatus status; if (m_RecordLayer == null) { CompatibilityResult ret = m_Compatibility.ProcessHello(m_ReceiveBuffer, 0, size); m_RecordLayer = ret.RecordLayer; status = ret.Status; if (m_RecordLayer != null) m_Compatibility = null; } else { status = m_RecordLayer.ProcessBytes(m_ReceiveBuffer, 0, size); } if (status.Buffer != null) { if (status.Status == SslStatus.Close) { // shut down the connection after the send m_IsShuttingDown = true; } BeginSend(status.Buffer, 0, status.Buffer.Length, null, DataType.ProtocolData); } else if (status.Status == SslStatus.Close) { // Record Layer instructs us to shut down m_Socket.Shutdown(SocketShutdown.Both); CloseConnection(null); } else if (status.Status == SslStatus.OK) { ResumeSending(); } if (status.Decrypted != null) ProcessDecryptedBytes(status.Decrypted); if (!m_IsDisposed && !m_IsShuttingDown) m_Socket.BeginReceive(m_ReceiveBuffer, 0, m_ReceiveBufferLength, SocketFlags.None, new AsyncCallback(this.OnReceive), null); } } catch (Exception e) { CloseConnection(e); } } }
public ServerHandshakeLayer(RecordLayer recordLayer, SecurityOptions options) : base(recordLayer, options) { }
public ClientHandshakeLayer(RecordLayer recordLayer, SecurityOptions options) : base(recordLayer, options) { }