diff options
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/src/crypto/prng/CryptoApiRandomGenerator.cs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/crypto/src/crypto/prng/CryptoApiRandomGenerator.cs b/crypto/src/crypto/prng/CryptoApiRandomGenerator.cs index 44a9c261f..dcd3baa1c 100644 --- a/crypto/src/crypto/prng/CryptoApiRandomGenerator.cs +++ b/crypto/src/crypto/prng/CryptoApiRandomGenerator.cs @@ -7,7 +7,7 @@ namespace Org.BouncyCastle.Crypto.Prng /// Uses RandomNumberGenerator.Create() to get randomness generator /// </summary> public sealed class CryptoApiRandomGenerator - : IRandomGenerator + : IRandomGenerator, IDisposable { private readonly RandomNumberGenerator m_randomNumberGenerator; @@ -18,7 +18,8 @@ namespace Org.BouncyCastle.Crypto.Prng public CryptoApiRandomGenerator(RandomNumberGenerator randomNumberGenerator) { - m_randomNumberGenerator = randomNumberGenerator; + m_randomNumberGenerator = randomNumberGenerator ?? + throw new ArgumentNullException(nameof(randomNumberGenerator)); } #region IRandomGenerator Members @@ -76,5 +77,14 @@ namespace Org.BouncyCastle.Crypto.Prng #endif #endregion + + #region IDisposable Members + + public void Dispose() + { + m_randomNumberGenerator.Dispose(); + } + + #endregion } } |