diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2013-09-06 18:36:16 +0200 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2013-09-06 18:36:16 +0200 |
commit | d6dd81d4449f437de672395b8f9ba2664c945d4c (patch) | |
tree | 22b8e3531e3c4305aa4ae010196917f40003bd8c /OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service | |
parent | 9e8ee3353a8230c02a0c5cc63448c16164149b24 (diff) | |
download | open-keychain-d6dd81d4449f437de672395b8f9ba2664c945d4c.tar.gz open-keychain-d6dd81d4449f437de672395b8f9ba2664c945d4c.tar.bz2 open-keychain-d6dd81d4449f437de672395b8f9ba2664c945d4c.zip |
Work on encryption in new service
Diffstat (limited to 'OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service')
-rw-r--r-- | OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/KeychainApiService.java | 12 | ||||
-rw-r--r-- | OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/KeychainIntentService.java | 52 |
2 files changed, 31 insertions, 33 deletions
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/KeychainApiService.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/KeychainApiService.java index 41250f645..d7457f132 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/KeychainApiService.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/KeychainApiService.java @@ -103,12 +103,12 @@ public class KeychainApiService extends Service { InputData input = new InputData(inputStream, inputLength); OutputStream output = new ByteArrayOutputStream(); - - PgpMain.encryptAndSign(mContext, null, input, output, useAsciiArmor, compression, - encryptionKeyIds, encryptionPassphrase, symmetricEncryptionAlgorithm, - signatureKeyId, signatureHashAlgorithm, signatureForceV3, signaturePassphrase); - - output.close(); +// +// PgpMain.encryptAndSign(mContext, null, input, output, useAsciiArmor, compression, +// encryptionKeyIds, encryptionPassphrase, symmetricEncryptionAlgorithm, +// signatureKeyId, signatureHashAlgorithm, signatureForceV3, signaturePassphrase); +// +// output.close(); // if (isBlob) { // ContentResolver cr = getContentResolver(); diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/KeychainIntentService.java index d1ea9281d..1ffb390c0 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -27,6 +27,8 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import org.spongycastle.openpgp.PGPPublicKeyRing; import org.spongycastle.openpgp.PGPSecretKey; @@ -75,9 +77,11 @@ public class KeychainIntentService extends IntentService implements ProgressDial public static final String ACTION_SAVE_KEYRING = Constants.INTENT_PREFIX + "SAVE_KEYRING"; public static final String ACTION_GENERATE_KEY = Constants.INTENT_PREFIX + "GENERATE_KEY"; - public static final String ACTION_GENERATE_DEFAULT_RSA_KEYS = Constants.INTENT_PREFIX + "GENERATE_DEFAULT_RSA_KEYS"; + public static final String ACTION_GENERATE_DEFAULT_RSA_KEYS = Constants.INTENT_PREFIX + + "GENERATE_DEFAULT_RSA_KEYS"; - public static final String ACTION_DELETE_FILE_SECURELY = Constants.INTENT_PREFIX + "DELETE_FILE_SECURELY"; + public static final String ACTION_DELETE_FILE_SECURELY = Constants.INTENT_PREFIX + + "DELETE_FILE_SECURELY"; public static final String ACTION_IMPORT_KEYRING = Constants.INTENT_PREFIX + "IMPORT_KEYRING"; public static final String ACTION_EXPORT_KEYRING = Constants.INTENT_PREFIX + "EXPORT_KEYRING"; @@ -216,8 +220,8 @@ public class KeychainIntentService extends IntentService implements ProgressDial return; } - if (!(extras.containsKey(EXTRA_MESSENGER) || extras.containsKey(EXTRA_DATA) || - (intent.getAction() == null))) { + if (!(extras.containsKey(EXTRA_MESSENGER) || extras.containsKey(EXTRA_DATA) || (intent + .getAction() == null))) { Log.e(Constants.TAG, "Extra bundle must contain a messenger, a data bundle, and an action!"); return; @@ -229,9 +233,9 @@ public class KeychainIntentService extends IntentService implements ProgressDial OtherHelper.logDebugBundle(data, "EXTRA_DATA"); String action = intent.getAction(); - + // execute action from extra bundle - if( ACTION_ENCRYPT_SIGN.equals(action)) { + if (ACTION_ENCRYPT_SIGN.equals(action)) { try { /* Input */ int target = data.getInt(TARGET); @@ -312,6 +316,10 @@ public class KeychainIntentService extends IntentService implements ProgressDial } /* Operation */ + // convert to arraylist + ArrayList<Long> keyIdsList = new ArrayList<Long>(encryptionKeyIds.length); + for (long n : encryptionKeyIds) + keyIdsList.add(n); if (generateSignature) { Log.d(Constants.TAG, "generating signature..."); @@ -329,7 +337,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial } else { Log.d(Constants.TAG, "encrypt..."); PgpMain.encryptAndSign(this, this, inputData, outStream, useAsciiArmor, - compressionId, encryptionKeyIds, encryptionPassphrase, Preferences + compressionId, keyIdsList, encryptionPassphrase, Preferences .getPreferences(this).getDefaultEncryptionAlgorithm(), secretKeyId, Preferences.getPreferences(this).getDefaultHashAlgorithm(), Preferences @@ -380,8 +388,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial } catch (Exception e) { sendErrorToHandler(e); } - } - else if(ACTION_DECRYPT_VERIFY.equals(action)) { + } else if (ACTION_DECRYPT_VERIFY.equals(action)) { try { /* Input */ int target = data.getInt(TARGET); @@ -510,8 +517,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial } catch (Exception e) { sendErrorToHandler(e); } - } - else if(ACTION_SAVE_KEYRING.equals(action)) { + } else if (ACTION_SAVE_KEYRING.equals(action)) { try { /* Input */ String oldPassPhrase = data.getString(SAVE_KEYRING_CURRENT_PASSPHRASE); @@ -547,8 +553,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial } catch (Exception e) { sendErrorToHandler(e); } - } - else if(ACTION_GENERATE_KEY.equals(action)) { + } else if (ACTION_GENERATE_KEY.equals(action)) { try { /* Input */ int algorithm = data.getInt(GENERATE_KEY_ALGORITHM); @@ -575,8 +580,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial } catch (Exception e) { sendErrorToHandler(e); } - } - else if(ACTION_GENERATE_DEFAULT_RSA_KEYS.equals(action)) { + } else if (ACTION_GENERATE_DEFAULT_RSA_KEYS.equals(action)) { // generate one RSA 2048 key for signing and one subkey for encrypting! try { /* Input */ @@ -602,8 +606,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial } catch (Exception e) { sendErrorToHandler(e); } - } - else if(ACTION_DELETE_FILE_SECURELY.equals(action)) { + } else if (ACTION_DELETE_FILE_SECURELY.equals(action)) { try { /* Input */ String deleteFile = data.getString(DELETE_FILE); @@ -624,8 +627,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial } catch (Exception e) { sendErrorToHandler(e); } - } - else if(ACTION_IMPORT_KEYRING.equals(action)) { + } else if (ACTION_IMPORT_KEYRING.equals(action)) { try { /* Input */ @@ -672,8 +674,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial } catch (Exception e) { sendErrorToHandler(e); } - } - else if(ACTION_EXPORT_KEYRING.equals(action)) { + } else if (ACTION_EXPORT_KEYRING.equals(action)) { try { /* Input */ @@ -721,8 +722,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial } catch (Exception e) { sendErrorToHandler(e); } - } - else if(ACTION_UPLOAD_KEYRING.equals(action)) { + } else if (ACTION_UPLOAD_KEYRING.equals(action)) { try { /* Input */ @@ -746,8 +746,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial } catch (Exception e) { sendErrorToHandler(e); } - } - else if(ACTION_QUERY_KEYRING.equals(action)) { + } else if (ACTION_QUERY_KEYRING.equals(action)) { try { /* Input */ @@ -775,8 +774,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial } catch (Exception e) { sendErrorToHandler(e); } - } - else if(ACTION_SIGN_KEYRING.equals(action)) { + } else if (ACTION_SIGN_KEYRING.equals(action)) { try { /* Input */ |