/// <summary> /// Constructs a new SecureBaseClient /// </summary> /// <param name="client">An existing connected TcpClient</param> /// <param name="rsa">The RSA object used to initialize this client</param> public SecureClient(TcpClient client, W.Encryption.RSA rsa) : base(client) { //no need to compress because encrypted is barely compressable //Socket.UseCompression = true; _rsa = rsa; OnConnected(client.Client.RemoteEndPoint.As <IPEndPoint>()); }
private void CreateRSA() { if (_rsa == null) { _rsa = new Encryption.RSA(2048); } }
/// <summary> /// Constructs a new SecureStringClient /// </summary> public SecureStringClient() : base() { _rsa = new W.Encryption.RSA(); Connected += (socket, address) => { SendPublicKey(); //immediately send the public key Log.v("Client Sent Public Key"); }; }
public SecureClientSlim() : base() { base.Connected += (client, remoteEndPoint) => { _rsa = new Encryption.RSA(); SecureTheConnection().Wait(); }; base.Disconnected += (client, remoteEndPoint, exception) => { _remotePublicKey = null; }; }
public void EncryptAndDecrypt() { const string value = "Jordan Duerksen"; using (var rsa = new W.Encryption.RSA(2048)) { var encrypted = rsa.Encrypt(value, rsa.PublicKey); Console.WriteLine("Encrypted = {0}", encrypted); var decrypted = rsa.Decrypt(encrypted, rsa.PrivateKey); Assert.IsTrue(decrypted == value); } }
/// <summary> /// Constructs a new SecureStringClient /// </summary> public SecureStringClient() : base() { _rsa = new W.Encryption.RSA(); Connected += (client, address) => { IsSecuredEvent.Reset(); SendPublicKey(); //immediately send the public key Log.v("Client Sent Public Key"); }; Disconnected += (socket, remoteEndPoint, e) => { IsSecuredEvent.Reset(); _remotePublicKey = null; }; }
/// <summary> /// Constructs a new SecureBaseClient /// </summary> public SecureClient() : base() { //no need to compress because encrypted is barely compressable //Socket.UseCompression = true; _rsa = new W.Encryption.RSA(); }
/// <summary> /// Constructs a new SecureStringClient /// </summary> /// <param name="client">An existing connected TcpClient</param> /// <param name="rsa">An existing instance of RSA to be used for encryption</param> public SecureStringClient(TcpClient client, W.Encryption.RSA rsa) : base(client) { _rsa = rsa; SendPublicKey(); //immediately send the public key Log.v("Server Sent Public Key"); }
/// <summary> /// Constructs a new SecureStringClient (used by SecureServer) /// </summary> /// <param name="client">An existing connected TcpClient</param> /// <param name="rsa">An existing instance of RSA to be used for encryption</param> public SecureClient(TcpClient client, W.Encryption.RSA rsa) : base(client) { _rsa = rsa; SendPublicKey(); //immediately send the public key //can't log messages yet - Log.v("Server Sent Public Key"); }
/// <summary> /// Constructs a new SecureStringClient /// </summary> public SecureClient() : base() { _rsa = new W.Encryption.RSA(); }
public SecureClientSlim(TcpClient tcpClient, W.Encryption.RSA rsa) : base(tcpClient) { _rsa = rsa; //this won't work because the base class constructor will call OnConnected before this is assigned SecureTheConnection().Wait(); }
/// <summary> /// Constructs a new GenericClient /// </summary> /// <param name="client">An existing connected TcpClient</param> /// <param name="rsa">An existing instance of RSA to be used for encryption</param> public GenericClient(System.Net.Sockets.TcpClient client, W.Encryption.RSA rsa) : base(client, rsa) { HookMessageReceived(); }