mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-29 07:42:06 +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 {
|
dependencies {
|
||||||
testCompile group: 'junit', name: 'junit', version: '4.12'
|
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'
|
compile 'org.bouncycastle:bcpg-jdk15on:1.59'
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,18 +152,16 @@ public class DecryptionStreamFactory {
|
||||||
PGPPrivateKey decryptionKey = null;
|
PGPPrivateKey decryptionKey = null;
|
||||||
PGPPublicKeyEncryptedData encryptedSessionKey = null;
|
PGPPublicKeyEncryptedData encryptedSessionKey = null;
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
encryptedSessionKey = (PGPPublicKeyEncryptedData) iterator.next();
|
PGPPublicKeyEncryptedData encryptedData = (PGPPublicKeyEncryptedData) iterator.next();
|
||||||
long keyId = encryptedSessionKey.getKeyID();
|
long keyId = encryptedData.getKeyID();
|
||||||
|
|
||||||
resultBuilder.addRecipientKeyId(keyId);
|
resultBuilder.addRecipientKeyId(keyId);
|
||||||
LOGGER.log(LEVEL, "PGPEncryptedData is encrypted for key " + Long.toHexString(keyId));
|
LOGGER.log(LEVEL, "PGPEncryptedData is encrypted for key " + Long.toHexString(keyId));
|
||||||
if (decryptionKey != null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
PGPSecretKey secretKey = decryptionKeys.getSecretKey(keyId);
|
PGPSecretKey secretKey = decryptionKeys.getSecretKey(keyId);
|
||||||
if (secretKey != null) {
|
if (secretKey != null) {
|
||||||
LOGGER.log(LEVEL, "Found respective secret key " + Long.toHexString(keyId));
|
LOGGER.log(LEVEL, "Found respective secret key " + Long.toHexString(keyId));
|
||||||
|
encryptedSessionKey = encryptedData;
|
||||||
decryptionKey = secretKey.extractPrivateKey(decryptionKeyDecryptor.getDecryptor(keyId));
|
decryptionKey = secretKey.extractPrivateKey(decryptionKeyDecryptor.getDecryptor(keyId));
|
||||||
resultBuilder.setDecryptionKeyId(keyId);
|
resultBuilder.setDecryptionKeyId(keyId);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue