diff --git a/build.gradle b/build.gradle index 2d133f8d..6bec0f21 100644 --- a/build.gradle +++ b/build.gradle @@ -25,6 +25,6 @@ repositories { dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' - compile 'org.bouncycastle:bcprov-jdk15on:1.59' + compile 'org.bouncycastle:bcprov-debug-jdk15on:1.59' compile 'org.bouncycastle:bcpg-jdk15on:1.59' } diff --git a/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/DecryptionStreamFactory.java b/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/DecryptionStreamFactory.java index d651b1bf..522ac668 100644 --- a/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/DecryptionStreamFactory.java +++ b/src/main/java/de/vanitasvitae/crypto/pgpainless/decryption_verification/DecryptionStreamFactory.java @@ -152,18 +152,16 @@ public class DecryptionStreamFactory { PGPPrivateKey decryptionKey = null; PGPPublicKeyEncryptedData encryptedSessionKey = null; while (iterator.hasNext()) { - encryptedSessionKey = (PGPPublicKeyEncryptedData) iterator.next(); - long keyId = encryptedSessionKey.getKeyID(); + PGPPublicKeyEncryptedData encryptedData = (PGPPublicKeyEncryptedData) iterator.next(); + long keyId = encryptedData.getKeyID(); resultBuilder.addRecipientKeyId(keyId); LOGGER.log(LEVEL, "PGPEncryptedData is encrypted for key " + Long.toHexString(keyId)); - if (decryptionKey != null) { - continue; - } PGPSecretKey secretKey = decryptionKeys.getSecretKey(keyId); if (secretKey != null) { LOGGER.log(LEVEL, "Found respective secret key " + Long.toHexString(keyId)); + encryptedSessionKey = encryptedData; decryptionKey = secretKey.extractPrivateKey(decryptionKeyDecryptor.getDecryptor(keyId)); resultBuilder.setDecryptionKeyId(keyId); }