@@ -56,17 +56,6 @@ public void setBEREncodeRecipients(
5656 _berEncodeRecipientSet = berEncodeRecipientSet ;
5757 }
5858
59- private OutputStream doOpen (
60- ASN1ObjectIdentifier dataType ,
61- OutputStream out ,
62- OutputAEADEncryptor encryptor )
63- throws IOException , CMSException
64- {
65- ASN1EncodableVector recipientInfos = CMSUtils .getRecipentInfos (encryptor .getKey (), recipientInfoGenerators );
66-
67- return open (dataType , out , recipientInfos , encryptor );
68- }
69-
7059 protected OutputStream open (
7160 ASN1ObjectIdentifier dataType ,
7261 OutputStream out ,
@@ -123,22 +112,41 @@ protected OutputStream open(
123112 }
124113
125114 /**
126- * generate an enveloped object that contains an CMS Enveloped Data object using the given encryptor.
115+ * Generate authenticated-enveloped-data using the given encryptor, and marking the encapsulated
116+ * bytes as being of type DATA.
117+ * <p>
118+ * <b>Stream handling note:</b> Closing the returned stream finalizes the CMS structure but <b>does
119+ * not close</b> the underlying output stream. The caller remains responsible for managing the
120+ * lifecycle of {@code out}.
121+ *
122+ * @param out the output stream to write the CMS structure to
123+ * @param encryptor the cipher to use for encryption
124+ * @return an output stream that writes encrypted and authenticated content
125+ */
126+ public OutputStream open (OutputStream out , OutputAEADEncryptor encryptor ) throws CMSException , IOException
127+ {
128+ return open (CMSObjectIdentifiers .data , out , encryptor );
129+ }
130+
131+ /**
132+ * Generate authenticated-enveloped-data using the given encryptor, and marking the encapsulated
133+ * bytes as being of the passed in type.
127134 * <p>
128135 * <b>Stream handling note:</b> Closing the returned stream finalizes the CMS structure but
129136 * <b>does not close</b> the underlying output stream. The caller remains responsible for
130137 * managing the lifecycle of {@code out}.
131138 *
139+ * @param dataType the type of the data being written to the object.
132140 * @param out the output stream to write the CMS structure to
133141 * @param encryptor the cipher to use for encryption
134142 * @return an output stream that writes encrypted and authenticated content
135143 */
136- public OutputStream open (
137- OutputStream out ,
138- OutputAEADEncryptor encryptor )
144+ public OutputStream open (ASN1ObjectIdentifier dataType , OutputStream out , OutputAEADEncryptor encryptor )
139145 throws CMSException , IOException
140146 {
141- return doOpen (CMSObjectIdentifiers .data , out , encryptor );
147+ ASN1EncodableVector recipientInfos = CMSUtils .getRecipentInfos (encryptor .getKey (), recipientInfoGenerators );
148+
149+ return open (dataType , out , recipientInfos , encryptor );
142150 }
143151
144152 private class CMSAuthEnvelopedDataOutputStream
0 commit comments