diff --git a/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs b/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs
index 2c2590ade..e902f8738 100644
--- a/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs
+++ b/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs
@@ -13,34 +13,27 @@
namespace Org.BouncyCastle.Cms
{
- /**
- * General class for generating a CMS enveloped-data message stream.
- *
- * A simple example of usage.
- *
- * CmsEnvelopedDataStreamGenerator edGen = new CmsEnvelopedDataStreamGenerator();
- * edGen.AddKeyTransRecipient(cert);
- *
- * MemoryStream bOut = new MemoryStream();
- *
- * Stream out = edGen.Open(bOut, CMSEnvelopedGenerator.AES128_CBC);
- * out.Write(data);
- * out.Close();
- *
- *
- *
- * Stream handling note:
- *
- * - The returned Stream must be closed to finalize the CMS structure.
- * - Closing the returned stream does not close the underlying Stream
- * passed to {@code Open()}.
- * - Callers are responsible for closing the underlying Stream separately.
- * If the underlying Stream is a buffering encoder whose tail state
- * only flushes on close (e.g. Apache Commons {@code Base64OutputStream}),
- * failing to close it will cause the encoded output to be truncated.
- *
- *
- */
+ ///
+ /// Streaming generator for CMS EnvelopedData (PKCS#7 enveloped-data) messages. Add recipients via the base
+ /// methods, then call to obtain a
+ /// to which the content to be encrypted is written; closing that stream finalizes the
+ /// CMS structure.
+ ///
+ ///
+ /// The returned stream must be closed (disposed) to finalize the CMS structure. Closing the returned stream
+ /// does not close the underlying stream passed to Open; callers are responsible for closing the
+ /// underlying stream separately. If the underlying stream is a buffering encoder whose tail state only flushes
+ /// on close (e.g. a base64 encoding stream), failing to close it will cause the encoded output to be truncated.
+ /// A simple example of usage:
+ ///
+ /// CmsEnvelopedDataStreamGenerator gen = new CmsEnvelopedDataStreamGenerator();
+ /// gen.AddKeyTransRecipient(cert);
+ /// using (Stream envOut = gen.Open(bOut, CmsEnvelopedGenerator.Aes128Cbc))
+ /// {
+ /// envOut.Write(data, 0, data.Length);
+ /// }
+ ///
+ ///
public class CmsEnvelopedDataStreamGenerator
: CmsEnvelopedGenerator
{
@@ -49,12 +42,15 @@ public class CmsEnvelopedDataStreamGenerator
private int m_bufferSize;
private bool m_berEncodeRecipientSet;
+ /// Creates a generator using the default randomness source.
public CmsEnvelopedDataStreamGenerator()
{
}
- /// Constructor allowing specific source of randomness
- /// Instance of SecureRandom to use.
+ ///
+ /// Creates a generator with an explicit randomness source for key and encryption operations.
+ ///
+ /// The secure random to use.
public CmsEnvelopedDataStreamGenerator(SecureRandom random)
: base(random)
{
@@ -67,7 +63,10 @@ public void SetBufferSize(int bufferSize)
m_bufferSize = bufferSize;
}
- /// Use a BER Set to store the recipient information.
+ /// Controls whether recipient information is stored using a BER (indefinite-length) SET.
+ ///
+ /// true to use a BER SET; false to use a DER SET (the default).
+ ///
public void SetBerEncodeRecipients(bool berEncodeRecipientSet)
{
m_berEncodeRecipientSet = berEncodeRecipientSet;
@@ -166,10 +165,13 @@ private Stream Open(Stream outStream, AlgorithmIdentifier encAlgID, ICipherParam
}
}
- /**
- * generate an enveloped object that contains an CMS Enveloped Data object
- * @throws IOException
- */
+ ///
+ /// Opens a stream for generating a CMS EnvelopedData object, deriving a content-encryption key of the
+ /// algorithm's default strength.
+ ///
+ /// The stream the CMS object is written to.
+ /// The content-encryption algorithm OID.
+ /// A stream the content to be encrypted is written to; close it to finalize the structure.
public Stream Open(Stream outStream, string encryptionOid)
{
CipherKeyGenerator keyGen = GeneratorUtilities.GetKeyGenerator(encryptionOid);
@@ -179,10 +181,14 @@ public Stream Open(Stream outStream, string encryptionOid)
return Open(outStream, encryptionOid, keyGen);
}
- /**
- * generate an enveloped object that contains an CMS Enveloped Data object
- * @throws IOException
- */
+ ///
+ /// Opens a stream for generating a CMS EnvelopedData object, deriving a content-encryption key of the
+ /// given size.
+ ///
+ /// The stream the CMS object is written to.
+ /// The content-encryption algorithm OID.
+ /// The content-encryption key size, in bits.
+ /// A stream the content to be encrypted is written to; close it to finalize the structure.
public Stream Open(Stream outStream, string encryptionOid, int keySize)
{
CipherKeyGenerator keyGen = GeneratorUtilities.GetKeyGenerator(encryptionOid);