aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/thialfihar/android/apg/EncryptMessageActivity.java
diff options
context:
space:
mode:
authorThialfihar <thialfihar@gmail.com>2010-04-15 16:37:32 +0000
committerThialfihar <thialfihar@gmail.com>2010-04-15 16:37:32 +0000
commitc212f28c446044acb5fc7ef7487b95b777b39c44 (patch)
treed6e2c7eaa5a32a728de4d92463f041cedb08489a /src/org/thialfihar/android/apg/EncryptMessageActivity.java
parentacd71a45c09ad6668a03ec74399d8f526ab647e2 (diff)
downloadopen-keychain-c212f28c446044acb5fc7ef7487b95b777b39c44.tar.gz
open-keychain-c212f28c446044acb5fc7ef7487b95b777b39c44.tar.bz2
open-keychain-c212f28c446044acb5fc7ef7487b95b777b39c44.zip
rewrote sign-only code, also finally recognize sign-only emails in the list and allow opening them for verification
Diffstat (limited to 'src/org/thialfihar/android/apg/EncryptMessageActivity.java')
-rw-r--r--src/org/thialfihar/android/apg/EncryptMessageActivity.java18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/org/thialfihar/android/apg/EncryptMessageActivity.java b/src/org/thialfihar/android/apg/EncryptMessageActivity.java
index af2eac82d..b954f31a1 100644
--- a/src/org/thialfihar/android/apg/EncryptMessageActivity.java
+++ b/src/org/thialfihar/android/apg/EncryptMessageActivity.java
@@ -24,6 +24,7 @@ import java.security.NoSuchProviderException;
import java.security.SignatureException;
import java.util.Vector;
+import org.bouncycastle2.bcpg.HashAlgorithmTags;
import org.bouncycastle2.openpgp.PGPException;
import org.bouncycastle2.openpgp.PGPPublicKey;
import org.bouncycastle2.openpgp.PGPPublicKeyRing;
@@ -104,16 +105,9 @@ public class EncryptMessageActivity extends Activity
return;
} else {
String message = data.getString("message");
- String signature = data.getString("signature");
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/plain; charset=utf-8");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, message);
- if (signature != null) {
- String fullText = "-----BEGIN PGP SIGNED MESSAGE-----\n" +
- "Hash: SHA256\n" + "\n" +
- message + "\n" + signature;
- emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, fullText);
- }
if (mSubject != null) {
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
mSubject);
@@ -305,7 +299,9 @@ public class EncryptMessageActivity extends Activity
message = message.replaceAll(" +\n", "\n");
message = message.replaceAll("\n\n+", "\n\n");
message = message.replaceFirst("^\n+", "");
- message = message.replaceFirst("\n+$", "");
+ // make sure there'll be exactly one newline at the end
+ message = message.replaceFirst("\n*$", "\n");
+
ByteArrayInputStream in =
new ByteArrayInputStream(Strings.toUTF8ByteArray(message));
ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -316,9 +312,9 @@ public class EncryptMessageActivity extends Activity
Apg.getPassPhrase(), this);
data.putString("message", new String(out.toByteArray()));
} else {
- Apg.sign(in, out, mSignatureKeyId, Apg.getPassPhrase(), this);
- data.putString("message", message);
- data.putString("signature", new String(out.toByteArray()));
+ Apg.signText(in, out, mSignatureKeyId,
+ Apg.getPassPhrase(), HashAlgorithmTags.SHA256, this);
+ data.putString("message", new String(out.toByteArray()));
}
} catch (IOException e) {
error = e.getMessage();