aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2013-09-15 16:42:08 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2013-09-15 16:42:08 +0200
commit5aebd115d4a7a8ba7d538621bbf9e88ef941f48c (patch)
tree14398fad82c0d244d19028cafb07ad4234e994b9 /OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service
parent121f8aaca040cd54d8182f0ab9adba961bdfde6d (diff)
downloadopen-keychain-5aebd115d4a7a8ba7d538621bbf9e88ef941f48c.tar.gz
open-keychain-5aebd115d4a7a8ba7d538621bbf9e88ef941f48c.tar.bz2
open-keychain-5aebd115d4a7a8ba7d538621bbf9e88ef941f48c.zip
Put PgpMain methods in separate opbject classes, handle passphrase dialog in EditKey not in SecretKeyList
Diffstat (limited to 'OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service')
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/KeychainIntentService.java104
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/PassphraseCacheService.java6
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/AppSettingsFragment.java6
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/ExtendedApiService.java7
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/OpenPgpService.java39
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/RemoteServiceActivity.java4
6 files changed, 89 insertions, 77 deletions
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/KeychainIntentService.java
index d7ddedce3..6b459b969 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/KeychainIntentService.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/KeychainIntentService.java
@@ -38,8 +38,11 @@ import org.sufficientlysecure.keychain.helper.FileHelper;
import org.sufficientlysecure.keychain.helper.OtherHelper;
import org.sufficientlysecure.keychain.helper.Preferences;
import org.sufficientlysecure.keychain.pgp.PgpConversionHelper;
-import org.sufficientlysecure.keychain.pgp.PgpMain;
-import org.sufficientlysecure.keychain.pgp.PgpMain.PgpGeneralException;
+import org.sufficientlysecure.keychain.pgp.PgpHelper;
+import org.sufficientlysecure.keychain.pgp.PgpImportExport;
+import org.sufficientlysecure.keychain.pgp.PgpKeyOperation;
+import org.sufficientlysecure.keychain.pgp.PgpOperation;
+import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
import org.sufficientlysecure.keychain.provider.KeychainContract.DataStream;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.util.HkpKeyServer;
@@ -288,16 +291,15 @@ public class KeychainIntentService extends IntentService implements ProgressDial
// InputStream
InputStream in = getContentResolver().openInputStream(providerUri);
- inLength = PgpMain.getLengthOfStream(in);
+ inLength = PgpHelper.getLengthOfStream(in);
inputData = new InputData(in, inLength);
// OutputStream
try {
while (true) {
- streamFilename = PgpMain.generateRandomFilename(32);
+ streamFilename = PgpHelper.generateRandomFilename(32);
if (streamFilename == null) {
- throw new PgpMain.PgpGeneralException(
- "couldn't generate random file name");
+ throw new PgpGeneralException("couldn't generate random file name");
}
openFileInput(streamFilename).close();
}
@@ -309,31 +311,30 @@ public class KeychainIntentService extends IntentService implements ProgressDial
break;
default:
- throw new PgpMain.PgpGeneralException("No target choosen!");
+ throw new PgpGeneralException("No target choosen!");
}
/* Operation */
+ PgpOperation operation = new PgpOperation(this, this, inputData, outStream);
if (generateSignature) {
Log.d(Constants.TAG, "generating signature...");
- PgpMain.generateSignature(this, this, inputData, outStream, useAsciiArmor,
- false, secretKeyId, PassphraseCacheService.getCachedPassphrase(this,
- secretKeyId), Preferences.getPreferences(this)
- .getDefaultHashAlgorithm(), Preferences.getPreferences(this)
- .getForceV3Signatures());
- } else if (signOnly) {
- Log.d(Constants.TAG, "sign only...");
- PgpMain.signText(this, this, inputData, outStream, secretKeyId,
+ operation.generateSignature(useAsciiArmor, false, secretKeyId,
PassphraseCacheService.getCachedPassphrase(this, secretKeyId),
Preferences.getPreferences(this).getDefaultHashAlgorithm(), Preferences
.getPreferences(this).getForceV3Signatures());
+ } else if (signOnly) {
+ Log.d(Constants.TAG, "sign only...");
+ operation.signText(secretKeyId, PassphraseCacheService.getCachedPassphrase(
+ this, secretKeyId), Preferences.getPreferences(this)
+ .getDefaultHashAlgorithm(), Preferences.getPreferences(this)
+ .getForceV3Signatures());
} else {
Log.d(Constants.TAG, "encrypt...");
- PgpMain.encryptAndSign(this, this, inputData, outStream, useAsciiArmor,
- compressionId, encryptionKeyIds, encryptionPassphrase, Preferences
- .getPreferences(this).getDefaultEncryptionAlgorithm(),
- secretKeyId,
- Preferences.getPreferences(this).getDefaultHashAlgorithm(), Preferences
+ operation.encryptAndSign(useAsciiArmor, compressionId, encryptionKeyIds,
+ encryptionPassphrase, Preferences.getPreferences(this)
+ .getDefaultEncryptionAlgorithm(), secretKeyId, Preferences
+ .getPreferences(this).getDefaultHashAlgorithm(), Preferences
.getPreferences(this).getForceV3Signatures(),
PassphraseCacheService.getCachedPassphrase(this, secretKeyId));
}
@@ -437,16 +438,15 @@ public class KeychainIntentService extends IntentService implements ProgressDial
// InputStream
InputStream in = getContentResolver().openInputStream(providerUri);
- inLength = PgpMain.getLengthOfStream(in);
+ inLength = PgpHelper.getLengthOfStream(in);
inputData = new InputData(in, inLength);
// OutputStream
try {
while (true) {
- streamFilename = PgpMain.generateRandomFilename(32);
+ streamFilename = PgpHelper.generateRandomFilename(32);
if (streamFilename == null) {
- throw new PgpMain.PgpGeneralException(
- "couldn't generate random file name");
+ throw new PgpGeneralException("couldn't generate random file name");
}
openFileInput(streamFilename).close();
}
@@ -458,7 +458,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial
break;
default:
- throw new PgpMain.PgpGeneralException("No target choosen!");
+ throw new PgpGeneralException("No target choosen!");
}
@@ -468,11 +468,11 @@ public class KeychainIntentService extends IntentService implements ProgressDial
// verifyText and decrypt returning additional resultData values for the
// verification of signatures
+ PgpOperation operation = new PgpOperation(this, this, inputData, outStream);
if (signedOnly) {
- resultData = PgpMain.verifyText(this, this, inputData, outStream,
- lookupUnknownKey);
+ resultData = operation.verifyText(lookupUnknownKey);
} else {
- resultData = PgpMain.decryptAndVerify(this, this, inputData, outStream,
+ resultData = operation.decryptAndVerify(
PassphraseCacheService.getCachedPassphrase(this, secretKeyId),
assumeSymmetricEncryption);
}
@@ -530,14 +530,15 @@ public class KeychainIntentService extends IntentService implements ProgressDial
ArrayList<Integer> keysUsages = data.getIntegerArrayList(SAVE_KEYRING_KEYS_USAGES);
long masterKeyId = data.getLong(SAVE_KEYRING_MASTER_KEY_ID);
+ PgpKeyOperation keyOperations = new PgpKeyOperation(this, this);
/* Operation */
if (!canSign) {
- PgpMain.changeSecretKeyPassphrase(this,
+ keyOperations.changeSecretKeyPassphrase(
ProviderHelper.getPGPSecretKeyRingByKeyId(this, masterKeyId),
- oldPassPhrase, newPassPhrase, this);
+ oldPassPhrase, newPassPhrase);
} else {
- PgpMain.buildSecretKey(this, userIds, keys, keysUsages, masterKeyId,
- oldPassPhrase, newPassPhrase, this);
+ keyOperations.buildSecretKey(userIds, keys, keysUsages, masterKeyId,
+ oldPassPhrase, newPassPhrase);
}
PassphraseCacheService.addCachedPassphrase(this, masterKeyId, newPassPhrase);
@@ -559,7 +560,8 @@ public class KeychainIntentService extends IntentService implements ProgressDial
}
/* Operation */
- PGPSecretKeyRing newKeyRing = PgpMain.createKey(this, algorithm, keysize,
+ PgpKeyOperation keyOperations = new PgpKeyOperation(this, this);
+ PGPSecretKeyRing newKeyRing = keyOperations.createKey(algorithm, keysize,
passphrase, masterKey);
/* Output */
@@ -580,10 +582,12 @@ public class KeychainIntentService extends IntentService implements ProgressDial
String passphrase = data.getString(GENERATE_KEY_SYMMETRIC_PASSPHRASE);
/* Operation */
- PGPSecretKeyRing masterKeyRing = PgpMain.createKey(this, Id.choice.algorithm.rsa,
+ PgpKeyOperation keyOperations = new PgpKeyOperation(this, this);
+
+ PGPSecretKeyRing masterKeyRing = keyOperations.createKey(Id.choice.algorithm.rsa,
4096, passphrase, null);
- PGPSecretKeyRing subKeyRing = PgpMain.createKey(this, Id.choice.algorithm.rsa,
+ PGPSecretKeyRing subKeyRing = keyOperations.createKey(Id.choice.algorithm.rsa,
4096, passphrase, masterKeyRing.getSecretKey());
/* Output */
@@ -606,13 +610,13 @@ public class KeychainIntentService extends IntentService implements ProgressDial
/* Operation */
try {
- PgpMain.deleteFileSecurely(this, this, new File(deleteFile));
+ PgpHelper.deleteFileSecurely(this, this, new File(deleteFile));
} catch (FileNotFoundException e) {
- throw new PgpMain.PgpGeneralException(getString(R.string.error_fileNotFound,
- deleteFile));
+ throw new PgpGeneralException(
+ getString(R.string.error_fileNotFound, deleteFile));
} catch (IOException e) {
- throw new PgpMain.PgpGeneralException(getString(
- R.string.error_fileDeleteFailed, deleteFile));
+ throw new PgpGeneralException(getString(R.string.error_fileDeleteFailed,
+ deleteFile));
}
/* Output */
@@ -661,7 +665,9 @@ public class KeychainIntentService extends IntentService implements ProgressDial
}
Bundle resultData = new Bundle();
- resultData = PgpMain.importKeyRings(this, inputData, this);
+
+ PgpImportExport pgpImportExport = new PgpImportExport(this, this);
+ resultData = pgpImportExport.importKeyRings(inputData);
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, resultData);
} catch (Exception e) {
@@ -708,8 +714,10 @@ public class KeychainIntentService extends IntentService implements ProgressDial
}
Bundle resultData = new Bundle();
- resultData = PgpMain.exportKeyRings(this, keyRingMasterKeyIds, keyType, outStream,
- this);
+
+ PgpImportExport pgpImportExport = new PgpImportExport(this, this);
+ resultData = pgpImportExport
+ .exportKeyRings(keyRingMasterKeyIds, keyType, outStream);
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, resultData);
} catch (Exception e) {
@@ -728,7 +736,9 @@ public class KeychainIntentService extends IntentService implements ProgressDial
PGPPublicKeyRing keyring = ProviderHelper.getPGPPublicKeyRingByRowId(this,
keyRingRowId);
if (keyring != null) {
- boolean uploaded = PgpMain.uploadKeyRingToServer(server,
+ PgpImportExport pgpImportExport = new PgpImportExport(this, null);
+
+ boolean uploaded = pgpImportExport.uploadKeyRingToServer(server,
(PGPPublicKeyRing) keyring);
if (!uploaded) {
throw new PgpGeneralException("Unable to export key to selected server");
@@ -778,11 +788,13 @@ public class KeychainIntentService extends IntentService implements ProgressDial
String signaturePassPhrase = PassphraseCacheService.getCachedPassphrase(this,
masterKeyId);
- PGPPublicKeyRing signedPubKeyRing = PgpMain.signKey(this, masterKeyId, pubKeyId,
+ PgpKeyOperation keyOperation = new PgpKeyOperation(this, this);
+ PGPPublicKeyRing signedPubKeyRing = keyOperation.signKey(masterKeyId, pubKeyId,
signaturePassPhrase);
// store the signed key in our local cache
- int retval = PgpMain.storeKeyRingInCache(this, signedPubKeyRing);
+ PgpImportExport pgpImportExport = new PgpImportExport(this, null);
+ int retval = pgpImportExport.storeKeyRingInCache(signedPubKeyRing);
if (retval != Id.return_value.ok && retval != Id.return_value.updated) {
throw new PgpGeneralException("Failed to store signed key in local cache");
}
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/PassphraseCacheService.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/PassphraseCacheService.java
index 466d087a2..f447b6d4f 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/PassphraseCacheService.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/PassphraseCacheService.java
@@ -29,7 +29,7 @@ import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.Id;
import org.sufficientlysecure.keychain.helper.Preferences;
-import org.sufficientlysecure.keychain.pgp.PgpHelper;
+import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import android.app.AlarmManager;
@@ -173,7 +173,7 @@ public class PassphraseCacheService extends Service {
if (keyRing == null) {
return null;
}
- PGPSecretKey masterKey = PgpHelper.getMasterKey(keyRing);
+ PGPSecretKey masterKey = PgpKeyHelper.getMasterKey(keyRing);
if (masterKey == null) {
return null;
}
@@ -210,7 +210,7 @@ public class PassphraseCacheService extends Service {
public static boolean hasPassphrase(Context context, long secretKeyId) {
// check if the key has no passphrase
try {
- PGPSecretKey secretKey = PgpHelper.getMasterKey(ProviderHelper
+ PGPSecretKey secretKey = PgpKeyHelper.getMasterKey(ProviderHelper
.getPGPSecretKeyRingByKeyId(context, secretKeyId));
PBESecretKeyDecryptor keyDecryptor = new JcePBESecretKeyDecryptorBuilder().setProvider(
"SC").build("".toCharArray());
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/AppSettingsFragment.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/AppSettingsFragment.java
index 8eb34b6e8..0f919fc67 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/AppSettingsFragment.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/AppSettingsFragment.java
@@ -26,7 +26,7 @@ import org.spongycastle.openpgp.PGPSecretKeyRing;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.Id;
import org.sufficientlysecure.keychain.R;
-import org.sufficientlysecure.keychain.pgp.PgpHelper;
+import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.ui.SelectSecretKeyActivity;
import org.sufficientlysecure.keychain.util.KeyValueSpinnerAdapter;
@@ -259,9 +259,9 @@ public class AppSettingsFragment extends Fragment {
PGPSecretKeyRing keyRing = ProviderHelper.getPGPSecretKeyRingByMasterKeyId(
getActivity(), secretKeyId);
if (keyRing != null) {
- PGPSecretKey key = PgpHelper.getMasterKey(keyRing);
+ PGPSecretKey key = PgpKeyHelper.getMasterKey(keyRing);
if (key != null) {
- String userId = PgpHelper.getMainUserIdSafe(getActivity(), key);
+ String userId = PgpKeyHelper.getMainUserIdSafe(getActivity(), key);
String chunks[] = userId.split(" <", 2);
uid = chunks[0];
if (chunks.length > 1) {
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/ExtendedApiService.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/ExtendedApiService.java
index 94e4004c6..4530179cb 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/ExtendedApiService.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/ExtendedApiService.java
@@ -29,8 +29,7 @@ import org.spongycastle.openpgp.PGPPrivateKey;
import org.spongycastle.openpgp.PGPSecretKey;
import org.spongycastle.openssl.PEMWriter;
import org.sufficientlysecure.keychain.Constants;
-import org.sufficientlysecure.keychain.pgp.PgpHelper;
-import org.sufficientlysecure.keychain.pgp.PgpMain;
+import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
import org.sufficientlysecure.keychain.pgp.PgpToX509;
import org.sufficientlysecure.keychain.util.Log;
@@ -53,13 +52,13 @@ public class ExtendedApiService extends RemoteService {
try {
long keyId = appSettings.getKeyId();
- PGPSecretKey pgpSecretKey = PgpHelper.getSigningKey(this, keyId);
+ PGPSecretKey pgpSecretKey = PgpKeyHelper.getSigningKey(this, keyId);
PasswordCallback pgpSecKeyPasswordCallBack = new PasswordCallback("pgp passphrase?",
false);
pgpPwdCallbackHandler.handle(new Callback[] { pgpSecKeyPasswordCallBack });
PGPPrivateKey pgpPrivKey = pgpSecretKey.extractPrivateKey(
- pgpSecKeyPasswordCallBack.getPassword(), PgpMain.BOUNCY_CASTLE_PROVIDER_NAME);
+ pgpSecKeyPasswordCallBack.getPassword(), Constants.BOUNCY_CASTLE_PROVIDER_NAME);
pgpSecKeyPasswordCallBack.clearPassword();
X509Certificate selfSignedCert = PgpToX509.createSelfSignedCert(pgpSecretKey,
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/OpenPgpService.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/OpenPgpService.java
index 200675288..480b88ca5 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/OpenPgpService.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/OpenPgpService.java
@@ -32,7 +32,10 @@ import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.Id;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.helper.Preferences;
-import org.sufficientlysecure.keychain.pgp.PgpMain;
+import org.sufficientlysecure.keychain.pgp.PgpHelper;
+import org.sufficientlysecure.keychain.pgp.PgpOperation;
+import org.sufficientlysecure.keychain.pgp.exception.NoAsymmetricEncryptionException;
+import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
@@ -230,6 +233,7 @@ public class OpenPgpService extends RemoteService {
return;
}
+ PgpOperation operation = new PgpOperation(getContext(), null, inputData, outputStream);
if (sign) {
String passphrase = getCachedPassphrase(appSettings.getKeyId());
if (passphrase == null) {
@@ -238,13 +242,11 @@ public class OpenPgpService extends RemoteService {
return;
}
- PgpMain.encryptAndSign(getContext(), null, inputData, outputStream, asciiArmor,
- appSettings.getCompression(), keyIds, null,
+ operation.encryptAndSign(asciiArmor, appSettings.getCompression(), keyIds, null,
appSettings.getEncryptionAlgorithm(), appSettings.getKeyId(),
appSettings.getHashAlgorithm(), true, passphrase);
} else {
- PgpMain.encryptAndSign(getContext(), null, inputData, outputStream, asciiArmor,
- appSettings.getCompression(), keyIds, null,
+ operation.encryptAndSign(asciiArmor, appSettings.getCompression(), keyIds, null,
appSettings.getEncryptionAlgorithm(), Id.key.none,
appSettings.getHashAlgorithm(), true, null);
}
@@ -286,9 +288,9 @@ public class OpenPgpService extends RemoteService {
return;
}
- PgpMain.signText(this, null, inputData, outputStream, appSettings.getKeyId(),
- passphrase, appSettings.getHashAlgorithm(), Preferences.getPreferences(this)
- .getForceV3Signatures());
+ PgpOperation operation = new PgpOperation(getContext(), null, inputData, outputStream);
+ operation.signText(appSettings.getKeyId(), passphrase, appSettings.getHashAlgorithm(),
+ Preferences.getPreferences(this).getForceV3Signatures());
outputStream.close();
@@ -315,7 +317,7 @@ public class OpenPgpService extends RemoteService {
String message = new String(inputBytes);
Log.d(Constants.TAG, "in: " + message);
boolean signedOnly = false;
- Matcher matcher = PgpMain.PGP_MESSAGE.matcher(message);
+ Matcher matcher = PgpHelper.PGP_MESSAGE.matcher(message);
if (matcher.matches()) {
Log.d(Constants.TAG, "PGP_MESSAGE matched");
message = matcher.group(1);
@@ -325,7 +327,7 @@ public class OpenPgpService extends RemoteService {
// overwrite inputBytes
inputBytes = message.getBytes();
} else {
- matcher = PgpMain.PGP_SIGNED_MESSAGE.matcher(message);
+ matcher = PgpHelper.PGP_SIGNED_MESSAGE.matcher(message);
if (matcher.matches()) {
signedOnly = true;
Log.d(Constants.TAG, "PGP_SIGNED_MESSAGE matched");
@@ -368,19 +370,18 @@ public class OpenPgpService extends RemoteService {
// than 0.
inputStream2.mark(200);
}
- secretKeyId = PgpMain.getDecryptionKeyId(this, inputStream2);
+ secretKeyId = PgpHelper.getDecryptionKeyId(this, inputStream2);
if (secretKeyId == Id.key.none) {
- throw new PgpMain.PgpGeneralException(
- getString(R.string.error_noSecretKeyFound));
+ throw new PgpGeneralException(getString(R.string.error_noSecretKeyFound));
}
assumeSymmetricEncryption = false;
- } catch (PgpMain.NoAsymmetricEncryptionException e) {
+ } catch (NoAsymmetricEncryptionException e) {
if (inputStream2.markSupported()) {
inputStream2.reset();
}
secretKeyId = Id.key.symmetric;
- if (!PgpMain.hasSymmetricEncryption(this, inputStream2)) {
- throw new PgpMain.PgpGeneralException(
+ if (!PgpOperation.hasSymmetricEncryption(this, inputStream2)) {
+ throw new PgpGeneralException(
getString(R.string.error_noKnownEncryptionFound));
}
assumeSymmetricEncryption = true;
@@ -404,13 +405,13 @@ public class OpenPgpService extends RemoteService {
OutputStream outputStream = new ByteArrayOutputStream();
Bundle outputBundle;
+ PgpOperation operation = new PgpOperation(getContext(), null, inputData, outputStream);
if (signedOnly) {
// TODO: download missing keys from keyserver?
- outputBundle = PgpMain.verifyText(this, null, inputData, outputStream, false);
+ outputBundle = operation.verifyText(false);
} else {
// TODO: assume symmetric: callback to enter symmetric pass
- outputBundle = PgpMain.decryptAndVerify(this, null, inputData, outputStream,
- passphrase, assumeSymmetricEncryption);
+ outputBundle = operation.decryptAndVerify(passphrase, assumeSymmetricEncryption);
}
outputStream.close();
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/RemoteServiceActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/RemoteServiceActivity.java
index cf64fb71d..5bf0684b1 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/RemoteServiceActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/RemoteServiceActivity.java
@@ -24,7 +24,7 @@ import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.Id;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.helper.ActionBarHelper;
-import org.sufficientlysecure.keychain.pgp.PgpMain;
+import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.ui.SelectPublicKeyFragment;
import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment;
@@ -316,7 +316,7 @@ public class RemoteServiceActivity extends SherlockFragmentActivity {
messenger, secretKeyId);
passphraseDialog.show(getSupportFragmentManager(), "passphraseDialog");
- } catch (PgpMain.PgpGeneralException e) {
+ } catch (PgpGeneralException e) {
Log.d(Constants.TAG, "No passphrase for this secret key, encrypt directly!");
// send message to handler to start encryption directly
returnHandler.sendEmptyMessage(PassphraseDialogFragment.MESSAGE_OKAY);