public EncryptorAsyncResult(PeerId id, AsyncCallback callback, object state) : base(callback, state) { Id = id; Decryptor = new PlainTextEncryption(); Encryptor = new PlainTextEncryption(); }
/// <summary> /// Sets CryptoSelect and initializes the stream encryptor and decryptor based on the selected method. /// </summary> /// <param name="remoteCryptoBytes"> /// The cryptographic methods supported/wanted by the remote client in CryptoProvide /// format. The highest order one available will be selected /// </param> /// <param name="replace">if set to <c>true</c> [replace].</param> /// <returns></returns> protected virtual int SelectCrypto(byte[] remoteCryptoBytes, bool replace) { CryptoSelect = new byte[remoteCryptoBytes.Length]; // '2' corresponds to RC4Full if ((remoteCryptoBytes[3] & 2) == 2 && Toolbox.HasEncryption(_allowedEncryption, EncryptionTypes.RC4Full)) { CryptoSelect[3] |= 2; if (replace) { Encryptor = _encryptor; Decryptor = _decryptor; } return(2); } // '1' corresponds to RC4Header if ((remoteCryptoBytes[3] & 1) == 1 && Toolbox.HasEncryption(_allowedEncryption, EncryptionTypes.RC4Header)) { CryptoSelect[3] |= 1; if (replace) { Encryptor = new RC4Header(); Decryptor = new RC4Header(); } return(1); } throw new EncryptionException("No valid encryption method detected"); }
public EncryptorAsyncResult(PeerId id, AsyncCallback callback, object state) : base(callback, state) { Id = id; Decryptor = new PlainTextEncryption(); Encryptor = new PlainTextEncryption(); }
/// <summary> /// Sets CryptoSelect and initializes the stream encryptor and decryptor based on the selected method. /// </summary> /// <param name="remoteCryptoBytes"> /// The cryptographic methods supported/wanted by the remote client in CryptoProvide /// format. The highest order one available will be selected /// </param> /// <param name="replace">if set to <c>true</c> [replace].</param> /// <returns></returns> protected virtual int SelectCrypto(byte[] remoteCryptoBytes, bool replace) { CryptoSelect = new byte[remoteCryptoBytes.Length]; // '2' corresponds to RC4Full if ((remoteCryptoBytes[3] & 2) == 2 && Toolbox.HasEncryption(_allowedEncryption, EncryptionTypes.RC4Full)) { CryptoSelect[3] |= 2; if (replace) { Encryptor = _encryptor; Decryptor = _decryptor; } return 2; } // '1' corresponds to RC4Header if ((remoteCryptoBytes[3] & 1) == 1 && Toolbox.HasEncryption(_allowedEncryption, EncryptionTypes.RC4Header)) { CryptoSelect[3] |= 1; if (replace) { Encryptor = new RC4Header(); Decryptor = new RC4Header(); } return 1; } throw new EncryptionException("No valid encryption method detected"); }