1 files changed, 31 insertions, 4 deletions
diff --git a/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs b/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs
index a63ea7b7f..8e6d2729b 100644
--- a/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs
+++ b/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs
@@ -166,7 +166,7 @@ namespace Org.BouncyCastle.Cms
Stream octetOutputStream = CmsUtilities.CreateBerOctetOutputStream(
eiGen.GetRawOutputStream(), 0, false, _bufferSize);
- IBufferedCipher cipher = CipherUtilities.GetCipher(encAlgID.ObjectID);
+ IBufferedCipher cipher = CipherUtilities.GetCipher(encAlgID.Algorithm);
cipher.Init(true, new ParametersWithRandom(cipherParameters, rand));
CipherStream cOut = new CipherStream(octetOutputStream, null, cipher);
@@ -255,11 +255,37 @@ namespace Org.BouncyCastle.Cms
_out.Write(bytes, off, len);
}
- public override void Close()
+#if PORTABLE
+ 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();
+ }
+ base.Dispose(disposing);
+ }
+#else
+ public override void Close()
{
- _out.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
}
}
}
|