1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-12-22 19:08:00 +01:00

Wrap MalformedOpenPgpMessageException in BadData

This commit is contained in:
Paul Schaub 2022-10-24 18:32:56 +02:00
parent 8097c87b7f
commit a013ab4ebb
4 changed files with 7 additions and 4 deletions

View file

@ -656,7 +656,7 @@ public class OpenPgpMessageInputStream extends DecryptionStream {
if (decryptionKey == null) { if (decryptionKey == null) {
continue; continue;
} }
KeyRingInfo info = new KeyRingInfo(secretKeys, policy, new Date()); KeyRingInfo info = new KeyRingInfo(secretKeys, policy, new Date());
List<PGPPublicKey> encryptionKeys = info.getEncryptionSubkeys(EncryptionPurpose.ANY); List<PGPPublicKey> encryptionKeys = info.getEncryptionSubkeys(EncryptionPurpose.ANY);
for (PGPPublicKey key : encryptionKeys) { for (PGPPublicKey key : encryptionKeys) {

View file

@ -23,6 +23,7 @@ import org.pgpainless.decryption_verification.ConsumerOptions;
import org.pgpainless.decryption_verification.DecryptionStream; import org.pgpainless.decryption_verification.DecryptionStream;
import org.pgpainless.decryption_verification.OpenPgpMetadata; import org.pgpainless.decryption_verification.OpenPgpMetadata;
import org.pgpainless.decryption_verification.SignatureVerification; import org.pgpainless.decryption_verification.SignatureVerification;
import org.pgpainless.exception.MalformedOpenPgpMessageException;
import org.pgpainless.exception.MissingDecryptionMethodException; import org.pgpainless.exception.MissingDecryptionMethodException;
import org.pgpainless.exception.WrongPassphraseException; import org.pgpainless.exception.WrongPassphraseException;
import org.pgpainless.util.Passphrase; import org.pgpainless.util.Passphrase;
@ -123,7 +124,7 @@ public class DecryptImpl implements Decrypt {
throw new SOPGPException.CannotDecrypt("No usable decryption key or password provided.", e); throw new SOPGPException.CannotDecrypt("No usable decryption key or password provided.", e);
} catch (WrongPassphraseException e) { } catch (WrongPassphraseException e) {
throw new SOPGPException.KeyIsProtected(); throw new SOPGPException.KeyIsProtected();
} catch (PGPException | IOException e) { } catch (MalformedOpenPgpMessageException | PGPException | IOException e) {
throw new SOPGPException.BadData(e); throw new SOPGPException.BadData(e);
} finally { } finally {
// Forget passphrases after decryption // Forget passphrases after decryption

View file

@ -18,6 +18,7 @@ import org.pgpainless.decryption_verification.ConsumerOptions;
import org.pgpainless.decryption_verification.DecryptionStream; import org.pgpainless.decryption_verification.DecryptionStream;
import org.pgpainless.decryption_verification.OpenPgpMetadata; import org.pgpainless.decryption_verification.OpenPgpMetadata;
import org.pgpainless.decryption_verification.SignatureVerification; import org.pgpainless.decryption_verification.SignatureVerification;
import org.pgpainless.exception.MalformedOpenPgpMessageException;
import sop.Verification; import sop.Verification;
import sop.exception.SOPGPException; import sop.exception.SOPGPException;
import sop.operation.DetachedVerify; import sop.operation.DetachedVerify;
@ -82,7 +83,7 @@ public class DetachedVerifyImpl implements DetachedVerify {
} }
return verificationList; return verificationList;
} catch (PGPException e) { } catch (MalformedOpenPgpMessageException | PGPException e) {
throw new SOPGPException.BadData(e); throw new SOPGPException.BadData(e);
} }
} }

View file

@ -19,6 +19,7 @@ import org.pgpainless.decryption_verification.ConsumerOptions;
import org.pgpainless.decryption_verification.DecryptionStream; import org.pgpainless.decryption_verification.DecryptionStream;
import org.pgpainless.decryption_verification.OpenPgpMetadata; import org.pgpainless.decryption_verification.OpenPgpMetadata;
import org.pgpainless.decryption_verification.SignatureVerification; import org.pgpainless.decryption_verification.SignatureVerification;
import org.pgpainless.exception.MalformedOpenPgpMessageException;
import org.pgpainless.exception.MissingDecryptionMethodException; import org.pgpainless.exception.MissingDecryptionMethodException;
import sop.ReadyWithResult; import sop.ReadyWithResult;
import sop.Verification; import sop.Verification;
@ -82,7 +83,7 @@ public class InlineVerifyImpl implements InlineVerify {
return verificationList; return verificationList;
} catch (MissingDecryptionMethodException e) { } catch (MissingDecryptionMethodException e) {
throw new SOPGPException.BadData("Cannot verify encrypted message.", e); throw new SOPGPException.BadData("Cannot verify encrypted message.", e);
} catch (PGPException e) { } catch (MalformedOpenPgpMessageException | PGPException e) {
throw new SOPGPException.BadData(e); throw new SOPGPException.BadData(e);
} }
} }