private void TearDown() { if (_clientSocket != null) { if (_clientSocket.IsConnected) { _clientSocket.Close(); } _clientSocket.Dispose(); } if (_evtSendWait != null) { _evtSendWait.Dispose(); } if (_fileSymProcessor != null) { _fileSymProcessor.Dispose(); } if (_rcvBuffer != null) { _rcvBuffer.Dispose(); } if (_sndBuffer != null) { _sndBuffer.Dispose(); } if (_filePath != null) { _filePath = null; } }
private void Dispose(bool Disposing) { if (!m_isDisposed && Disposing) { try { if (m_disposeEngine) { if (m_cipherEngine != null) { m_cipherEngine.Dispose(); m_cipherEngine = null; } if (m_streamCipher != null) { m_streamCipher.Dispose(); m_streamCipher = null; } } } finally { m_isDisposed = true; } } }
private void Dispose(bool Disposing) { if (!_isDisposed && Disposing) { try { if (_cipherType != null && _disposeEngine) { _cipherType.Dispose(); _cipherType = null; } if (_msgCode != null) { Array.Clear(_msgCode, 0, _msgCode.Length); _msgCode = null; } if (_tmpZeroes != null) { Array.Clear(_tmpZeroes, 0, _tmpZeroes.Length); _tmpZeroes = null; } if (_wrkBuffer != null) { Array.Clear(_wrkBuffer, 0, _wrkBuffer.Length); _wrkBuffer = null; } if (_L != null) { Array.Clear(_L, 0, _L.Length); _L = null; } if (_LU != null) { Array.Clear(_LU, 0, _LU.Length); _LU = null; } if (_LU2 != null) { Array.Clear(_LU2, 0, _LU2.Length); _LU2 = null; } } finally { _isDisposed = true; } } }
void StreamModesTest(ICipherMode Cipher, IPadding Padding) { if (Cipher.Engine.LegalKeySizes[0] > 32) { AllocateRandom(ref _key, 192); } else { AllocateRandom(ref _key, 32); } AllocateRandom(ref _iv, 16); // we are testing padding modes, make sure input size is random, but -not- block aligned.. AllocateRandom(ref _plnText, 0, Cipher.BlockSize); KeyParams kp = new KeyParams(_key, _iv); MemoryStream mIn = new MemoryStream(_plnText); MemoryStream mOut = new MemoryStream(); MemoryStream mRes = new MemoryStream(); CipherStream cs = new CipherStream(Cipher, Padding); cs.Initialize(true, kp); cs.Write(mIn, mOut); cs.Initialize(false, kp); mOut.Seek(0, SeekOrigin.Begin); cs.Write(mOut, mRes); int pos = (int)mRes.Position; byte[] res = new byte[_plnText.Length]; Buffer.BlockCopy(mRes.ToArray(), 0, res, 0, pos); if (!Evaluate.AreEqual(res, _plnText)) { throw new Exception("CipherStreamTest: Encrypted arrays are not equal!"); } Cipher.Dispose(); }
private void Dispose(bool Disposing) { if (!m_isDisposed && Disposing) { try { if (m_cipherMode != null && m_disposeEngine) { m_cipherMode.Dispose(); m_cipherMode = null; } if (m_msgCode != null) { Array.Clear(m_msgCode, 0, m_msgCode.Length); m_msgCode = null; } if (m_wrkBuffer != null) { Array.Clear(m_wrkBuffer, 0, m_wrkBuffer.Length); m_wrkBuffer = null; } if (m_K1 != null) { Array.Clear(m_K1, 0, m_K1.Length); m_K1 = null; } if (m_K2 != null) { Array.Clear(m_K2, 0, m_K2.Length); m_K2 = null; } } finally { m_isDisposed = true; } } }