From 80d97b1bc02497c9dd723a497932065b7975a191 Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Sun, 27 Mar 2022 16:35:20 +0200 Subject: [PATCH] Fix malformed signature packets --- .../org/pgpainless/encryption_signing/EncryptionStream.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pgpainless-core/src/main/java/org/pgpainless/encryption_signing/EncryptionStream.java b/pgpainless-core/src/main/java/org/pgpainless/encryption_signing/EncryptionStream.java index 6fc112ba..68aef2ce 100644 --- a/pgpainless-core/src/main/java/org/pgpainless/encryption_signing/EncryptionStream.java +++ b/pgpainless-core/src/main/java/org/pgpainless/encryption_signing/EncryptionStream.java @@ -47,6 +47,8 @@ public final class EncryptionStream extends OutputStream { private static final int BUFFER_SIZE = 1 << 9; OutputStream outermostStream; + OutputStream signatureLayerStream; + private ArmoredOutputStream armorOutputStream = null; private OutputStream publicKeyEncryptedStream = null; private PGPCompressedDataGenerator compressedDataGenerator; @@ -130,6 +132,7 @@ public final class EncryptionStream extends OutputStream { } private void prepareOnePassSignatures() throws IOException, PGPException { + signatureLayerStream = outermostStream; SigningOptions signingOptions = options.getSigningOptions(); if (signingOptions == null || signingOptions.getSigningMethods().isEmpty()) { // No singing options/methods -> no signing @@ -274,7 +277,7 @@ public final class EncryptionStream extends OutputStream { resultBuilder.addDetachedSignature(signingKey, signature); } if (!signingMethod.isDetached() || options.isCleartextSigned()) { - signature.encode(outermostStream); + signature.encode(signatureLayerStream); } } }