diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2015-11-04 19:28:43 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2015-11-04 19:28:43 +0700 |
commit | f56fc16973d66bd9461f247e50738e55bd54de7e (patch) | |
tree | 8e84c9bd2cfc2d554b99c8045ec46de7313410fc /crypto/src/cms | |
parent | Port updated revocation test from Java (diff) | |
download | BouncyCastle.NET-ed25519-f56fc16973d66bd9461f247e50738e55bd54de7e.tar.xz |
Replace Close with Dispose for PORTABLE
Diffstat (limited to 'crypto/src/cms')
-rw-r--r-- | crypto/src/cms/CMSAuthenticatedDataStreamGenerator.cs | 25 | ||||
-rw-r--r-- | crypto/src/cms/CMSCompressedDataStreamGenerator.cs | 19 | ||||
-rw-r--r-- | crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs | 31 | ||||
-rw-r--r-- | crypto/src/cms/CMSSignedDataStreamGenerator.cs | 20 |
4 files changed, 89 insertions, 6 deletions
diff --git a/crypto/src/cms/CMSAuthenticatedDataStreamGenerator.cs b/crypto/src/cms/CMSAuthenticatedDataStreamGenerator.cs index a9879a6fc..591e36f2d 100644 --- a/crypto/src/cms/CMSAuthenticatedDataStreamGenerator.cs +++ b/crypto/src/cms/CMSAuthenticatedDataStreamGenerator.cs @@ -252,7 +252,29 @@ namespace Org.BouncyCastle.Cms macStream.Write(bytes, off, len); } - public override void Close() +#if PORTABLE + protected override void Disposing(bool disposing) + { + if (disposing) + { + Platform.Dispose(macStream); + + // TODO Parent context(s) should really be be closed explicitly + + eiGen.Close(); + + // [TODO] auth attributes go here + byte[] macOctets = MacUtilities.DoFinal(mac); + authGen.AddObject(new DerOctetString(macOctets)); + // [TODO] unauth attributes go here + + authGen.Close(); + cGen.Close(); + } + base.Dispose(disposing); + } +#else + public override void Close() { Platform.Dispose(macStream); @@ -268,6 +290,7 @@ namespace Org.BouncyCastle.Cms authGen.Close(); cGen.Close(); } +#endif } } } diff --git a/crypto/src/cms/CMSCompressedDataStreamGenerator.cs b/crypto/src/cms/CMSCompressedDataStreamGenerator.cs index 73832f5f3..1fb8da756 100644 --- a/crypto/src/cms/CMSCompressedDataStreamGenerator.cs +++ b/crypto/src/cms/CMSCompressedDataStreamGenerator.cs @@ -125,7 +125,23 @@ namespace Org.BouncyCastle.Cms _out.Write(bytes, off, len); } - public override void Close() +#if PORTABLE + protected override void Disposing(bool disposing) + { + if (disposing) + { + Platform.Dispose(_out); + + // TODO Parent context(s) should really be be closed explicitly + + _eiGen.Close(); + _cGen.Close(); + _sGen.Close(); + } + base.Dispose(disposing); + } +#else + public override void Close() { Platform.Dispose(_out); @@ -136,6 +152,7 @@ namespace Org.BouncyCastle.Cms _sGen.Close(); base.Close(); } +#endif } } } diff --git a/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs b/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs index 17c49ed07..264161b73 100644 --- a/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs +++ b/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs @@ -255,11 +255,37 @@ namespace Org.BouncyCastle.Cms _out.Write(bytes, off, len); } - public override void Close() +#if PORTABLE + protected override void Disposing(bool disposing) + { + if (disposing) + { + Platform.Dispose(_out); + + // TODO Parent context(s) should really be closed explicitly + + _eiGen.Close(); + + if (_outer.unprotectedAttributeGenerator != null) + { + Asn1.Cms.AttributeTable attrTable = _outer.unprotectedAttributeGenerator.GetAttributes(Platform.CreateHashtable()); + + Asn1Set unprotectedAttrs = new BerSet(attrTable.ToAsn1EncodableVector()); + + _envGen.AddObject(new DerTaggedObject(false, 1, unprotectedAttrs)); + } + + _envGen.Close(); + _cGen.Close(); + } + base.Dispose(disposing); + } +#else + public override void Close() { Platform.Dispose(_out); - // TODO Parent context(s) should really be be closed explicitly + // TODO Parent context(s) should really be closed explicitly _eiGen.Close(); @@ -276,6 +302,7 @@ namespace Org.BouncyCastle.Cms _cGen.Close(); base.Close(); } +#endif } } } diff --git a/crypto/src/cms/CMSSignedDataStreamGenerator.cs b/crypto/src/cms/CMSSignedDataStreamGenerator.cs index 746538ebd..36e7a780c 100644 --- a/crypto/src/cms/CMSSignedDataStreamGenerator.cs +++ b/crypto/src/cms/CMSSignedDataStreamGenerator.cs @@ -809,8 +809,25 @@ namespace Org.BouncyCastle.Cms _out.Write(bytes, off, len); } +#if PORTABLE + protected override void Disposing(bool disposing) + { + if (disposing) + { + DoClose(); + } + base.Dispose(disposing); + } +#else public override void Close() { + DoClose(); + base.Close(); + } +#endif + + private void DoClose() + { Platform.Dispose(_out); // TODO Parent context(s) should really be be closed explicitly @@ -898,8 +915,7 @@ namespace Org.BouncyCastle.Cms _sigGen.Close(); _sGen.Close(); - base.Close(); - } + } private static void WriteToGenerator( Asn1Generator ag, |