aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2014-02-19 12:07:07 +0100
committerDominik Schürmann <dominik@dominikschuermann.de>2014-02-19 12:07:07 +0100
commitc5688889a70d9d8a8fa17e548faa0049ed0368dd (patch)
treead26868df0e01a1b4999e368856fd17cf4011e0c /OpenPGP-Keychain
parenta5e33097a6cb3d8240ea475bfd32f0dbda02b4a0 (diff)
downloadopen-keychain-c5688889a70d9d8a8fa17e548faa0049ed0368dd.tar.gz
open-keychain-c5688889a70d9d8a8fa17e548faa0049ed0368dd.tar.bz2
open-keychain-c5688889a70d9d8a8fa17e548faa0049ed0368dd.zip
fixes encryption
Diffstat (limited to 'OpenPGP-Keychain')
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpOperationOutgoing.java20
1 files changed, 16 insertions, 4 deletions
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpOperationOutgoing.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpOperationOutgoing.java
index f86d83547..8431aa165 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpOperationOutgoing.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpOperationOutgoing.java
@@ -33,6 +33,7 @@ import org.spongycastle.openpgp.PGPSecretKeyRing;
import org.spongycastle.openpgp.PGPSignature;
import org.spongycastle.openpgp.PGPSignatureGenerator;
import org.spongycastle.openpgp.PGPSignatureSubpacketGenerator;
+import org.spongycastle.openpgp.PGPUtil;
import org.spongycastle.openpgp.PGPV3SignatureGenerator;
import org.spongycastle.openpgp.operator.PBESecretKeyDecryptor;
import org.spongycastle.openpgp.operator.jcajce.JcaPGPContentSignerBuilder;
@@ -195,8 +196,14 @@ public class PgpOperationOutgoing {
boolean enableEncryption = (encryptionKeyIds.length != 0 || encryptionPassphrase != null);
boolean enableCompression = (enableEncryption && compressionId != Id.choice.compression.none);
+ Log.d(Constants.TAG, "enableSignature:" + enableSignature
+ + "\nenableEncryption:" + enableEncryption
+ + "\nenableCompression:" + enableCompression
+ + "\nenableAsciiArmorOutput:" + enableAsciiArmorOutput);
+
int signatureType;
if (enableAsciiArmorOutput && enableSignature && !enableEncryption && !enableCompression) {
+ // for sign-only ascii text
signatureType = PGPSignature.CANONICAL_TEXT_DOCUMENT;
} else {
signatureType = PGPSignature.BINARY_DOCUMENT;
@@ -299,10 +306,10 @@ public class PgpOperationOutgoing {
PGPCompressedDataGenerator compressGen = null;
OutputStream pOut;
OutputStream encryptionOut = null;
+ BCPGOutputStream bcpgOut;
if (enableEncryption) {
encryptionOut = cPk.open(out, new byte[1 << 16]);
- BCPGOutputStream bcpgOut;
if (enableCompression) {
compressGen = new PGPCompressedDataGenerator(compressionId);
bcpgOut = new BCPGOutputStream(compressGen.open(encryptionOut));
@@ -402,18 +409,23 @@ public class PgpOperationOutgoing {
}
}
- // closing outputs...
+ // closing outputs
+ // NOTE: closing need to be done in the correct order!
+ // TODO: closing bcpgOut and pOut???
if (enableEncryption) {
- encryptionOut.close();
-
if (enableCompression) {
compressGen.close();
}
+
+ encryptionOut.close();
}
if (enableAsciiArmorOutput) {
armorOut.close();
}
+ out.close();
+ outStream.close();
+
updateProgress(R.string.progress_done, 100, 100);
}