From 0b3511486c398dd416bfdcd801b8a85389d9e693 Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Sun, 25 Apr 2021 13:34:30 +0200 Subject: [PATCH] Add documentation to DecryptionStream(Interface) --- .../DecryptionBuilderInterface.java | 6 ++++++ .../decryption_verification/DecryptionStream.java | 14 +++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/pgpainless-core/src/main/java/org/pgpainless/decryption_verification/DecryptionBuilderInterface.java b/pgpainless-core/src/main/java/org/pgpainless/decryption_verification/DecryptionBuilderInterface.java index 608c5f63..fe98fd06 100644 --- a/pgpainless-core/src/main/java/org/pgpainless/decryption_verification/DecryptionBuilderInterface.java +++ b/pgpainless-core/src/main/java/org/pgpainless/decryption_verification/DecryptionBuilderInterface.java @@ -77,6 +77,12 @@ public interface DecryptionBuilderInterface { */ Verify decryptWith(@Nonnull Passphrase passphrase); + /** + * Do not attempt to decrypt the provided data. + * Useful for signature verification of signed-only data. + * + * @return api handle + */ Verify doNotDecrypt(); } 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 13e0f794..54f5f36e 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 @@ -25,6 +25,10 @@ import java.util.logging.Logger; import org.bouncycastle.openpgp.PGPException; import org.pgpainless.util.IntegrityProtectedInputStream; +/** + * Decryption Stream that handles updating and verification of detached signatures, + * as well as verification of integrity-protected input streams once the stream gets closed. + */ public class DecryptionStream extends InputStream { private static final Logger LOGGER = Logger.getLogger(DecryptionStream.class.getName()); @@ -66,7 +70,7 @@ public class DecryptionStream extends InputStream { this.isClosed = true; } - void maybeVerifyDetachedSignatures() { + private void maybeVerifyDetachedSignatures() { for (DetachedSignature s : resultBuilder.getDetachedSignatures()) { try { s.setVerified(s.getSignature().verify()); @@ -76,6 +80,14 @@ public class DecryptionStream extends InputStream { } } + /** + * Return the result of the decryption. + * The result contains metadata about the decryption, such as signatures, used keys and algorithms, as well as information + * about the decrypted file/stream. + * + * Can only be obtained once the stream got successfully closed ({@link #close()}). + * @return metadata + */ public OpenPgpMetadata getResult() { if (!isClosed) { throw new IllegalStateException("DecryptionStream MUST be closed before the result can be accessed.");