aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/thialfihar/android/apg/Apg.java
diff options
context:
space:
mode:
authorThialfihar <thialfihar@gmail.com>2010-04-15 14:37:46 +0000
committerThialfihar <thialfihar@gmail.com>2010-04-15 14:37:46 +0000
commitacd71a45c09ad6668a03ec74399d8f526ab647e2 (patch)
treeda6f4d3ee14825120083d9c838a804e9e918a2a0 /src/org/thialfihar/android/apg/Apg.java
parentb8009d6d43277a7840819885a64aeda9e5f582e7 (diff)
downloadopen-keychain-acd71a45c09ad6668a03ec74399d8f526ab647e2.tar.gz
open-keychain-acd71a45c09ad6668a03ec74399d8f526ab647e2.tar.bz2
open-keychain-acd71a45c09ad6668a03ec74399d8f526ab647e2.zip
minor layout fixes, replace non breakable spaces if found in an encrypted armored message, as they break the decryption, the HTML representation of GMail introduces them for empty lines ending in a normal space, also adjusted the PGP_MESSAGE regex to allow for spaces after the -----, which seems to be added by some implementations
Diffstat (limited to 'src/org/thialfihar/android/apg/Apg.java')
-rw-r--r--src/org/thialfihar/android/apg/Apg.java16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/org/thialfihar/android/apg/Apg.java b/src/org/thialfihar/android/apg/Apg.java
index bf32fc1eb..affc78cd7 100644
--- a/src/org/thialfihar/android/apg/Apg.java
+++ b/src/org/thialfihar/android/apg/Apg.java
@@ -122,7 +122,7 @@ public class Apg {
protected static Vector<PGPSecretKeyRing> mSecretKeyRings;
public static Pattern PGP_MESSAGE =
- Pattern.compile(".*?(-----BEGIN PGP MESSAGE-----\n.*?-----END PGP MESSAGE-----).*",
+ Pattern.compile(".*?(-----BEGIN PGP MESSAGE-----.*?-----END PGP MESSAGE-----).*",
Pattern.DOTALL);
protected static boolean mInitialized = false;
@@ -1135,6 +1135,7 @@ public class Apg {
}
public static void encrypt(InputStream inStream, OutputStream outStream,
+ boolean armored,
long encryptionKeyIds[], long signatureKeyId,
String signaturePassPhrase,
ProgressDialogUpdater progress)
@@ -1142,11 +1143,16 @@ public class Apg {
NoSuchAlgorithmException, SignatureException {
Security.addProvider(new BouncyCastleProvider());
- ArmoredOutputStream armorOut = new ArmoredOutputStream(outStream);
- armorOut.setHeader("Version", FULL_VERSION);
- OutputStream out = armorOut;
+ ArmoredOutputStream armorOut = null;
+ OutputStream out = null;
OutputStream encryptOut = null;
-
+ if (armored) {
+ armorOut = new ArmoredOutputStream(outStream);
+ armorOut.setHeader("Version", FULL_VERSION);
+ out = armorOut;
+ } else {
+ out = outStream;
+ }
PGPSecretKey signingKey = null;
PGPSecretKeyRing signingKeyRing = null;
PGPPrivateKey signaturePrivateKey = null;