aboutsummaryrefslogtreecommitdiffstats
path: root/APG/src
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2012-12-12 19:14:09 +0100
committerDominik Schürmann <dominik@dominikschuermann.de>2012-12-12 19:14:09 +0100
commit2dcaad3d3b6f8757f01e4abd2295431f24cdfed5 (patch)
tree66f3d65e1e1e4e30ad6aa3ebe8e8eee5816cc15b /APG/src
parente3fea30abe9f9f16dbfa5e989e7058842b085b7e (diff)
downloadopen-keychain-2dcaad3d3b6f8757f01e4abd2295431f24cdfed5.tar.gz
open-keychain-2dcaad3d3b6f8757f01e4abd2295431f24cdfed5.tar.bz2
open-keychain-2dcaad3d3b6f8757f01e4abd2295431f24cdfed5.zip
API changes
Diffstat (limited to 'APG/src')
-rw-r--r--APG/src/org/thialfihar/android/apg/service/ApgIntentService.java121
-rw-r--r--APG/src/org/thialfihar/android/apg/service/ApgService.java84
-rw-r--r--APG/src/org/thialfihar/android/apg/service/IApgDecryptVerifyHandler.aidl (renamed from APG/src/org/thialfihar/android/apg/service/IApgEncryptDecryptHandler.aidl)10
-rw-r--r--APG/src/org/thialfihar/android/apg/service/IApgEncryptSignHandler.aidl (renamed from APG/src/org/thialfihar/android/apg/service/IApgSignVerifyHandler.aidl)11
-rw-r--r--APG/src/org/thialfihar/android/apg/service/IApgService.aidl16
-rw-r--r--APG/src/org/thialfihar/android/apg/ui/DecryptActivity.java30
-rw-r--r--APG/src/org/thialfihar/android/apg/ui/EditKeyActivity.java39
-rw-r--r--APG/src/org/thialfihar/android/apg/ui/EncryptActivity.java38
-rw-r--r--APG/src/org/thialfihar/android/apg/ui/KeyListActivity.java4
-rw-r--r--APG/src/org/thialfihar/android/apg/ui/widget/SectionView.java8
10 files changed, 194 insertions, 167 deletions
diff --git a/APG/src/org/thialfihar/android/apg/service/ApgIntentService.java b/APG/src/org/thialfihar/android/apg/service/ApgIntentService.java
index b50cb1789..e738b4193 100644
--- a/APG/src/org/thialfihar/android/apg/service/ApgIntentService.java
+++ b/APG/src/org/thialfihar/android/apg/service/ApgIntentService.java
@@ -98,37 +98,37 @@ public class ApgIntentService extends IntentService implements ProgressDialogUpd
public static final int TARGET_STREAM = 3;
// encrypt
- public static final String SECRET_KEY_ID = "secretKeyId";
- public static final String USE_ASCII_AMOR = "useAsciiAmor";
- public static final String ENCRYPTION_KEYS_IDS = "encryptionKeysIds";
- public static final String COMPRESSION_ID = "compressionId";
- public static final String GENERATE_SIGNATURE = "generateSignature";
- public static final String SIGN_ONLY = "signOnly";
- public static final String MESSAGE_BYTES = "messageBytes";
- public static final String INPUT_FILE = "inputFile";
- public static final String OUTPUT_FILE = "outputFile";
- public static final String PROVIDER_URI = "providerUri";
+ public static final String ENCRYPT_SECRET_KEY_ID = "secretKeyId";
+ public static final String ENCRYPT_USE_ASCII_AMOR = "useAsciiAmor";
+ public static final String ENCRYPT_ENCRYPTION_KEYS_IDS = "encryptionKeysIds";
+ public static final String ENCRYPT_COMPRESSION_ID = "compressionId";
+ public static final String ENCRYPT_GENERATE_SIGNATURE = "generateSignature";
+ public static final String ENCRYPT_SIGN_ONLY = "signOnly";
+ public static final String ENCRYPT_MESSAGE_BYTES = "messageBytes";
+ public static final String ENCRYPT_INPUT_FILE = "inputFile";
+ public static final String ENCRYPT_OUTPUT_FILE = "outputFile";
+ public static final String ENCRYPT_PROVIDER_URI = "providerUri";
// decrypt/verify
- public static final String SIGNED_ONLY = "signedOnly";
- public static final String RETURN_BYTES = "returnBinary";
- public static final String CIPHERTEXT_BYTES = "ciphertextBytes";
- public static final String ASSUME_SYMMETRIC = "assumeSymmetric";
- public static final String LOOKUP_UNKNOWN_KEY = "lookupUnknownKey";
-
- // edit keys
- public static final String NEW_PASSPHRASE = "newPassphrase";
- public static final String CURRENT_PASSPHRASE = "currentPassphrase";
- public static final String USER_IDS = "userIds";
- public static final String KEYS = "keys";
- public static final String KEYS_USAGES = "keysUsages";
- public static final String MASTER_KEY_ID = "masterKeyId";
+ public static final String DECRYPT_SIGNED_ONLY = "signedOnly";
+ public static final String DECRYPT_RETURN_BYTES = "returnBinary";
+ public static final String DECRYPT_CIPHERTEXT_BYTES = "ciphertextBytes";
+ public static final String DECRYPT_ASSUME_SYMMETRIC = "assumeSymmetric";
+ public static final String DECRYPT_LOOKUP_UNKNOWN_KEY = "lookupUnknownKey";
+
+ // save keyring
+ public static final String SAVE_KEYRING_NEW_PASSPHRASE = "newPassphrase";
+ public static final String SAVE_KEYRING_CURRENT_PASSPHRASE = "currentPassphrase";
+ public static final String SAVE_KEYRING_USER_IDS = "userIds";
+ public static final String SAVE_KEYRING_KEYS = "keys";
+ public static final String SAVE_KEYRING_KEYS_USAGES = "keysUsages";
+ public static final String SAVE_KEYRING_MASTER_KEY_ID = "masterKeyId";
// generate key
- public static final String ALGORITHM = "algorithm";
- public static final String KEY_SIZE = "keySize";
- public static final String SYMMETRIC_PASSPHRASE = "passphrase";
- public static final String MASTER_KEY = "masterKey";
+ public static final String GENERATE_KEY_ALGORITHM = "algorithm";
+ public static final String GENERATE_KEY_KEY_SIZE = "keySize";
+ public static final String GENERATE_KEY_SYMMETRIC_PASSPHRASE = "passphrase";
+ public static final String GENERATE_KEY_MASTER_KEY = "masterKey";
// delete file securely
public static final String DELETE_FILE = "deleteFile";
@@ -238,14 +238,14 @@ public class ApgIntentService extends IntentService implements ProgressDialogUpd
/* Input */
int target = data.getInt(TARGET);
- long secretKeyId = data.getLong(SECRET_KEY_ID);
- String encryptionPassphrase = data.getString(SYMMETRIC_PASSPHRASE);
+ long secretKeyId = data.getLong(ENCRYPT_SECRET_KEY_ID);
+ String encryptionPassphrase = data.getString(GENERATE_KEY_SYMMETRIC_PASSPHRASE);
- boolean useAsciiArmor = data.getBoolean(USE_ASCII_AMOR);
- long encryptionKeyIds[] = data.getLongArray(ENCRYPTION_KEYS_IDS);
- int compressionId = data.getInt(COMPRESSION_ID);
- boolean generateSignature = data.getBoolean(GENERATE_SIGNATURE);
- boolean signOnly = data.getBoolean(SIGN_ONLY);
+ boolean useAsciiArmor = data.getBoolean(ENCRYPT_USE_ASCII_AMOR);
+ long encryptionKeyIds[] = data.getLongArray(ENCRYPT_ENCRYPTION_KEYS_IDS);
+ int compressionId = data.getInt(ENCRYPT_COMPRESSION_ID);
+ boolean generateSignature = data.getBoolean(ENCRYPT_GENERATE_SIGNATURE);
+ boolean signOnly = data.getBoolean(ENCRYPT_SIGN_ONLY);
InputStream inStream = null;
long inLength = -1;
@@ -254,7 +254,7 @@ public class ApgIntentService extends IntentService implements ProgressDialogUpd
String streamFilename = null;
switch (target) {
case TARGET_BYTES: /* encrypting bytes directly */
- byte[] bytes = data.getByteArray(MESSAGE_BYTES);
+ byte[] bytes = data.getByteArray(ENCRYPT_MESSAGE_BYTES);
inStream = new ByteArrayInputStream(bytes);
inLength = bytes.length;
@@ -264,8 +264,8 @@ public class ApgIntentService extends IntentService implements ProgressDialogUpd
break;
case TARGET_FILE: /* encrypting file */
- String inputFile = data.getString(INPUT_FILE);
- String outputFile = data.getString(OUTPUT_FILE);
+ String inputFile = data.getString(ENCRYPT_INPUT_FILE);
+ String outputFile = data.getString(ENCRYPT_OUTPUT_FILE);
// check if storage is ready
if (!FileHelper.isStorageMounted(inputFile)
@@ -284,7 +284,7 @@ public class ApgIntentService extends IntentService implements ProgressDialogUpd
break;
case TARGET_STREAM: /* Encrypting stream from content uri */
- Uri providerUri = (Uri) data.getParcelable(PROVIDER_URI);
+ Uri providerUri = (Uri) data.getParcelable(ENCRYPT_PROVIDER_URI);
// InputStream
InputStream in = getContentResolver().openInputStream(providerUri);
@@ -390,13 +390,13 @@ public class ApgIntentService extends IntentService implements ProgressDialogUpd
/* Input */
int target = data.getInt(TARGET);
- long secretKeyId = data.getLong(SECRET_KEY_ID);
- byte[] bytes = data.getByteArray(CIPHERTEXT_BYTES);
- boolean signedOnly = data.getBoolean(SIGNED_ONLY);
- boolean returnBytes = data.getBoolean(RETURN_BYTES);
- boolean assumeSymmetricEncryption = data.getBoolean(ASSUME_SYMMETRIC);
+ long secretKeyId = data.getLong(ENCRYPT_SECRET_KEY_ID);
+ byte[] bytes = data.getByteArray(DECRYPT_CIPHERTEXT_BYTES);
+ boolean signedOnly = data.getBoolean(DECRYPT_SIGNED_ONLY);
+ boolean returnBytes = data.getBoolean(DECRYPT_RETURN_BYTES);
+ boolean assumeSymmetricEncryption = data.getBoolean(DECRYPT_ASSUME_SYMMETRIC);
- boolean lookupUnknownKey = data.getBoolean(LOOKUP_UNKNOWN_KEY);
+ boolean lookupUnknownKey = data.getBoolean(DECRYPT_LOOKUP_UNKNOWN_KEY);
InputStream inStream = null;
long inLength = -1;
@@ -414,8 +414,8 @@ public class ApgIntentService extends IntentService implements ProgressDialogUpd
break;
case TARGET_FILE: /* decrypting file */
- String inputFile = data.getString(INPUT_FILE);
- String outputFile = data.getString(OUTPUT_FILE);
+ String inputFile = data.getString(ENCRYPT_INPUT_FILE);
+ String outputFile = data.getString(ENCRYPT_OUTPUT_FILE);
// check if storage is ready
if (!FileHelper.isStorageMounted(inputFile)
@@ -437,7 +437,7 @@ public class ApgIntentService extends IntentService implements ProgressDialogUpd
break;
case TARGET_STREAM: /* decrypting stream from content uri */
- Uri providerUri = (Uri) data.getParcelable(PROVIDER_URI);
+ Uri providerUri = (Uri) data.getParcelable(ENCRYPT_PROVIDER_URI);
// InputStream
InputStream in = getContentResolver().openInputStream(providerUri);
@@ -521,16 +521,16 @@ public class ApgIntentService extends IntentService implements ProgressDialogUpd
try {
/* Input */
- String oldPassPhrase = data.getString(CURRENT_PASSPHRASE);
- String newPassPhrase = data.getString(NEW_PASSPHRASE);
+ String oldPassPhrase = data.getString(SAVE_KEYRING_CURRENT_PASSPHRASE);
+ String newPassPhrase = data.getString(SAVE_KEYRING_NEW_PASSPHRASE);
if (newPassPhrase == null) {
newPassPhrase = oldPassPhrase;
}
- ArrayList<String> userIds = data.getStringArrayList(USER_IDS);
+ ArrayList<String> userIds = data.getStringArrayList(SAVE_KEYRING_USER_IDS);
ArrayList<PGPSecretKey> keys = PGPConversionHelper.BytesToPGPSecretKeyList(data
- .getByteArray(KEYS));
- ArrayList<Integer> keysUsages = data.getIntegerArrayList(KEYS_USAGES);
- long masterKeyId = data.getLong(MASTER_KEY_ID);
+ .getByteArray(SAVE_KEYRING_KEYS));
+ ArrayList<Integer> keysUsages = data.getIntegerArrayList(SAVE_KEYRING_KEYS_USAGES);
+ long masterKeyId = data.getLong(SAVE_KEYRING_MASTER_KEY_ID);
/* Operation */
PGPMain.buildSecretKey(this, userIds, keys, keysUsages, masterKeyId, oldPassPhrase,
@@ -549,13 +549,13 @@ public class ApgIntentService extends IntentService implements ProgressDialogUpd
try {
/* Input */
- int algorithm = data.getInt(ALGORITHM);
- String passphrase = data.getString(SYMMETRIC_PASSPHRASE);
- int keysize = data.getInt(KEY_SIZE);
+ int algorithm = data.getInt(GENERATE_KEY_ALGORITHM);
+ String passphrase = data.getString(GENERATE_KEY_SYMMETRIC_PASSPHRASE);
+ int keysize = data.getInt(GENERATE_KEY_KEY_SIZE);
PGPSecretKey masterKey = null;
- if (data.containsKey(MASTER_KEY)) {
+ if (data.containsKey(GENERATE_KEY_MASTER_KEY)) {
masterKey = PGPConversionHelper.BytesToPGPSecretKey(data
- .getByteArray(MASTER_KEY));
+ .getByteArray(GENERATE_KEY_MASTER_KEY));
}
/* Operation */
@@ -580,7 +580,7 @@ public class ApgIntentService extends IntentService implements ProgressDialogUpd
// generate one RSA 2048 key for signing and one subkey for encrypting!
try {
/* Input */
- String passphrase = data.getString(SYMMETRIC_PASSPHRASE);
+ String passphrase = data.getString(GENERATE_KEY_SYMMETRIC_PASSPHRASE);
/* Operation */
PGPSecretKeyRing masterKeyRing = PGPMain.createKey(this, Id.choice.algorithm.rsa,
@@ -739,7 +739,8 @@ public class ApgIntentService extends IntentService implements ProgressDialogUpd
/* Operation */
HkpKeyServer server = new HkpKeyServer(keyServer);
- PGPPublicKeyRing keyring = ProviderHelper.getPGPPublicKeyRingByRowId(this, keyRingRowId);
+ PGPPublicKeyRing keyring = ProviderHelper.getPGPPublicKeyRingByRowId(this,
+ keyRingRowId);
if (keyring != null) {
boolean uploaded = PGPMain.uploadKeyRingToServer(server,
(PGPPublicKeyRing) keyring);
diff --git a/APG/src/org/thialfihar/android/apg/service/ApgService.java b/APG/src/org/thialfihar/android/apg/service/ApgService.java
index 9e618b545..a94887ba4 100644
--- a/APG/src/org/thialfihar/android/apg/service/ApgService.java
+++ b/APG/src/org/thialfihar/android/apg/service/ApgService.java
@@ -76,27 +76,27 @@ public class ApgService extends Service {
}
}
- void encryptAndSignImplementation(byte[] inputBytes, String inputUri, boolean useAsciiArmor,
- int compression, long[] encryptionKeyIds, String encryptionPassphrase,
- int symmetricEncryptionAlgorithm, long signatureKeyId, int signatureHashAlgorithm,
- boolean signatureForceV3, String signaturePassphrase, IApgEncryptDecryptHandler handler)
- throws RemoteException {
+ private void encryptAndSignImplementation(byte[] inputBytes, String inputUri,
+ boolean useAsciiArmor, int compression, long[] encryptionKeyIds,
+ String encryptionPassphrase, int symmetricEncryptionAlgorithm, long signatureKeyId,
+ int signatureHashAlgorithm, boolean signatureForceV3, String signaturePassphrase,
+ IApgEncryptSignHandler handler) throws RemoteException {
try {
// TODO use inputUri
-
-// InputStream inStream = null;
-// if (isBlob) {
-// ContentResolver cr = getContentResolver();
-// try {
-// inStream = cr.openInputStream(Uri.parse(pArgs.getString(arg.BLOB.name())));
-// } catch (Exception e) {
-// Log.e(TAG, "... exception on opening blob", e);
-// }
-// } else {
-// inStream = new ByteArrayInputStream(pArgs.getString(arg.MESSAGE.name()).getBytes());
-// }
-// InputData in = new InputData(inStream, 0); // XXX Size second param?
+
+ // InputStream inStream = null;
+ // if (isBlob) {
+ // ContentResolver cr = getContentResolver();
+ // try {
+ // inStream = cr.openInputStream(Uri.parse(pArgs.getString(arg.BLOB.name())));
+ // } catch (Exception e) {
+ // Log.e(TAG, "... exception on opening blob", e);
+ // }
+ // } else {
+ // inStream = new ByteArrayInputStream(pArgs.getString(arg.MESSAGE.name()).getBytes());
+ // }
+ // InputData in = new InputData(inStream, 0); // XXX Size second param?
// build InputData and write into OutputStream
InputStream inputStream = new ByteArrayInputStream(inputBytes);
@@ -110,20 +110,20 @@ public class ApgService extends Service {
signatureKeyId, signatureHashAlgorithm, signatureForceV3, signaturePassphrase);
output.close();
-
-// if (isBlob) {
-// ContentResolver cr = getContentResolver();
-// try {
-// OutputStream outStream = cr.openOutputStream(Uri.parse(pArgs.getString(arg.BLOB
-// .name())));
-// writeToOutputStream(new ByteArrayInputStream(out.toString().getBytes()), outStream);
-// outStream.close();
-// } catch (Exception e) {
-// Log.e(TAG, "... exception on writing blob", e);
-// }
-// } else {
-// pReturn.putString(ret.RESULT.name(), out.toString());
-// }
+
+ // if (isBlob) {
+ // ContentResolver cr = getContentResolver();
+ // try {
+ // OutputStream outStream = cr.openOutputStream(Uri.parse(pArgs.getString(arg.BLOB
+ // .name())));
+ // writeToOutputStream(new ByteArrayInputStream(out.toString().getBytes()), outStream);
+ // outStream.close();
+ // } catch (Exception e) {
+ // Log.e(TAG, "... exception on writing blob", e);
+ // }
+ // } else {
+ // pReturn.putString(ret.RESULT.name(), out.toString());
+ // }
byte[] outputBytes = ((ByteArrayOutputStream) output).toByteArray();
@@ -140,8 +140,8 @@ public class ApgService extends Service {
}
}
- public void decryptAndVerifyImplementation(byte[] inputBytes, String inputUri,
- String passphrase, boolean assumeSymmetric, IApgEncryptDecryptHandler handler)
+ private void decryptAndVerifyImplementation(byte[] inputBytes, String inputUri,
+ String passphrase, boolean assumeSymmetric, IApgDecryptVerifyHandler handler)
throws RemoteException {
try {
@@ -232,7 +232,7 @@ public class ApgService extends Service {
@Override
public void encryptAsymmetric(byte[] inputBytes, String inputUri, boolean useAsciiArmor,
int compression, long[] encryptionKeyIds, int symmetricEncryptionAlgorithm,
- IApgEncryptDecryptHandler handler) throws RemoteException {
+ IApgEncryptSignHandler handler) throws RemoteException {
encryptAndSignImplementation(inputBytes, inputUri, useAsciiArmor, compression,
encryptionKeyIds, null, symmetricEncryptionAlgorithm, Id.key.none, 0, false,
@@ -242,7 +242,7 @@ public class ApgService extends Service {
@Override
public void encryptSymmetric(byte[] inputBytes, String inputUri, boolean useAsciiArmor,
int compression, String encryptionPassphrase, int symmetricEncryptionAlgorithm,
- IApgEncryptDecryptHandler handler) throws RemoteException {
+ IApgEncryptSignHandler handler) throws RemoteException {
encryptAndSignImplementation(inputBytes, inputUri, useAsciiArmor, compression, null,
encryptionPassphrase, symmetricEncryptionAlgorithm, Id.key.none, 0, false,
@@ -253,8 +253,8 @@ public class ApgService extends Service {
public void encryptAndSignAsymmetric(byte[] inputBytes, String inputUri,
boolean useAsciiArmor, int compression, long[] encryptionKeyIds,
int symmetricEncryptionAlgorithm, long signatureKeyId, int signatureHashAlgorithm,
- boolean signatureForceV3, String signaturePassphrase,
- IApgEncryptDecryptHandler handler) throws RemoteException {
+ boolean signatureForceV3, String signaturePassphrase, IApgEncryptSignHandler handler)
+ throws RemoteException {
encryptAndSignImplementation(inputBytes, inputUri, useAsciiArmor, compression,
encryptionKeyIds, null, symmetricEncryptionAlgorithm, signatureKeyId,
@@ -265,8 +265,8 @@ public class ApgService extends Service {
public void encryptAndSignSymmetric(byte[] inputBytes, String inputUri,
boolean useAsciiArmor, int compression, String encryptionPassphrase,
int symmetricEncryptionAlgorithm, long signatureKeyId, int signatureHashAlgorithm,
- boolean signatureForceV3, String signaturePassphrase,
- IApgEncryptDecryptHandler handler) throws RemoteException {
+ boolean signatureForceV3, String signaturePassphrase, IApgEncryptSignHandler handler)
+ throws RemoteException {
encryptAndSignImplementation(inputBytes, inputUri, useAsciiArmor, compression, null,
encryptionPassphrase, symmetricEncryptionAlgorithm, signatureKeyId,
@@ -275,14 +275,14 @@ public class ApgService extends Service {
@Override
public void decryptAndVerifyAsymmetric(byte[] inputBytes, String inputUri,
- String keyPassphrase, IApgEncryptDecryptHandler handler) throws RemoteException {
+ String keyPassphrase, IApgDecryptVerifyHandler handler) throws RemoteException {
decryptAndVerifyImplementation(inputBytes, inputUri, keyPassphrase, false, handler);
}
@Override
public void decryptAndVerifySymmetric(byte[] inputBytes, String inputUri,
- String encryptionPassphrase, IApgEncryptDecryptHandler handler)
+ String encryptionPassphrase, IApgDecryptVerifyHandler handler)
throws RemoteException {
decryptAndVerifyImplementation(inputBytes, inputUri, encryptionPassphrase, true,
diff --git a/APG/src/org/thialfihar/android/apg/service/IApgEncryptDecryptHandler.aidl b/APG/src/org/thialfihar/android/apg/service/IApgDecryptVerifyHandler.aidl
index 318e5f344..ad74340bf 100644
--- a/APG/src/org/thialfihar/android/apg/service/IApgEncryptDecryptHandler.aidl
+++ b/APG/src/org/thialfihar/android/apg/service/IApgDecryptVerifyHandler.aidl
@@ -16,17 +16,15 @@
package org.thialfihar.android.apg.service;
-interface IApgEncryptDecryptHandler {
- /**
- * Either output or streamUri is given. One of them is null
- *
- */
- oneway void onSuccessEncrypt(in byte[] outputBytes, in String outputUri);
+interface IApgDecryptVerifyHandler {
oneway void onSuccessDecrypt(in byte[] outputBytes, in String outputUri, in boolean signature,
in long signatureKeyId, in String signatureUserId, in boolean signatureSuccess,
in boolean signatureUnknown);
+ oneway void onSuccessVerify(in boolean signature, in long signatureKeyId,
+ in String signatureUserId, in boolean signatureSuccess, in boolean signatureUnknown);
+
oneway void onException(in int exceptionNumber, in String message);
} \ No newline at end of file
diff --git a/APG/src/org/thialfihar/android/apg/service/IApgSignVerifyHandler.aidl b/APG/src/org/thialfihar/android/apg/service/IApgEncryptSignHandler.aidl
index cc854e540..ea3e2ae86 100644
--- a/APG/src/org/thialfihar/android/apg/service/IApgSignVerifyHandler.aidl
+++ b/APG/src/org/thialfihar/android/apg/service/IApgEncryptSignHandler.aidl
@@ -16,11 +16,14 @@
package org.thialfihar.android.apg.service;
-interface IApgSignVerifyHandler {
- oneway void onSuccessSign(in byte[] outputBytes, in String outputUri);
+interface IApgEncryptSignHandler {
+ /**
+ * Either output or streamUri is given. One of them is null
+ *
+ */
+ oneway void onSuccessEncrypt(in byte[] outputBytes, in String outputUri);
- oneway void onSuccessVerify(in boolean signature, in long signatureKeyId,
- in String signatureUserId, in boolean signatureSuccess, in boolean signatureUnknown);
+ oneway void onSuccessSign(in byte[] outputBytes, in String outputUri);
oneway void onException(in int exceptionNumber, in String message);
diff --git a/APG/src/org/thialfihar/android/apg/service/IApgService.aidl b/APG/src/org/thialfihar/android/apg/service/IApgService.aidl
index 7753d1e3d..98c08c62b 100644
--- a/APG/src/org/thialfihar/android/apg/service/IApgService.aidl
+++ b/APG/src/org/thialfihar/android/apg/service/IApgService.aidl
@@ -16,8 +16,8 @@
package org.thialfihar.android.apg.service;
-import org.thialfihar.android.apg.service.IApgEncryptDecryptHandler;
-import org.thialfihar.android.apg.service.IApgSignVerifyHandler;
+import org.thialfihar.android.apg.service.IApgEncryptSignHandler;
+import org.thialfihar.android.apg.service.IApgDecryptVerifyHandler;
import org.thialfihar.android.apg.service.IApgHelperHandler;
/**
@@ -50,7 +50,7 @@ interface IApgService {
*/
oneway void encryptAsymmetric(in byte[] inputBytes, in String inputUri, in boolean useAsciiArmor,
in int compression, in long[] encryptionKeyIds, in int symmetricEncryptionAlgorithm,
- in IApgEncryptDecryptHandler handler);
+ in IApgEncryptSignHandler handler);
/**
* Same as encryptAsymmetric but using a passphrase for symmetric encryption
@@ -60,7 +60,7 @@ interface IApgService {
*/
oneway void encryptSymmetric(in byte[] inputBytes, in String inputUri, in boolean useAsciiArmor,
in int compression, in String encryptionPassphrase, in int symmetricEncryptionAlgorithm,
- in IApgEncryptDecryptHandler handler);
+ in IApgEncryptSignHandler handler);
/**
* Encrypt and sign
@@ -97,7 +97,7 @@ interface IApgService {
in boolean useAsciiArmor, in int compression, in long[] encryptionKeyIds,
in int symmetricEncryptionAlgorithm, in long signatureKeyId, in int signatureHashAlgorithm,
in boolean signatureForceV3, in String signaturePassphrase,
- in IApgEncryptDecryptHandler handler);
+ in IApgEncryptSignHandler handler);
/**
* Same as encryptAndSignAsymmetric but using a passphrase for symmetric encryption
@@ -109,7 +109,7 @@ interface IApgService {
in boolean useAsciiArmor, in int compression, in String encryptionPassphrase,
in int symmetricEncryptionAlgorithm, in long signatureKeyId, in int signatureHashAlgorithm,
in boolean signatureForceV3, in String signaturePassphrase,
- in IApgEncryptDecryptHandler handler);
+ in IApgEncryptSignHandler handler);
/**
* Decrypts and verifies given input bytes. If no signature is present this method
@@ -125,7 +125,7 @@ interface IApgService {
* Handler where to return results to after successful encryption
*/
oneway void decryptAndVerifyAsymmetric(in byte[] inputBytes, in String inputUri,
- in String keyPassphrase, in IApgEncryptDecryptHandler handler);
+ in String keyPassphrase, in IApgDecryptVerifyHandler handler);
/**
* Same as decryptAndVerifyAsymmetric but for symmetric decryption.
@@ -134,7 +134,7 @@ interface IApgService {
* Passphrase to decrypt
*/
oneway void decryptAndVerifySymmetric(in byte[] inputBytes, in String inputUri,
- in String encryptionPassphrase, in IApgEncryptDecryptHandler handler);
+ in String encryptionPassphrase, in IApgDecryptVerifyHandler handler);
/**
*
diff --git a/APG/src/org/thialfihar/android/apg/ui/DecryptActivity.java b/APG/src/org/thialfihar/android/apg/ui/DecryptActivity.java
index 21e75f7ea..3c4911420 100644
--- a/APG/src/org/thialfihar/android/apg/ui/DecryptActivity.java
+++ b/APG/src/org/thialfihar/android/apg/ui/DecryptActivity.java
@@ -68,16 +68,18 @@ import java.util.regex.Matcher;
public class DecryptActivity extends SherlockFragmentActivity {
- // possible intent actions for this activity
+ /* Intents */
+ // without permission
public static final String ACTION_DECRYPT = Constants.INTENT_PREFIX + "DECRYPT";
+ public static final String ACTION_DECRYPT_FILE = Constants.INTENT_PREFIX + "DECRYPT_FILE";
+
+ // with permission
public static final String ACTION_DECRYPT_AND_RETURN = Constants.INTENT_PREFIX
+ "DECRYPT_AND_RETURN";
-
- public static final String ACTION_DECRYPT_FILE = Constants.INTENT_PREFIX + "DECRYPT_FILE";
public static final String ACTION_DECRYPT_STREAM_AND_RETURN = Constants.INTENT_PREFIX
+ "DECRYPT_STREAM_AND_RETURN";
- // possible extra keys
+ /* EXTRA keys for input */
public static final String EXTRA_TEXT = "text";
public static final String EXTRA_DATA = "data";
public static final String EXTRA_REPLY_TO = "replyTo";
@@ -755,32 +757,32 @@ public class DecryptActivity extends SherlockFragmentActivity {
if (mContentUri != null) {
data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_STREAM);
- data.putParcelable(ApgIntentService.PROVIDER_URI, mContentUri);
+ data.putParcelable(ApgIntentService.ENCRYPT_PROVIDER_URI, mContentUri);
} else if (mDecryptTarget == Id.target.file) {
data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_FILE);
Log.d(Constants.TAG, "mInputFilename=" + mInputFilename + ", mOutputFilename="
+ mOutputFilename);
- data.putString(ApgIntentService.INPUT_FILE, mInputFilename);
- data.putString(ApgIntentService.OUTPUT_FILE, mOutputFilename);
+ data.putString(ApgIntentService.ENCRYPT_INPUT_FILE, mInputFilename);
+ data.putString(ApgIntentService.ENCRYPT_OUTPUT_FILE, mOutputFilename);
} else {
data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_BYTES);
if (mDataBytes != null) {
- data.putByteArray(ApgIntentService.CIPHERTEXT_BYTES, mDataBytes);
+ data.putByteArray(ApgIntentService.DECRYPT_CIPHERTEXT_BYTES, mDataBytes);
} else {
String message = mMessage.getText().toString();
- data.putByteArray(ApgIntentService.CIPHERTEXT_BYTES, message.getBytes());
+ data.putByteArray(ApgIntentService.DECRYPT_CIPHERTEXT_BYTES, message.getBytes());
}
}
- data.putLong(ApgIntentService.SECRET_KEY_ID, mSecretKeyId);
+ data.putLong(ApgIntentService.ENCRYPT_SECRET_KEY_ID, mSecretKeyId);
- data.putBoolean(ApgIntentService.SIGNED_ONLY, mSignedOnly);
- data.putBoolean(ApgIntentService.LOOKUP_UNKNOWN_KEY, mLookupUnknownKey);
- data.putBoolean(ApgIntentService.RETURN_BYTES, mReturnBinary);
- data.putBoolean(ApgIntentService.ASSUME_SYMMETRIC, mAssumeSymmetricEncryption);
+ data.putBoolean(ApgIntentService.DECRYPT_SIGNED_ONLY, mSignedOnly);
+ data.putBoolean(ApgIntentService.DECRYPT_LOOKUP_UNKNOWN_KEY, mLookupUnknownKey);
+ data.putBoolean(ApgIntentService.DECRYPT_RETURN_BYTES, mReturnBinary);
+ data.putBoolean(ApgIntentService.DECRYPT_ASSUME_SYMMETRIC, mAssumeSymmetricEncryption);
intent.putExtra(ApgIntentService.EXTRA_DATA, data);
diff --git a/APG/src/org/thialfihar/android/apg/ui/EditKeyActivity.java b/APG/src/org/thialfihar/android/apg/ui/EditKeyActivity.java
index 0e480a3ae..d4859cc86 100644
--- a/APG/src/org/thialfihar/android/apg/ui/EditKeyActivity.java
+++ b/APG/src/org/thialfihar/android/apg/ui/EditKeyActivity.java
@@ -25,6 +25,7 @@ import org.thialfihar.android.apg.helper.OtherHelper;
import org.thialfihar.android.apg.helper.PGPHelper;
import org.thialfihar.android.apg.helper.PGPMain;
import org.thialfihar.android.apg.helper.PGPConversionHelper;
+import org.thialfihar.android.apg.helper.PGPMain.ApgGeneralException;
import org.thialfihar.android.apg.provider.ProviderHelper;
import org.thialfihar.android.apg.service.ApgIntentServiceHandler;
import org.thialfihar.android.apg.service.ApgIntentService;
@@ -75,6 +76,10 @@ public class EditKeyActivity extends SherlockFragmentActivity {
public static final String EXTRA_GENERATE_DEFAULT_KEYS = "generateDefaultKeys";
public static final String EXTRA_KEY_ID = "keyId";
+ // results when saving key
+ public static final String RESULT_EXTRA_MASTER_KEY_ID = "masterKeyId";
+ public static final String RESULT_EXTRA_USER_ID = "userId";
+
private ActionBar mActionBar;
private PGPSecretKeyRing mKeyRing = null;
@@ -121,7 +126,7 @@ public class EditKeyActivity extends SherlockFragmentActivity {
return true;
case Id.menu.option.cancel:
- finish();
+ cancelClicked();
return true;
default:
@@ -236,7 +241,8 @@ public class EditKeyActivity extends SherlockFragmentActivity {
// fill values for this action
Bundle data = new Bundle();
- data.putString(ApgIntentService.SYMMETRIC_PASSPHRASE, mCurrentPassPhrase);
+ data.putString(ApgIntentService.GENERATE_KEY_SYMMETRIC_PASSPHRASE,
+ mCurrentPassPhrase);
serviceIntent.putExtra(ApgIntentService.EXTRA_DATA, data);
@@ -424,14 +430,16 @@ public class EditKeyActivity extends SherlockFragmentActivity {
// fill values for this action
Bundle data = new Bundle();
- data.putString(ApgIntentService.CURRENT_PASSPHRASE, mCurrentPassPhrase);
- data.putString(ApgIntentService.NEW_PASSPHRASE, mNewPassPhrase);
- data.putStringArrayList(ApgIntentService.USER_IDS, getUserIds(mUserIdsView));
+ data.putString(ApgIntentService.SAVE_KEYRING_CURRENT_PASSPHRASE, mCurrentPassPhrase);
+ data.putString(ApgIntentService.SAVE_KEYRING_NEW_PASSPHRASE, mNewPassPhrase);
+ data.putStringArrayList(ApgIntentService.SAVE_KEYRING_USER_IDS,
+ getUserIds(mUserIdsView));
ArrayList<PGPSecretKey> keys = getKeys(mKeysView);
- data.putByteArray(ApgIntentService.KEYS,
+ data.putByteArray(ApgIntentService.SAVE_KEYRING_KEYS,
PGPConversionHelper.PGPSecretKeyArrayListToBytes(keys));
- data.putIntegerArrayList(ApgIntentService.KEYS_USAGES, getKeysUsages(mKeysView));
- data.putLong(ApgIntentService.MASTER_KEY_ID, getMasterKeyId());
+ data.putIntegerArrayList(ApgIntentService.SAVE_KEYRING_KEYS_USAGES,
+ getKeysUsages(mKeysView));
+ data.putLong(ApgIntentService.SAVE_KEYRING_MASTER_KEY_ID, getMasterKeyId());
intent.putExtra(ApgIntentService.EXTRA_DATA, data);
@@ -443,6 +451,16 @@ public class EditKeyActivity extends SherlockFragmentActivity {
super.handleMessage(message);
if (message.arg1 == ApgIntentServiceHandler.MESSAGE_OKAY) {
+ Intent data = new Intent();
+ data.putExtra(RESULT_EXTRA_MASTER_KEY_ID, getMasterKeyId());
+ ArrayList<String> userIds = null;
+ try {
+ userIds = getUserIds(mUserIdsView);
+ } catch (ApgGeneralException e) {
+ Log.e(Constants.TAG, "exception while getting user ids", e);
+ }
+ data.putExtra(RESULT_EXTRA_USER_ID, userIds.get(0));
+ setResult(RESULT_OK, data);
finish();
}
};
@@ -462,6 +480,11 @@ public class EditKeyActivity extends SherlockFragmentActivity {
}
}
+ private void cancelClicked() {
+ setResult(RESULT_CANCELED);
+ finish();
+ }
+
/**
* Returns user ids from the SectionView
*
diff --git a/APG/src/org/thialfihar/android/apg/ui/EncryptActivity.java b/APG/src/org/thialfihar/android/apg/ui/EncryptActivity.java
index 6ff97a796..3014892a3 100644
--- a/APG/src/org/thialfihar/android/apg/ui/EncryptActivity.java
+++ b/APG/src/org/thialfihar/android/apg/ui/EncryptActivity.java
@@ -70,18 +70,20 @@ import java.util.Vector;
public class EncryptActivity extends SherlockFragmentActivity {
- // possible intent actions for this activity
+ /* Intents */
+ // without permission
public static final String ACTION_ENCRYPT = Constants.INTENT_PREFIX + "ENCRYPT";
+ public static final String ACTION_ENCRYPT_FILE = Constants.INTENT_PREFIX + "ENCRYPT_FILE";
+
+ // with permission
public static final String ACTION_ENCRYPT_AND_RETURN = Constants.INTENT_PREFIX
+ "ENCRYPT_AND_RETURN";
public static final String ACTION_GENERATE_SIGNATURE_AND_RETURN = Constants.INTENT_PREFIX
- + "GENERATE_SIGNATURE";
-
- public static final String ACTION_ENCRYPT_FILE = Constants.INTENT_PREFIX + "ENCRYPT_FILE";
+ + "GENERATE_SIGNATURE_AND_RETURN";
public static final String ACTION_ENCRYPT_STREAM_AND_RETURN = Constants.INTENT_PREFIX
+ "ENCRYPT_STREAM_AND_RETURN";
- // possible extra keys
+ /* EXTRA keys for input */
public static final String EXTRA_TEXT = "text";
public static final String EXTRA_DATA = "data";
public static final String EXTRA_ASCII_ARMOUR = "asciiArmour";
@@ -339,7 +341,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
} else if (ACTION_ENCRYPT_STREAM_AND_RETURN.equals(action)) {
// TODO: Set mStreamAndReturnUri that is used later to encrypt a stream!
- mStreamAndReturnUri = null;
+ mStreamAndReturnUri = uri;
}
}
@@ -684,7 +686,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
passPhrase = null;
}
- data.putString(ApgIntentService.SYMMETRIC_PASSPHRASE, passPhrase);
+ data.putString(ApgIntentService.GENERATE_KEY_SYMMETRIC_PASSPHRASE, passPhrase);
} else {
encryptionKeyIds = mEncryptionKeyIds;
signOnly = (mEncryptionKeyIds == null || mEncryptionKeyIds.length == 0);
@@ -696,7 +698,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
if (mStreamAndReturnUri != null) {
// mIntentDataUri is only defined when ACTION_ENCRYPT_STREAM_AND_RETURN is used
data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_STREAM);
- data.putParcelable(ApgIntentService.PROVIDER_URI, mStreamAndReturnUri);
+ data.putParcelable(ApgIntentService.ENCRYPT_PROVIDER_URI, mStreamAndReturnUri);
} else if (mEncryptTarget == Id.target.file) {
useAsciiArmor = mAsciiArmour.isChecked();
@@ -707,8 +709,8 @@ public class EncryptActivity extends SherlockFragmentActivity {
Log.d(Constants.TAG, "mInputFilename=" + mInputFilename + ", mOutputFilename="
+ mOutputFilename);
- data.putString(ApgIntentService.INPUT_FILE, mInputFilename);
- data.putString(ApgIntentService.OUTPUT_FILE, mOutputFilename);
+ data.putString(ApgIntentService.ENCRYPT_INPUT_FILE, mInputFilename);
+ data.putString(ApgIntentService.ENCRYPT_OUTPUT_FILE, mOutputFilename);
} else {
useAsciiArmor = true;
@@ -717,13 +719,13 @@ public class EncryptActivity extends SherlockFragmentActivity {
data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_BYTES);
if (mData != null) {
- data.putByteArray(ApgIntentService.MESSAGE_BYTES, mData);
+ data.putByteArray(ApgIntentService.ENCRYPT_MESSAGE_BYTES, mData);
} else {
String message = mMessage.getText().toString();
if (signOnly && !mEncryptImmediately) {
fixBadCharactersForGmail(message);
}
- data.putByteArray(ApgIntentService.MESSAGE_BYTES, message.getBytes());
+ data.putByteArray(ApgIntentService.ENCRYPT_MESSAGE_BYTES, message.getBytes());
}
}
@@ -731,12 +733,12 @@ public class EncryptActivity extends SherlockFragmentActivity {
useAsciiArmor = mAsciiArmorDemand;
}
- data.putLong(ApgIntentService.SECRET_KEY_ID, mSecretKeyId);
- data.putBoolean(ApgIntentService.USE_ASCII_AMOR, useAsciiArmor);
- data.putLongArray(ApgIntentService.ENCRYPTION_KEYS_IDS, encryptionKeyIds);
- data.putInt(ApgIntentService.COMPRESSION_ID, compressionId);
- data.putBoolean(ApgIntentService.GENERATE_SIGNATURE, mGenerateSignature);
- data.putBoolean(ApgIntentService.SIGN_ONLY, signOnly);
+ data.putLong(ApgIntentService.ENCRYPT_SECRET_KEY_ID, mSecretKeyId);
+ data.putBoolean(ApgIntentService.ENCRYPT_USE_ASCII_AMOR, useAsciiArmor);
+ data.putLongArray(ApgIntentService.ENCRYPT_ENCRYPTION_KEYS_IDS, encryptionKeyIds);
+ data.putInt(ApgIntentService.ENCRYPT_COMPRESSION_ID, compressionId);
+ data.putBoolean(ApgIntentService.ENCRYPT_GENERATE_SIGNATURE, mGenerateSignature);
+ data.putBoolean(ApgIntentService.ENCRYPT_SIGN_ONLY, signOnly);
intent.putExtra(ApgIntentService.EXTRA_DATA, data);
diff --git a/APG/src/org/thialfihar/android/apg/ui/KeyListActivity.java b/APG/src/org/thialfihar/android/apg/ui/KeyListActivity.java
index b36300769..2dc09d545 100644
--- a/APG/src/org/thialfihar/android/apg/ui/KeyListActivity.java
+++ b/APG/src/org/thialfihar/android/apg/ui/KeyListActivity.java
@@ -281,7 +281,7 @@ public class KeyListActivity extends SherlockFragmentActivity {
@Override
public void handleMessage(Message message) {
if (message.what == DeleteKeyDialogFragment.MESSAGE_OKAY) {
- // refreshList();
+ // no further actions needed
}
}
};
@@ -368,8 +368,6 @@ public class KeyListActivity extends SherlockFragmentActivity {
.newInstance(mImportFilename);
deleteFileDialog.show(getSupportFragmentManager(), "deleteDialog");
}
- // refreshList();
-
}
};
};
diff --git a/APG/src/org/thialfihar/android/apg/ui/widget/SectionView.java b/APG/src/org/thialfihar/android/apg/ui/widget/SectionView.java
index 45fbbaba1..c7e8087cb 100644
--- a/APG/src/org/thialfihar/android/apg/ui/widget/SectionView.java
+++ b/APG/src/org/thialfihar/android/apg/ui/widget/SectionView.java
@@ -262,14 +262,14 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
passPhrase = PassphraseCacheService
.getCachedPassphrase(mActivity, masterKey.getKeyID());
- data.putByteArray(ApgIntentService.MASTER_KEY,
+ data.putByteArray(ApgIntentService.GENERATE_KEY_MASTER_KEY,
PGPConversionHelper.PGPSecretKeyToBytes(masterKey));
} else {
passPhrase = "";
}
- data.putString(ApgIntentService.SYMMETRIC_PASSPHRASE, passPhrase);
- data.putInt(ApgIntentService.ALGORITHM, mNewKeyAlgorithmChoice.getId());
- data.putInt(ApgIntentService.KEY_SIZE, mNewKeySize);
+ data.putString(ApgIntentService.GENERATE_KEY_SYMMETRIC_PASSPHRASE, passPhrase);
+ data.putInt(ApgIntentService.GENERATE_KEY_ALGORITHM, mNewKeyAlgorithmChoice.getId());
+ data.putInt(ApgIntentService.GENERATE_KEY_KEY_SIZE, mNewKeySize);
intent.putExtra(ApgIntentService.EXTRA_DATA, data);