Skip to content

Commit a883bf2

Browse files
author
gefeili
committed
Fix the bug in PGPEncryptedDataGenerator.open
1 parent d5fee26 commit a883bf2

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

pg/src/main/java/org/bouncycastle/openpgp/PGPEncryptedDataGenerator.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.bouncycastle.bcpg.BCPGOutputStream;
1212
import org.bouncycastle.bcpg.HashAlgorithmTags;
1313
import org.bouncycastle.bcpg.PacketTags;
14+
import org.bouncycastle.bcpg.SymmetricEncDataPacket;
1415
import org.bouncycastle.bcpg.SymmetricEncIntegrityPacket;
1516
import org.bouncycastle.bcpg.SymmetricKeyAlgorithmTags;
1617
import org.bouncycastle.openpgp.operator.PBEKeyEncryptionMethodGenerator;
@@ -260,10 +261,17 @@ else if (directS2K)
260261
// OpenPGP v4
261262
else // data is encrypted by v1 SEIPD or SED packet, so write v4 SKESK packet
262263
{
263-
encOut = SymmetricEncIntegrityPacket.createVersion1Packet();
264-
if (digestCalc != null && useOldFormat)
264+
if (digestCalc != null)
265+
{
266+
encOut = SymmetricEncIntegrityPacket.createVersion1Packet();
267+
if (useOldFormat)
268+
{
269+
throw new PGPException("symmetric-enc-integrity packets not supported in old PGP format");
270+
}
271+
}
272+
else
265273
{
266-
throw new PGPException("symmetric-enc-integrity packets not supported in old PGP format");
274+
encOut = new SymmetricEncDataPacket();
267275
}
268276

269277
if (buffer == null)

0 commit comments

Comments
 (0)