summary refs log tree commit diff
path: root/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2015-11-04 19:28:43 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2015-11-04 19:28:43 +0700
commitf56fc16973d66bd9461f247e50738e55bd54de7e (patch)
tree8e84c9bd2cfc2d554b99c8045ec46de7313410fc /crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs
parentPort updated revocation test from Java (diff)
downloadBouncyCastle.NET-ed25519-f56fc16973d66bd9461f247e50738e55bd54de7e.tar.xz
Replace Close with Dispose for PORTABLE
Diffstat (limited to 'crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs')
-rw-r--r--crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs31
1 files changed, 29 insertions, 2 deletions
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
 		}
 	}
 }