diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-11-09 16:08:19 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-11-09 16:08:19 +0700 |
commit | 7735c6336809bc20d10dae1c15891143d0cc54c5 (patch) | |
tree | 3f08af7faa908520ae06944744c1e86aeea395d6 /crypto/src/cms/CMSCompressedDataStreamGenerator.cs | |
parent | Remove unused class (diff) | |
download | BouncyCastle.NET-ed25519-7735c6336809bc20d10dae1c15891143d0cc54c5.tar.xz |
Asn1Generator implements IDisposable
- now expects BerOctetStringGenerator to be disposed, not just its octets stream
Diffstat (limited to 'crypto/src/cms/CMSCompressedDataStreamGenerator.cs')
-rw-r--r-- | crypto/src/cms/CMSCompressedDataStreamGenerator.cs | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/crypto/src/cms/CMSCompressedDataStreamGenerator.cs b/crypto/src/cms/CMSCompressedDataStreamGenerator.cs index 64a978c6d..f992a8269 100644 --- a/crypto/src/cms/CMSCompressedDataStreamGenerator.cs +++ b/crypto/src/cms/CMSCompressedDataStreamGenerator.cs @@ -87,11 +87,11 @@ namespace Org.BouncyCastle.Cms eiGen.AddObject(new DerObjectIdentifier(contentOid)); - Stream octetStream = CmsUtilities.CreateBerOctetOutputStream( - eiGen.GetRawOutputStream(), 0, true, _bufferSize); + BerOctetStringGenerator octGen = new BerOctetStringGenerator(eiGen.GetRawOutputStream(), 0, true); + Stream octetStream = octGen.GetOctetOutputStream(_bufferSize); - return new CmsCompressedOutputStream( - Utilities.IO.Compression.ZLib.CompressOutput(octetStream, -1), sGen, cGen, eiGen); + return new CmsCompressedOutputStream( + Utilities.IO.Compression.ZLib.CompressOutput(octetStream, -1), sGen, cGen, eiGen, octGen); } private class CmsCompressedOutputStream @@ -101,17 +101,20 @@ namespace Org.BouncyCastle.Cms private BerSequenceGenerator _sGen; private BerSequenceGenerator _cGen; private BerSequenceGenerator _eiGen; + private BerOctetStringGenerator _octGen; - internal CmsCompressedOutputStream( + internal CmsCompressedOutputStream( Stream outStream, BerSequenceGenerator sGen, BerSequenceGenerator cGen, - BerSequenceGenerator eiGen) + BerSequenceGenerator eiGen, + BerOctetStringGenerator octGen) { _out = outStream; _sGen = sGen; _cGen = cGen; _eiGen = eiGen; + _octGen = octGen; } public override void Write(byte[] buffer, int offset, int count) @@ -137,11 +140,12 @@ namespace Org.BouncyCastle.Cms { _out.Dispose(); - // TODO Parent context(s) should really be be closed explicitly + // TODO Parent context(s) should really be be closed explicitly - _eiGen.Close(); - _cGen.Close(); - _sGen.Close(); + _octGen.Dispose(); + _eiGen.Dispose(); + _cGen.Dispose(); + _sGen.Dispose(); } base.Dispose(disposing); } |