2222 * </p>
2323 */
2424public abstract class PBEKeyEncryptionMethodGenerator
25- extends PGPKeyEncryptionMethodGenerator
25+ implements PGPKeyEncryptionMethodGenerator
2626{
2727 private char [] passPhrase ;
2828 private PGPDigestCalculator s2kDigestCalculator ;
@@ -161,38 +161,57 @@ public byte[] getKey(int encAlgorithm)
161161 }
162162
163163 /**
164- * Generates a version 4 Public -Key-Encrypted-Session-Key (PKESK ) packet, encoding the encrypted
164+ * Generates a version 4 Symmetric -Key-Encrypted-Session-Key (SKESK ) packet, encoding the encrypted
165165 * session-key for this method.
166- * PKESKv4 packets are used by Symmetrically-Encrypted-Integrity-Protected-Data (SEIPD) packets
166+ * SKESKv4 packets are used by Symmetrically-Encrypted-Integrity-Protected-Data (SEIPD) packets
167167 * of version 1, or by (deprecated) Symmetrically-Encrypted-Data (SED) packets.
168- * You can use PKESKv4 packets with OpenPGP v4 keys, but MUST NOT use them when producing
169- * SEIPDv2 packets (use {@link #generateV6(int, int, byte[])} instead in that case).
168+ * You MUST NOT use them when producing SEIPDv2 packets ( use {@link #generateV6(int, int, byte[])}
169+ * instead in that case).
170170 *
171- * @param encAlgorithm the {@link SymmetricKeyAlgorithmTags encryption algorithm} being used
171+ * @param kekAlgorithm the {@link SymmetricKeyAlgorithmTags encryption algorithm} being used to
172+ * wrap the session key
172173 * @param sessionInfo session data generated by the encrypted data generator.
173174 * @return a packet encoding the provided information and the configuration of this instance.
174175 *
175176 * @throws PGPException if an error occurs constructing the packet.
177+ * @see <a href="https://www.rfc-editor.org/rfc/rfc9580.html#name-version-4-symmetric-key-enc">
178+ * RFC9580 - Symmetric-Key Encrypted Session-Key Packet version 4</a>
176179 */
177- public ContainedPacket generateV4 (int encAlgorithm , byte [] sessionInfo )
180+ public ContainedPacket generateV4 (int kekAlgorithm , byte [] sessionInfo )
178181 throws PGPException
179182 {
180183 if (sessionInfo == null )
181184 {
182- return SymmetricKeyEncSessionPacket .createV4Packet (encAlgorithm , s2k , null );
185+ return SymmetricKeyEncSessionPacket .createV4Packet (kekAlgorithm , s2k , null );
183186 }
184187
185- byte [] key = getKey (encAlgorithm );
188+ byte [] key = getKey (kekAlgorithm );
186189 //
187190 // the passed in session info has the an RSA/ElGamal checksum added to it, for PBE this is not included.
188191 //
189192 byte [] nSessionInfo = new byte [sessionInfo .length - 2 ];
190193
191194 System .arraycopy (sessionInfo , 0 , nSessionInfo , 0 , nSessionInfo .length );
192195
193- return SymmetricKeyEncSessionPacket .createV4Packet (encAlgorithm , s2k , encryptSessionInfo (encAlgorithm , key , nSessionInfo ));
196+ return SymmetricKeyEncSessionPacket .createV4Packet (kekAlgorithm , s2k , encryptSessionInfo (kekAlgorithm , key , nSessionInfo ));
194197 }
195198
199+ /**
200+ * Generates a version 5 Symmetric-Key-Encrypted-Session-Key (SKESK) packet, encoding the encrypted
201+ * session-key for this method.
202+ * SKESKv5 packets are used with {@link org.bouncycastle.bcpg.AEADEncDataPacket OCB-Encrypted Data (OED) packets}
203+ * only.
204+ *
205+ * @param kekAlgorithm the {@link SymmetricKeyAlgorithmTags encryption algorithm} being used to
206+ * wrap the session key
207+ * @param aeadAlgorithm AEAD algorithm ID (MUST be {@link org.bouncycastle.bcpg.AEADAlgorithmTags#OCB})
208+ * @param sessionInfo session data generated by the encrypted data generator.
209+ * @return a packet encoding the provided information and the configuration of this instance.
210+ *
211+ * @throws PGPException if an error occurs constructing the packet.
212+ * @see <a href="https://www.ietf.org/archive/id/draft-koch-librepgp-02.html#section-5.3-8">
213+ * LibrePGP - Symmetric-Key Encrypted Session-Key Packet version 5</a>
214+ */
196215 public ContainedPacket generateV5 (int kekAlgorithm , int aeadAlgorithm , byte [] sessionInfo )
197216 throws PGPException
198217 {
@@ -216,6 +235,23 @@ public ContainedPacket generateV5(int kekAlgorithm, int aeadAlgorithm, byte[] se
216235 return SymmetricKeyEncSessionPacket .createV5Packet (kekAlgorithm , aeadAlgorithm , iv , s2k , esk , tag );
217236 }
218237
238+ /**
239+ * Generates a version 6 Symmetric-Key-Encrypted-Session-Key (SKESK) packet, encoding the encrypted
240+ * session-key for this method.
241+ * SKESKv6 packets are used with Symmetrically-Encrypted Integrity-Protected Data (SEIPD) packets of
242+ * version 2 only.
243+ * A SKESKv6 packet MUST NOT precede a SEIPDv1, OED or SED packet.
244+ *
245+ * @param kekAlgorithm the {@link SymmetricKeyAlgorithmTags encryption algorithm} being used to
246+ * wrap the session key
247+ * @param aeadAlgorithm AEAD algorithm ID
248+ * @param sessionInfo session data generated by the encrypted data generator.
249+ * @return a packet encoding the provided information and the configuration of this instance.
250+ *
251+ * @throws PGPException if an error occurs constructing the packet.
252+ * @see <a href="https://www.rfc-editor.org/rfc/rfc9580.html#name-version-6-symmetric-key-enc">
253+ * RFC9580 - Symmetric-Key Encrypted Session-Key Packet version 6</a>
254+ */
219255 public ContainedPacket generateV6 (int kekAlgorithm , int aeadAlgorithm , byte [] sessionInfo )
220256 throws PGPException
221257 {
0 commit comments