summary refs log tree commit diff
path: root/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs')
-rw-r--r--crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs45
1 files changed, 17 insertions, 28 deletions
diff --git a/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs b/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs
index 261f67a15..90ecf0748 100644
--- a/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs
+++ b/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs
@@ -250,51 +250,40 @@ namespace Org.BouncyCastle.Cms
             protected override void Dispose(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();
+ 				{
+					ImplClose();
                 }
                 base.Dispose(disposing);
             }
 #else
 			public override void Close()
 			{
-                Platform.Dispose(_out);
+				ImplClose();
+				base.Close();
+			}
+#endif
+
+			private void ImplClose()
+            {
+				Platform.Dispose(_out);
 
-                // TODO Parent context(s) should really be closed explicitly
+				// TODO Parent context(s) should really be closed explicitly
 
-                _eiGen.Close();
+				_eiGen.Close();
 
-                if (_outer.unprotectedAttributeGenerator != null)
-                {
+				if (_outer.unprotectedAttributeGenerator != null)
+				{
 					Asn1.Cms.AttributeTable attrTable = _outer.unprotectedAttributeGenerator.GetAttributes(
 						new Dictionary<CmsAttributeTableParameter, object>());
 
-                    Asn1Set unprotectedAttrs = new BerSet(attrTable.ToAsn1EncodableVector());
+					Asn1Set unprotectedAttrs = new BerSet(attrTable.ToAsn1EncodableVector());
 
-                    _envGen.AddObject(new DerTaggedObject(false, 1, unprotectedAttrs));
-                }
+					_envGen.AddObject(new DerTaggedObject(false, 1, unprotectedAttrs));
+				}
 
 				_envGen.Close();
 				_cGen.Close();
-				base.Close();
 			}
-#endif
 		}
 	}
 }