1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-12-23 11:27:57 +01:00

Add documentation to DecryptionStream(Interface)

This commit is contained in:
Paul Schaub 2021-04-25 13:34:30 +02:00
parent 7916bf77d1
commit 0b3511486c
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
2 changed files with 19 additions and 1 deletions

View file

@ -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();
}

View file

@ -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.");