mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-25 22:02:05 +01:00
Fix ugly bug: Use our private key on our enc session key
This commit is contained in:
parent
eadc023940
commit
f26e17848d
2 changed files with 4 additions and 6 deletions
|
@ -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'
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue