diff options
Diffstat (limited to 'crypto/src/cms')
-rw-r--r-- | crypto/src/cms/CMSAuthenticatedDataGenerator.cs | 9 | ||||
-rw-r--r-- | crypto/src/cms/CMSAuthenticatedDataStreamGenerator.cs | 2 | ||||
-rw-r--r-- | crypto/src/cms/CMSCompressedData.cs | 2 | ||||
-rw-r--r-- | crypto/src/cms/CMSCompressedDataGenerator.cs | 8 | ||||
-rw-r--r-- | crypto/src/cms/CMSCompressedDataStreamGenerator.cs | 2 | ||||
-rw-r--r-- | crypto/src/cms/CMSContentInfoParser.cs | 2 | ||||
-rw-r--r-- | crypto/src/cms/CMSEnvelopedDataGenerator.cs | 18 | ||||
-rw-r--r-- | crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs | 2 | ||||
-rw-r--r-- | crypto/src/cms/CMSProcessableFile.cs | 7 | ||||
-rw-r--r-- | crypto/src/cms/CMSProcessableInputStream.cs | 2 | ||||
-rw-r--r-- | crypto/src/cms/CMSSignedDataParser.cs | 4 | ||||
-rw-r--r-- | crypto/src/cms/CMSSignedDataStreamGenerator.cs | 13 | ||||
-rw-r--r-- | crypto/src/cms/CMSTypedStream.cs | 2 |
13 files changed, 38 insertions, 35 deletions
diff --git a/crypto/src/cms/CMSAuthenticatedDataGenerator.cs b/crypto/src/cms/CMSAuthenticatedDataGenerator.cs index f6827157c..95e710c9b 100644 --- a/crypto/src/cms/CMSAuthenticatedDataGenerator.cs +++ b/crypto/src/cms/CMSAuthenticatedDataGenerator.cs @@ -71,11 +71,10 @@ namespace Org.BouncyCastle.Cms mac.Init(encKey); var bOut = new MemoryStream(); - Stream mOut = new TeeOutputStream(bOut, new MacSink(mac)); - - content.Write(mOut); - - Platform.Dispose(mOut); + using (var mOut = new TeeOutputStream(bOut, new MacSink(mac))) + { + content.Write(mOut); + } encContent = new BerOctetString(bOut.ToArray()); diff --git a/crypto/src/cms/CMSAuthenticatedDataStreamGenerator.cs b/crypto/src/cms/CMSAuthenticatedDataStreamGenerator.cs index 6348431a2..fd2c743bb 100644 --- a/crypto/src/cms/CMSAuthenticatedDataStreamGenerator.cs +++ b/crypto/src/cms/CMSAuthenticatedDataStreamGenerator.cs @@ -253,7 +253,7 @@ namespace Org.BouncyCastle.Cms { if (disposing) { - Platform.Dispose(macStream); + macStream.Dispose(); // TODO Parent context(s) should really be be closed explicitly diff --git a/crypto/src/cms/CMSCompressedData.cs b/crypto/src/cms/CMSCompressedData.cs index 5f8165005..4bfac3a93 100644 --- a/crypto/src/cms/CMSCompressedData.cs +++ b/crypto/src/cms/CMSCompressedData.cs @@ -56,7 +56,7 @@ namespace Org.BouncyCastle.Cms } finally { - Platform.Dispose(zIn); + zIn.Dispose(); } } diff --git a/crypto/src/cms/CMSCompressedDataGenerator.cs b/crypto/src/cms/CMSCompressedDataGenerator.cs index 70515e8d3..e60effa61 100644 --- a/crypto/src/cms/CMSCompressedDataGenerator.cs +++ b/crypto/src/cms/CMSCompressedDataGenerator.cs @@ -42,11 +42,11 @@ namespace Org.BouncyCastle.Cms try { MemoryStream bOut = new MemoryStream(); - Stream zOut = Utilities.IO.Compression.ZLib.CompressOutput(bOut, -1); - content.Write(zOut); - - Platform.Dispose(zOut); + using (var zOut = Utilities.IO.Compression.ZLib.CompressOutput(bOut, -1)) + { + content.Write(zOut); + } comAlgId = new AlgorithmIdentifier(CmsObjectIdentifiers.ZlibCompress); comOcts = new BerOctetString(bOut.ToArray()); diff --git a/crypto/src/cms/CMSCompressedDataStreamGenerator.cs b/crypto/src/cms/CMSCompressedDataStreamGenerator.cs index 3669c0b3a..64a978c6d 100644 --- a/crypto/src/cms/CMSCompressedDataStreamGenerator.cs +++ b/crypto/src/cms/CMSCompressedDataStreamGenerator.cs @@ -135,7 +135,7 @@ namespace Org.BouncyCastle.Cms { if (disposing) { - Platform.Dispose(_out); + _out.Dispose(); // TODO Parent context(s) should really be be closed explicitly diff --git a/crypto/src/cms/CMSContentInfoParser.cs b/crypto/src/cms/CMSContentInfoParser.cs index a7b43f295..c3bc9e736 100644 --- a/crypto/src/cms/CMSContentInfoParser.cs +++ b/crypto/src/cms/CMSContentInfoParser.cs @@ -42,7 +42,7 @@ namespace Org.BouncyCastle.Cms */ public void Close() { - Platform.Dispose(this.data); + data.Dispose(); } } } diff --git a/crypto/src/cms/CMSEnvelopedDataGenerator.cs b/crypto/src/cms/CMSEnvelopedDataGenerator.cs index 1b618b331..d2cd18885 100644 --- a/crypto/src/cms/CMSEnvelopedDataGenerator.cs +++ b/crypto/src/cms/CMSEnvelopedDataGenerator.cs @@ -67,11 +67,10 @@ namespace Org.BouncyCastle.Cms cipher.Init(true, new ParametersWithRandom(cipherParameters, m_random)); MemoryStream bOut = new MemoryStream(); - CipherStream cOut = new CipherStream(bOut, null, cipher); - - content.Write(cOut); - - Platform.Dispose(cOut); + using (var cOut = new CipherStream(bOut, null, cipher)) + { + content.Write(cOut); + } encContent = new BerOctetString(bOut.ToArray()); } @@ -159,9 +158,12 @@ namespace Org.BouncyCastle.Cms encKey = (KeyParameter) cipherBuilder.Key; MemoryStream collector = new MemoryStream(); - Stream bOut = cipherBuilder.BuildCipher(collector).Stream; - content.Write(bOut); - Platform.Dispose(bOut); + var cipher = cipherBuilder.BuildCipher(collector); + using (var bOut = cipher.Stream) + { + content.Write(bOut); + } + encContent = new BerOctetString(collector.ToArray()); } catch (SecurityUtilityException e) diff --git a/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs b/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs index ad356a208..aafebee44 100644 --- a/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs +++ b/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs @@ -256,7 +256,7 @@ namespace Org.BouncyCastle.Cms { if (disposing) { - Platform.Dispose(_out); + _out.Dispose(); // TODO Parent context(s) should really be closed explicitly diff --git a/crypto/src/cms/CMSProcessableFile.cs b/crypto/src/cms/CMSProcessableFile.cs index 255c8432f..0344759cc 100644 --- a/crypto/src/cms/CMSProcessableFile.cs +++ b/crypto/src/cms/CMSProcessableFile.cs @@ -34,9 +34,10 @@ namespace Org.BouncyCastle.Cms public virtual void Write(Stream zOut) { - Stream inStr = _file.OpenRead(); - Streams.PipeAll(inStr, zOut, _bufSize); - Platform.Dispose(inStr); + using (var inStr = _file.OpenRead()) + { + Streams.PipeAll(inStr, zOut, _bufSize); + } } } } diff --git a/crypto/src/cms/CMSProcessableInputStream.cs b/crypto/src/cms/CMSProcessableInputStream.cs index 8fb3adbff..1a80ccfd6 100644 --- a/crypto/src/cms/CMSProcessableInputStream.cs +++ b/crypto/src/cms/CMSProcessableInputStream.cs @@ -30,7 +30,7 @@ namespace Org.BouncyCastle.Cms CheckSingleUsage(); Streams.PipeAll(input, output); - Platform.Dispose(input); + input.Dispose(); } protected virtual void CheckSingleUsage() diff --git a/crypto/src/cms/CMSSignedDataParser.cs b/crypto/src/cms/CMSSignedDataParser.cs index c5dc795a8..04a6d666b 100644 --- a/crypto/src/cms/CMSSignedDataParser.cs +++ b/crypto/src/cms/CMSSignedDataParser.cs @@ -366,7 +366,7 @@ namespace Org.BouncyCastle.Cms // gen.AddSigners(parser.GetSignerInfos()); - Platform.Dispose(contentOut); + contentOut.Dispose(); return outStr; } @@ -415,7 +415,7 @@ namespace Org.BouncyCastle.Cms gen.AddSigners(parser.GetSignerInfos()); - Platform.Dispose(contentOut); + contentOut.Dispose(); return outStr; } diff --git a/crypto/src/cms/CMSSignedDataStreamGenerator.cs b/crypto/src/cms/CMSSignedDataStreamGenerator.cs index 3f2da5f7e..a4e960ba6 100644 --- a/crypto/src/cms/CMSSignedDataStreamGenerator.cs +++ b/crypto/src/cms/CMSSignedDataStreamGenerator.cs @@ -621,12 +621,13 @@ namespace Org.BouncyCastle.Cms Stream dataOutputStream, CmsProcessable content) { - Stream signedOut = Open(outStream, eContentType, encapsulate, dataOutputStream); - if (content != null) + using (var signedOut = Open(outStream, eContentType, encapsulate, dataOutputStream)) { - content.Write(signedOut); - } - Platform.Dispose(signedOut); + if (content != null) + { + content.Write(signedOut); + } + } } // RFC3852, section 5.1: @@ -806,7 +807,7 @@ namespace Org.BouncyCastle.Cms private void DoClose() { - Platform.Dispose(_out); + _out.Dispose(); // TODO Parent context(s) should really be be closed explicitly diff --git a/crypto/src/cms/CMSTypedStream.cs b/crypto/src/cms/CMSTypedStream.cs index 7a66f0c74..92e71a20e 100644 --- a/crypto/src/cms/CMSTypedStream.cs +++ b/crypto/src/cms/CMSTypedStream.cs @@ -49,7 +49,7 @@ namespace Org.BouncyCastle.Cms public void Drain() { Streams.Drain(_in); - Platform.Dispose(_in); + _in.Dispose(); } private class FullReaderStream : FilterStream |