<PackageReference Include="BouncyCastle.Cryptography" Version="2.7.0" />

Org.BouncyCastle.Cms.CmsEnvelopedDataStreamGenerator

Streaming generator for CMS EnvelopedData (PKCS#7 enveloped-data) messages. Add recipients via the base CmsEnvelopedGenerator methods, then call Open to obtain a Stream to which the content to be encrypted is written; closing that stream finalizes the CMS structure.

Creates a generator using the default randomness source.

Creates a generator with an explicit randomness source for key and encryption operations.

public Stream Open(Stream outStream, string encryptionOid)

Opens a stream for generating a CMS EnvelopedData object, deriving a content-encryption key of the algorithm's default strength.

public Stream Open(Stream outStream, string encryptionOid, int keySize)

Opens a stream for generating a CMS EnvelopedData object, deriving a content-encryption key of the given size.

public void SetBerEncodeRecipients(bool berEncodeRecipientSet)

Controls whether recipient information is stored using a BER (indefinite-length) SET.

public void SetBufferSize(int bufferSize)

Set the underlying string size for encapsulated data.