From d6b30dcbb169c4eb14f093613010ed16eab5ba7f Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Sun, 6 Nov 2022 21:26:51 +0700 Subject: CryptoApiRandomGenerator implements IDisposable --- crypto/src/crypto/prng/CryptoApiRandomGenerator.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'crypto/src') 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 /// 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 } } -- cgit 1.4.1