diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-11-06 21:26:51 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-11-06 21:26:51 +0700 |
commit | d6b30dcbb169c4eb14f093613010ed16eab5ba7f (patch) | |
tree | 9ae495d20a3e8262869eaa9c05ec99c51f6c1d6b | |
parent | Add some dotnet ECDsa interop methods (diff) | |
download | BouncyCastle.NET-ed25519-d6b30dcbb169c4eb14f093613010ed16eab5ba7f.tar.xz |
CryptoApiRandomGenerator implements IDisposable
-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 } } |