aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java4
-rw-r--r--OpenPGP-Keychain-API/libraries/keychain-api-library/src/org/openintents/openpgp/util/OpenPgpApi.java108
-rw-r--r--OpenPGP-Keychain/src/main/AndroidManifest.xml4
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java8
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/OpenPgpService.java14
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RemoteService.java2
6 files changed, 77 insertions, 63 deletions
diff --git a/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java b/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java
index 4d143ade6..a660b1c9a 100644
--- a/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java
+++ b/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java
@@ -202,7 +202,7 @@ public class OpenPgpProviderActivity extends Activity {
break;
}
case OpenPgpApi.RESULT_CODE_ERROR: {
- OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERRORS);
+ OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERROR);
handleError(error);
break;
}
@@ -234,7 +234,7 @@ public class OpenPgpProviderActivity extends Activity {
}
public void signAndEncrypt(Intent data) {
- data.setAction(OpenPgpApi.ACTION_SIGN_AND_ENCTYPT);
+ data.setAction(OpenPgpApi.ACTION_SIGN_AND_ENCRYPT);
data.putExtra(OpenPgpApi.EXTRA_USER_IDS, mEncryptUserIds.getText().toString().split(","));
data.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
diff --git a/OpenPGP-Keychain-API/libraries/keychain-api-library/src/org/openintents/openpgp/util/OpenPgpApi.java b/OpenPGP-Keychain-API/libraries/keychain-api-library/src/org/openintents/openpgp/util/OpenPgpApi.java
index ed1a7540a..f0eae4a47 100644
--- a/OpenPGP-Keychain-API/libraries/keychain-api-library/src/org/openintents/openpgp/util/OpenPgpApi.java
+++ b/OpenPGP-Keychain-API/libraries/keychain-api-library/src/org/openintents/openpgp/util/OpenPgpApi.java
@@ -16,101 +16,110 @@
package org.openintents.openpgp.util;
+import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Build;
import android.os.ParcelFileDescriptor;
import android.util.Log;
-
import org.openintents.openpgp.IOpenPgpService;
import org.openintents.openpgp.OpenPgpError;
-
import java.io.InputStream;
import java.io.OutputStream;
public class OpenPgpApi {
- //TODO: fix this documentation
+ public static final String TAG = "OpenPgp API";
+
+ public static final int API_VERSION = 2;
+ public static final String SERVICE_INTENT = "org.openintents.openpgp.IOpenPgpService";
+
/**
- * General extras
- * --------------
- *
- * Intent extras:
- * int api_version (required)
- * boolean ascii_armor (request ascii armor for ouput)
+ * Sign only
*
- * returned Bundle:
- * int result_code (0, 1, or 2 (see OpenPgpApi))
- * OpenPgpError error (if result_code == 0)
- * Intent intent (if result_code == 2)
+ * optional params:
+ * String EXTRA_PASSPHRASE (for key passphrase)
*/
+ public static final String ACTION_SIGN = "org.openintents.openpgp.action.SIGN";
/**
- * Sign only
+ * General extras
+ * --------------
*
- * optional params:
- * String passphrase (for key passphrase)
+ * Intent extras:
+ * int EXTRA_API_VERSION (required)
+ * boolean EXTRA_REQUEST_ASCII_ARMOR (request ascii armor for ouput)
+ *
+ * returned extras:
+ * int RESULT_CODE (0, 1, or 2 (see OpenPgpApi))
+ * OpenPgpError RESULT_ERROR (if result_code == 0)
+ * Intent RESULT_INTENT (if result_code == 2)
*/
/**
* Encrypt
*
- * Intent extras:
- * long[] key_ids
+ * extras:
+ * long[] EXTRA_KEY_IDS
* or
- * String[] user_ids (= emails of recipients) (if more than one key has this user_id, a PendingIntent is returned)
+ * String[] EXTRA_USER_IDS (= emails of recipients) (if more than one key has this user_id, a PendingIntent is returned)
*
* optional extras:
- * String passphrase (for key passphrase)
+ * String EXTRA_PASSPHRASE (for key passphrase)
*/
+ public static final String ACTION_ENCRYPT = "org.openintents.openpgp.action.ENCRYPT";
/**
* Sign and encrypt
*
- * Intent extras:
- * same as in encrypt()
+ * extras:
+ * long[] EXTRA_KEY_IDS
+ * or
+ * String[] EXTRA_USER_IDS (= emails of recipients) (if more than one key has this user_id, a PendingIntent is returned)
+ *
+ * optional extras:
+ * String EXTRA_PASSPHRASE (for key passphrase)
*/
+ public static final String ACTION_SIGN_AND_ENCRYPT = "org.openintents.openpgp.action.SIGN_AND_ENCRYPT";
/**
* Decrypts and verifies given input bytes. This methods handles encrypted-only, signed-and-encrypted,
* and also signed-only input.
*
- * returned Bundle:
- * OpenPgpSignatureResult signature_result
+ * returned extras:
+ * OpenPgpSignatureResult RESULT_SIGNATURE
*/
+ public static final String ACTION_DECRYPT_VERIFY = "org.openintents.openpgp.action.DECRYPT_VERIFY";
/**
- * Retrieves key ids based on given user ids (=emails)
+ * Get key ids based on given user ids (=emails)
*
* Intent extras:
- * String[] user_ids
+ * String[] EXTRA_KEY_IDS
*
- * returned Bundle:
- * long[] key_ids
+ * returned extras:
+ * long[] EXTRA_USER_IDS
*/
+ public static final String ACTION_GET_KEY_IDS = "org.openintents.openpgp.action.GET_KEY_IDS";
- public static final String TAG = "OpenPgp API";
-
- public static final int API_VERSION = 2;
- public static final String SERVICE_INTENT = "org.openintents.openpgp.IOpenPgpService";
-
- public static final String ACTION_SIGN = "org.openintents.openpgp.action.SIGN";
- public static final String ACTION_ENCRYPT = "org.openintents.openpgp.action.ENCRYPT";
- public static final String ACTION_SIGN_AND_ENCTYPT = "org.openintents.openpgp.action.SIGN_AND_ENCRYPT";
- public static final String ACTION_DECRYPT_VERIFY = "org.openintents.openpgp.action.DECRYPT_VERIFY";
+ /**
+ * Download keys from keyserver
+ *
+ * Intent extras:
+ * String[] EXTRA_KEY_IDS
+ */
public static final String ACTION_DOWNLOAD_KEYS = "org.openintents.openpgp.action.DOWNLOAD_KEYS";
- public static final String ACTION_GET_KEY_IDS = "org.openintents.openpgp.action.GET_KEY_IDS";
/* Bundle params */
public static final String EXTRA_API_VERSION = "api_version";
- // SIGN, ENCRYPT, SIGN_ENCRYPT, DECRYPT_VERIFY
+ // SIGN, ENCRYPT, SIGN_AND_ENCRYPT, DECRYPT_VERIFY
// request ASCII Armor for output
// OpenPGP Radix-64, 33 percent overhead compared to binary, see http://tools.ietf.org/html/rfc4880#page-53)
public static final String EXTRA_REQUEST_ASCII_ARMOR = "ascii_armor";
- // ENCRYPT, SIGN_ENCRYPT
+ // ENCRYPT, SIGN_AND_ENCRYPT
public static final String EXTRA_USER_IDS = "user_ids";
public static final String EXTRA_KEY_IDS = "key_ids";
// optional parameter:
@@ -118,17 +127,19 @@ public class OpenPgpApi {
/* Service Bundle returns */
public static final String RESULT_CODE = "result_code";
- public static final String RESULT_SIGNATURE = "signature";
- public static final String RESULT_ERRORS = "error";
- public static final String RESULT_INTENT = "intent";
- // get actual error object from RESULT_ERRORS
+ // get actual error object from RESULT_ERROR
public static final int RESULT_CODE_ERROR = 0;
// success!
public static final int RESULT_CODE_SUCCESS = 1;
// executeServiceMethod intent and do it again with intent
public static final int RESULT_CODE_USER_INTERACTION_REQUIRED = 2;
+ public static final String RESULT_ERROR = "error";
+ public static final String RESULT_INTENT = "intent";
+
+ // DECRYPT_VERIFY
+ public static final String RESULT_SIGNATURE = "signature";
IOpenPgpService mService;
Context mContext;
@@ -166,6 +177,7 @@ public class OpenPgpApi {
}
+ @TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void executeApiAsync(Intent data, InputStream is, OutputStream os, IOpenPgpCallback callback) {
OpenPgpAsyncTask task = new OpenPgpAsyncTask(data, is, os, callback);
@@ -188,13 +200,13 @@ public class OpenPgpApi {
result = mService.execute(data, null, null);
return result;
} else {
- // send the input and output pfds
+ // pipe the input and output
ParcelFileDescriptor input = ParcelFileDescriptorUtil.pipeFrom(is,
new ParcelFileDescriptorUtil.IThreadListener() {
@Override
public void onThreadFinished(Thread thread) {
- Log.d(OpenPgpApi.TAG, "Copy to service finished");
+ //Log.d(OpenPgpApi.TAG, "Copy to service finished");
}
});
ParcelFileDescriptor output = ParcelFileDescriptorUtil.pipeTo(os,
@@ -202,7 +214,7 @@ public class OpenPgpApi {
@Override
public void onThreadFinished(Thread thread) {
- Log.d(OpenPgpApi.TAG, "Service finished writing!");
+ //Log.d(OpenPgpApi.TAG, "Service finished writing!");
}
});
@@ -222,7 +234,7 @@ public class OpenPgpApi {
Log.e(OpenPgpApi.TAG, "Exception", e);
Intent result = new Intent();
result.putExtra(RESULT_CODE, RESULT_CODE_ERROR);
- result.putExtra(RESULT_ERRORS,
+ result.putExtra(RESULT_ERROR,
new OpenPgpError(OpenPgpError.CLIENT_SIDE_ERROR, e.getMessage()));
return result;
}
diff --git a/OpenPGP-Keychain/src/main/AndroidManifest.xml b/OpenPGP-Keychain/src/main/AndroidManifest.xml
index 10a307bfb..976b84e01 100644
--- a/OpenPGP-Keychain/src/main/AndroidManifest.xml
+++ b/OpenPGP-Keychain/src/main/AndroidManifest.xml
@@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.sufficientlysecure.keychain"
android:installLocation="auto"
- android:versionCode="23102"
- android:versionName="2.3.1 beta2">
+ android:versionCode="23103"
+ android:versionName="2.3.1 beta3">
<!--
General remarks
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java
index c568f462a..ccd6ff8df 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java
@@ -335,7 +335,7 @@ public class PgpDecryptVerify {
currentProgress += 5;
updateProgress(R.string.progress_extracting_key, currentProgress, 100);
- PGPPrivateKey privateKey = null;
+ PGPPrivateKey privateKey;
try {
PBESecretKeyDecryptor keyDecryptor = new JcePBESecretKeyDecryptorBuilder()
.setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(
@@ -593,6 +593,8 @@ public class PgpDecryptVerify {
if (signature == null) {
signatureResult.setStatus(OpenPgpSignatureResult.SIGNATURE_UNKNOWN_PUB_KEY);
+ returnData.setSignatureResult(signatureResult);
+
updateProgress(R.string.progress_done, 100, 100);
return returnData;
}
@@ -630,9 +632,9 @@ public class PgpDecryptVerify {
// TODO: what about SIGNATURE_SUCCESS_CERTIFIED and SIGNATURE_ERROR????
- updateProgress(R.string.progress_done, 100, 100);
-
returnData.setSignatureResult(signatureResult);
+
+ updateProgress(R.string.progress_done, 100, 100);
return returnData;
}
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/OpenPgpService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/OpenPgpService.java
index 8b34c4421..e1801d9e7 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/OpenPgpService.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/OpenPgpService.java
@@ -180,7 +180,7 @@ public class OpenPgpService extends RemoteService {
} catch (Exception e) {
Intent result = new Intent();
result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR);
- result.putExtra(OpenPgpApi.RESULT_ERRORS,
+ result.putExtra(OpenPgpApi.RESULT_ERROR,
new OpenPgpError(OpenPgpError.GENERIC_ERROR, e.getMessage()));
return result;
}
@@ -209,7 +209,7 @@ public class OpenPgpService extends RemoteService {
} else {
Intent result = new Intent();
result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR);
- result.putExtra(OpenPgpApi.RESULT_ERRORS,
+ result.putExtra(OpenPgpApi.RESULT_ERROR,
new OpenPgpError(OpenPgpError.GENERIC_ERROR, "Missing parameter user_ids or key_ids!"));
return result;
}
@@ -268,7 +268,7 @@ public class OpenPgpService extends RemoteService {
} catch (Exception e) {
Intent result = new Intent();
result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR);
- result.putExtra(OpenPgpApi.RESULT_ERRORS,
+ result.putExtra(OpenPgpApi.RESULT_ERROR,
new OpenPgpError(OpenPgpError.GENERIC_ERROR, e.getMessage()));
return result;
}
@@ -334,7 +334,7 @@ public class OpenPgpService extends RemoteService {
} catch (Exception e) {
Intent result = new Intent();
result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR);
- result.putExtra(OpenPgpApi.RESULT_ERRORS,
+ result.putExtra(OpenPgpApi.RESULT_ERROR,
new OpenPgpError(OpenPgpError.GENERIC_ERROR, e.getMessage()));
return result;
}
@@ -361,7 +361,7 @@ public class OpenPgpService extends RemoteService {
if (data == null) {
Intent result = new Intent();
OpenPgpError error = new OpenPgpError(OpenPgpError.GENERIC_ERROR, "params Bundle required!");
- result.putExtra(OpenPgpApi.RESULT_ERRORS, error);
+ result.putExtra(OpenPgpApi.RESULT_ERROR, error);
result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR);
return result;
}
@@ -370,7 +370,7 @@ public class OpenPgpService extends RemoteService {
if (data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1) != OpenPgpApi.API_VERSION) {
Intent result = new Intent();
OpenPgpError error = new OpenPgpError(OpenPgpError.INCOMPATIBLE_API_VERSIONS, "Incompatible API versions!");
- result.putExtra(OpenPgpApi.RESULT_ERRORS, error);
+ result.putExtra(OpenPgpApi.RESULT_ERROR, error);
result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR);
return result;
}
@@ -401,7 +401,7 @@ public class OpenPgpService extends RemoteService {
return signImpl(data, input, output, appSettings);
} else if (OpenPgpApi.ACTION_ENCRYPT.equals(action)) {
return encryptAndSignImpl(data, input, output, appSettings, false);
- } else if (OpenPgpApi.ACTION_SIGN_AND_ENCTYPT.equals(action)) {
+ } else if (OpenPgpApi.ACTION_SIGN_AND_ENCRYPT.equals(action)) {
return encryptAndSignImpl(data, input, output, appSettings, true);
} else if (OpenPgpApi.ACTION_DECRYPT_VERIFY.equals(action)) {
return decryptAndVerifyImpl(data, input, output, appSettings);
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RemoteService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RemoteService.java
index e7b3b2945..cb556be39 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RemoteService.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RemoteService.java
@@ -72,7 +72,7 @@ public abstract class RemoteService extends Service {
// return error
Intent result = new Intent();
result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR);
- result.putExtra(OpenPgpApi.RESULT_ERRORS,
+ result.putExtra(OpenPgpApi.RESULT_ERROR,
new OpenPgpError(OpenPgpError.GENERIC_ERROR, e.getMessage()));
return result;
}