diff --git a/pgpainless-core/src/main/java/org/pgpainless/decryption_verification/DecryptionStream.java b/pgpainless-core/src/main/java/org/pgpainless/decryption_verification/DecryptionStream.java index 566bd26e..42c58252 100644 --- a/pgpainless-core/src/main/java/org/pgpainless/decryption_verification/DecryptionStream.java +++ b/pgpainless-core/src/main/java/org/pgpainless/decryption_verification/DecryptionStream.java @@ -60,6 +60,21 @@ public class DecryptionStream extends InputStream { return r; } + @Override + public int read(@Nonnull byte[] bytes, int offset, int length) throws IOException { + int read = inputStream.read(bytes, offset, length); + if (read != -1) { + maybeUpdateDetachedSignatures(bytes, offset, read); + } + return read; + } + + private void maybeUpdateDetachedSignatures(byte[] bytes, int offset, int length) { + for (DetachedSignature s : resultBuilder.getDetachedSignatures()) { + s.getSignature().update(bytes, offset, length); + } + } + private void maybeUpdateDetachedSignatures(int rByte) { for (DetachedSignature s : resultBuilder.getDetachedSignatures()) { if (rByte != -1) { diff --git a/pgpainless-core/src/main/java/org/pgpainless/util/IntegrityProtectedInputStream.java b/pgpainless-core/src/main/java/org/pgpainless/util/IntegrityProtectedInputStream.java index eb867505..ee6d3c45 100644 --- a/pgpainless-core/src/main/java/org/pgpainless/util/IntegrityProtectedInputStream.java +++ b/pgpainless-core/src/main/java/org/pgpainless/util/IntegrityProtectedInputStream.java @@ -18,6 +18,8 @@ package org.pgpainless.util; import java.io.IOException; import java.io.InputStream; +import javax.annotation.Nonnull; + import org.bouncycastle.openpgp.PGPEncryptedData; import org.bouncycastle.openpgp.PGPException; import org.pgpainless.exception.ModificationDetectionException; @@ -37,6 +39,11 @@ public class IntegrityProtectedInputStream extends InputStream { return inputStream.read(); } + @Override + public int read(@Nonnull byte[] b, int offset, int length) throws IOException { + return inputStream.read(b, offset, length); + } + @Override public void close() throws IOException { if (encryptedData.isIntegrityProtected()) {