// DSACryptoServiceProvider, as an AsymmetricAlgorithm, has to implement IDisposable. /// <include file='doc\DSACryptoServiceProvider.uex' path='docs/doc[@for="DSACryptoServiceProvider.Dispose"]/*' /> protected override void Dispose(bool disposing) { if (_KeyHandleProtector != null && !_KeyHandleProtector.IsClosed) { _KeyHandleProtector.Close(); } if (_CSPHandleProtector != null && !_CSPHandleProtector.IsClosed) { _CSPHandleProtector.Close(); } }
/// <include file='doc\cryptoapiTransform.uex' path='docs/doc[@for="CryptoAPITransform.Dispose"]/*' /> void Dispose(bool disposing) { if (disposing) { // we always want to clear out these items // clear out _rgbKey if (_rgbKey != null) { Array.Clear(_rgbKey, 0, _rgbKey.Length); _rgbKey = null; } if (IVValue != null) { Array.Clear(IVValue, 0, IVValue.Length); IVValue = null; } if (_depadBuffer != null) { Array.Clear(_depadBuffer, 0, _depadBuffer.Length); _depadBuffer = null; } } if (_KeyHandleProtector != null && !_KeyHandleProtector.IsClosed) { _KeyHandleProtector.Close(); } // Delete the temporary key container if (!_runningWin2KOrLaterCrypto) { _DeleteKeyContainer(_parameters, _hCSP); } if (_hCSP != IntPtr.Zero) { _FreeCSP(_hCSP); _hCSP = IntPtr.Zero; } }