1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2025-12-17 09:41:08 +01:00

Add junit test for symmetric decryption

This commit is contained in:
Paul Schaub 2020-12-26 23:36:33 +01:00
parent 7d374f10a7
commit c7ede0fc8a
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
2 changed files with 72 additions and 2 deletions

View file

@ -201,7 +201,12 @@ public final class DecryptionStreamFactory {
pbeEncryptedData.getSymmetricAlgorithm(passphraseDecryptor));
resultBuilder.setSymmetricKeyAlgorithm(symmetricKeyAlgorithm);
resultBuilder.setIntegrityProtected(pbeEncryptedData.isIntegrityProtected());
return pbeEncryptedData.getDataStream(passphraseDecryptor);
try {
return pbeEncryptedData.getDataStream(passphraseDecryptor);
} catch (PGPException e) {
LOGGER.log(LEVEL, "Probable passphrase mismatch, skip PBE encrypted data block", e);
}
}
} else if (encryptedData instanceof PGPPublicKeyEncryptedData) {
@ -225,7 +230,7 @@ public final class DecryptionStreamFactory {
}
if (decryptionKey == null) {
throw new PGPException("Decryption failed - No suitable decryption key found");
throw new PGPException("Decryption failed - No suitable decryption key or passphrase found");
}
PublicKeyDataDecryptorFactory keyDecryptor = new BcPublicKeyDataDecryptorFactory(decryptionKey);