Ejemplo n.º 1
0
        private void Dispose(bool Disposing)
        {
            if (!_isDisposed && Disposing)
            {
                try
                {
                    if (_rngGenerator != null)
                    {
                        _rngGenerator.Dispose();
                        _rngGenerator = null;
                    }
                    if (_seedGenerator != null)
                    {
                        _seedGenerator.Dispose();
                        _seedGenerator = null;
                    }
                    if (_byteBuffer != null)
                    {
                        Array.Clear(_byteBuffer, 0, _byteBuffer.Length);
                        _byteBuffer = null;
                    }
                    if (_stateSeed != null)
                    {
                        Array.Clear(_stateSeed, 0, _stateSeed.Length);
                        _stateSeed = null;
                    }
                }
                catch { }

                _isDisposed = true;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Reset the RNGCryptoServiceProvider instance.
        /// </summary>
        public void Reset()
        {
            if (_seedGenerator != null)
            {
                _seedGenerator.Dispose();
                _seedGenerator = null;
            }
            if (_rngGenerator != null)
            {
                _rngGenerator.Dispose();
                _rngGenerator = null;
            }

            _seedGenerator = GetSeedGenerator(_seedType);
            _rngGenerator = new SP20Drbg(_dfnRounds);

            if (_seedGenerator != null)
                _rngGenerator.Initialize(_seedGenerator.GetSeed(_keySize));
            else
                _rngGenerator.Initialize(_stateSeed);

            _rngGenerator.Generate(_byteBuffer);
            _bufferIndex = 0;
        }