internal SecureTcpConnection(RSAPair rsaPair, TcpClient tcpClient) : base(tcpClient, skipInitializationProcess: true) { //Setup the RSAConnectionHelper object. RSAConnection = new RSAConnection(this, rsaPair); PacketConverter = base.PacketConverter; base.PacketConverter = RSAConnection; //Since we did skip the initialization,... DO IT! Init(); }
/// <summary> /// Initializes a new instance of the <see cref="RSAConnection"/> class. /// </summary> /// <param name="connection">The base <see cref="Network.Connection"/> for sending and receiving data.</param> /// <param name="rsaPair">The local RSA key-pair for this <see cref="RSAConnection"/>.</param> public RSAConnection(Connection connection, RSAPair rsaPair) { Connection = connection; RSAPair = rsaPair; DecryptionProvider = new RSACryptoServiceProvider(RSAPair.KeySize); Extensions.RSACryptoServiceProviderExtensions.ImportParametersFromXmlString(DecryptionProvider, RSAPair.Private); //Setup RSA related packets. ExchangePublicKeys(); }
/// <summary> /// Initializes a new instance of the <see cref="SecureUdpConnection"/> class. /// </summary> /// <param name="udpClient">The <see cref="UdpClient"/> to use for sending and receiving data.</param> /// <param name="remoteEndPoint">The remote end point to connect to.</param> /// <param name="rsaPair">The local RSA key-pair.</param> /// <param name="writeLock">Whether the connection has a write lock.</param> internal SecureUdpConnection(UdpClient udpClient, IPEndPoint remoteEndPoint, RSAPair rsaPair, bool writeLock = false) : base(udpClient, remoteEndPoint, writeLock, skipInitializationProcess: true) { //Setup the RSAConnectionHelper object. RSAConnection = new RSAConnection(this, rsaPair); PacketConverter = base.PacketConverter; base.PacketConverter = RSAConnection; //Since we did skip the initialization,... DO IT! Init(); }
/// <summary> /// Initializes a new instance of the <see cref="RSAConnection"/> class. /// </summary> /// <param name="connection">The base <see cref="Network.Connection"/> for sending and receiving data.</param> /// <param name="rsaPair">The local RSA key-pair for this <see cref="RSAConnection"/>.</param> public RSAConnection(Connection connection, RSAPair rsaPair) { Connection = connection; RSAPair = rsaPair; DecryptionProvider = new RSACryptoServiceProvider(RSAPair.KeySize); Extensions.RSACryptoServiceProviderExtensions.ImportParametersFromXmlString(DecryptionProvider, RSAPair.Private); //Are we running on WinXP or higher? OperatingSystem operatingSystem = Environment.OSVersion; XPOrHigher = (operatingSystem.Platform == PlatformID.Win32NT) && ((operatingSystem.Version.Major > 5) || ((operatingSystem.Version.Major == 5) && (operatingSystem.Version.Minor >= 1))); //Setup RSA related packets. ExchangePublicKeys(); }
/// <summary> /// Initializes a new instance of the <see cref="SecureClientConnectionContainer"/> class. /// </summary> /// <param name="ipAddress">The remote ip address.</param> /// <param name="port">The remote port.</param> /// <param name="rsaPair">The local RSA key-pair.</param> internal SecureClientConnectionContainer(string ipAddress, int port, RSAPair rsaPair) : base(ipAddress, port) => RSAPair = rsaPair;
/// <summary> /// Initializes a new instance of the <see cref="SecureServerConnectionContainer" /> class. /// </summary> /// <param name="port">The local port.</param> /// <param name="rsaPair">The local RSA key-pair.</param> /// <param name="start">Whether to automatically starts to listen to tcp/udp/bluetooth clients.</param> internal SecureServerConnectionContainer(int port, RSAPair rsaPair, bool start = true) : this(System.Net.IPAddress.Any.ToString(), port, rsaPair, start) { }
/// <summary> /// Initializes a new instance of the <see cref="SecureServerConnectionContainer" /> class. /// </summary> /// <param name="ipAddress">The local ip address.</param> /// <param name="port">The local port.</param> /// <param name="rsaPair">The local RSA key-pair.</param> /// <param name="start">Whether to automatically starts to listen to tcp/udp/bluetooth clients.</param> internal SecureServerConnectionContainer(string ipAddress, int port, RSAPair rsaPair, bool start = true) : base(ipAddress, port, start) { RSAPair = rsaPair; }
/// <summary> /// Initializes a new instance of the <see cref="ClientConnectionContainer"/> class. /// </summary> /// <param name="tcpConnection">The TCP connection to use.</param> /// <param name="udpConnection">The UDP connection to use.</param> /// <param name="rsaPair">The local RSA key-pair.</param> internal SecureClientConnectionContainer(TcpConnection tcpConnection, UdpConnection udpConnection, RSAPair rsaPair) : base(tcpConnection.IPRemoteEndPoint.Address.ToString(), tcpConnection.IPRemoteEndPoint.Port) { RSAPair = rsaPair; }