aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/crypto/PgpEngine.java
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2014-03-08 00:31:29 +0100
committerDaniel Gultsch <daniel@gultsch.de>2014-03-08 00:31:29 +0100
commit5955da3519787bd2b0c6d5b1cc879137f4e946da (patch)
tree001c0957704e18480f99d471cd4500ad76aed870 /src/eu/siacs/conversations/crypto/PgpEngine.java
parent100059b530ad80f20a98c29af57c88d29c4eeabf (diff)
fixed a couple of pgp bugs
Diffstat (limited to 'src/eu/siacs/conversations/crypto/PgpEngine.java')
-rw-r--r--src/eu/siacs/conversations/crypto/PgpEngine.java17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/eu/siacs/conversations/crypto/PgpEngine.java b/src/eu/siacs/conversations/crypto/PgpEngine.java
index 5e480ae5..fa5a93b3 100644
--- a/src/eu/siacs/conversations/crypto/PgpEngine.java
+++ b/src/eu/siacs/conversations/crypto/PgpEngine.java
@@ -40,7 +40,6 @@ public class PgpEngine {
}
public String encrypt(long keyId, String message) {
- Log.d("xmppService","encrypt message: "+message+" for key "+keyId);
long[] keys = {keyId};
Intent params = new Intent();
params.setAction(OpenPgpApi.ACTION_ENCRYPT);
@@ -51,8 +50,6 @@ public class PgpEngine {
ByteArrayOutputStream os = new ByteArrayOutputStream();
Intent result = api.executeApi(params, is, os);
StringBuilder encryptedMessageBody = new StringBuilder();
- Log.d("xmppService","intent: "+result.toString());
- Log.d("xmppService","output: "+os.toString());
String[] lines = os.toString().split("\n");
for (int i = 3; i < lines.length - 1; ++i) {
encryptedMessageBody.append(lines[i].trim());
@@ -62,11 +59,15 @@ public class PgpEngine {
public long fetchKeyId(String status, String signature)
throws OpenPgpException {
+ if (signature==null) {
+ return 0;
+ }
+ if (status==null) {
+ status="";
+ }
StringBuilder pgpSig = new StringBuilder();
pgpSig.append("-----BEGIN PGP SIGNED MESSAGE-----");
pgpSig.append('\n');
- pgpSig.append("Hash: SHA1");
- pgpSig.append('\n');
pgpSig.append('\n');
pgpSig.append(status);
pgpSig.append('\n');
@@ -86,7 +87,11 @@ public class PgpEngine {
case OpenPgpApi.RESULT_CODE_SUCCESS:
OpenPgpSignatureResult sigResult
= result.getParcelableExtra(OpenPgpApi.RESULT_SIGNATURE);
- return sigResult.getKeyId();
+ if (sigResult==null) {
+ return 0;
+ } else {
+ return sigResult.getKeyId();
+ }
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
break;
case OpenPgpApi.RESULT_CODE_ERROR: