summary refs log tree commit diff
path: root/crypto/src/cms/CMSAuthenticatedDataStreamGenerator.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/cms/CMSAuthenticatedDataStreamGenerator.cs')
-rw-r--r--crypto/src/cms/CMSAuthenticatedDataStreamGenerator.cs25
1 files changed, 24 insertions, 1 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
 		}
 	}
 }