1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-12-26 12:58:02 +01:00

Fix ugly bug: Use our private key on our enc session key

This commit is contained in:
Paul Schaub 2018-06-26 16:34:41 +02:00
parent eadc023940
commit f26e17848d
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
2 changed files with 4 additions and 6 deletions

View file

@ -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'
}

View file

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