new spongy castle version, restructering, deprecation fixes

This commit is contained in:
Dominik 2012-06-20 18:44:11 +03:00
parent 47f88cdf4b
commit a51273a051
37 changed files with 2154 additions and 2236 deletions

View File

@ -27,7 +27,6 @@ Fork APG and do a merge request. I will merge your changes back into the main pr
1. New -> Android Project -> Create project from existing source, choose com_actionbarsherlock 1. New -> Android Project -> Create project from existing source, choose com_actionbarsherlock
2. New -> Android Project -> Create project from existing source, choose org_apg 2. New -> Android Project -> Create project from existing source, choose org_apg
3. Add com_actionbarsherlock as Android Lib (Properties of org_apg -> Android -> Library -> add) 3. Add com_actionbarsherlock as Android Lib (Properties of org_apg -> Android -> Library -> add)
4. Optional (As of Android Tools r17 the libraries are automatically added from the libs folder): Add Java libs (Properties of org_apg -> Java Build Path -> Libraries -> add all libraries from libs folder in org_apg)
5. Now APG+ can be build 5. Now APG+ can be build
# Libraries # Libraries
@ -35,7 +34,7 @@ Fork APG and do a merge request. I will merge your changes back into the main pr
The Libraries are provided in the git repository. The Libraries are provided in the git repository.
* ActionBarSherlock to provide an ActionBar for Android < 3.0 * ActionBarSherlock to provide an ActionBar for Android < 3.0
* Spongy Castle as the main Crypto Lib * Spongy Castle Crypto Lib (Android version of Bouncy Castle)
* android-support-v4.jar: Compatibility Lib * android-support-v4.jar: Compatibility Lib
* barcodescanner-android-integration-supportv4.jar: Barcode Scanner Integration * barcodescanner-android-integration-supportv4.jar: Barcode Scanner Integration

Binary file not shown.

Binary file not shown.

View File

@ -32,6 +32,7 @@ import org.thialfihar.android.apg.deprecated.IApgService2.Stub;
import org.thialfihar.android.apg.Id.database; import org.thialfihar.android.apg.Id.database;
import org.thialfihar.android.apg.R.string; import org.thialfihar.android.apg.R.string;
import org.thialfihar.android.apg.helper.PGPHelper; import org.thialfihar.android.apg.helper.PGPHelper;
import org.thialfihar.android.apg.helper.PGPMain;
import org.thialfihar.android.apg.helper.Preferences; import org.thialfihar.android.apg.helper.Preferences;
import org.thialfihar.android.apg.passphrase.PassphraseCacheService; import org.thialfihar.android.apg.passphrase.PassphraseCacheService;
import org.thialfihar.android.apg.provider.KeyRings; import org.thialfihar.android.apg.provider.KeyRings;
@ -204,7 +205,7 @@ public class ApgService2 extends PassphraseCacheService {
typeWhere = KeyRings.TABLE_NAME + "." + KeyRings.TYPE + " = ?"; typeWhere = KeyRings.TABLE_NAME + "." + KeyRings.TYPE + " = ?";
typeVal = new String[] { "" + pParams.get("key_type") }; typeVal = new String[] { "" + pParams.get("key_type") };
} }
return qb.query(PGPHelper.getDatabase().db(), (String[]) pParams.get("columns"), typeWhere, return qb.query(PGPMain.getDatabase().db(), (String[]) pParams.get("columns"), typeWhere,
typeVal, null, null, orderBy); typeVal, null, null, orderBy);
} }
@ -427,7 +428,7 @@ public class ApgService2 extends PassphraseCacheService {
} }
private boolean prepareArgs(String pCall, Bundle pArgs, Bundle pReturn) { private boolean prepareArgs(String pCall, Bundle pArgs, Bundle pReturn) {
PGPHelper.initialize(getBaseContext()); PGPMain.initialize(getBaseContext());
/* add default return values for all functions */ /* add default return values for all functions */
addDefaultReturns(pReturn); addDefaultReturns(pReturn);
@ -493,7 +494,7 @@ public class ApgService2 extends PassphraseCacheService {
if (LOCAL_LOGV) if (LOCAL_LOGV)
Log.v(TAG, "About to encrypt"); Log.v(TAG, "About to encrypt");
try { try {
PGPHelper.encrypt(getBaseContext(), // context PGPMain.encrypt(getBaseContext(), // context
in, // input stream in, // input stream
out, // output stream out, // output stream
pArgs.getBoolean(arg.ARMORED_OUTPUT.name()), // ARMORED_OUTPUT pArgs.getBoolean(arg.ARMORED_OUTPUT.name()), // ARMORED_OUTPUT
@ -625,7 +626,7 @@ public class ApgService2 extends PassphraseCacheService {
if (LOCAL_LOGV) if (LOCAL_LOGV)
Log.v(TAG, "About to decrypt"); Log.v(TAG, "About to decrypt");
try { try {
PGPHelper.decrypt(getBaseContext(), in, out, passphrase, null, // progress PGPMain.decrypt(getBaseContext(), in, out, passphrase, null, // progress
pArgs.getString(arg.SYMMETRIC_PASSPHRASE.name()) != null // symmetric pArgs.getString(arg.SYMMETRIC_PASSPHRASE.name()) != null // symmetric
); );
} catch (Exception e) { } catch (Exception e) {

View File

@ -1,196 +0,0 @@
///*
// * Licensed under the Apache License, Version 2.0 (the "License");
// * you may not use this file except in compliance with the License.
// * You may obtain a copy of the License at
// *
// * http://www.apache.org/licenses/LICENSE-2.0
// *
// * Unless required by applicable law or agreed to in writing, software
// * distributed under the License is distributed on an "AS IS" BASIS,
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// * See the License for the specific language governing permissions and
// * limitations under the License.
// */
//
//package org.thialfihar.android.apg.deprecated;
//
//import java.io.ByteArrayInputStream;
//import java.io.FileNotFoundException;
//import java.io.IOException;
//import java.io.InputStream;
//import java.util.Vector;
//
//import org.thialfihar.android.apg.R;
//import org.thialfihar.android.apg.Id;
//import org.thialfihar.android.apg.helper.PGPHelper;
//import org.thialfihar.android.apg.ui.BaseActivity;
//import org.thialfihar.android.apg.ui.DecryptActivity;
//import org.thialfihar.android.apg.ui.EncryptActivity;
//import org.thialfihar.android.apg.ui.PublicKeyListActivity;
//import org.thialfihar.android.apg.ui.SecretKeyListActivity;
//import org.thialfihar.android.apg.util.Choice;
//
//import android.content.Intent;
//import android.net.Uri;
//import android.os.Bundle;
//import android.view.View;
//import android.view.View.OnClickListener;
//import android.widget.AdapterView;
//import android.widget.AdapterView.OnItemClickListener;
//import android.widget.ArrayAdapter;
//import android.widget.Button;
//import android.widget.ListView;
//import android.widget.Toast;
//
//public class GeneralActivity extends BaseActivity {
// private Intent mIntent;
// private ArrayAdapter<Choice> mAdapter;
// private ListView mList;
// private Button mCancelButton;
// private String mDataString;
// private Uri mDataUri;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.general);
//
// mIntent = getIntent();
//
// InputStream inStream = null;
// {
// String data = mIntent.getStringExtra(Intent.EXTRA_TEXT);
// if (data != null) {
// mDataString = data;
// inStream = new ByteArrayInputStream(data.getBytes());
// }
// }
//
// if (inStream == null) {
// Uri data = mIntent.getData();
// if (data != null) {
// mDataUri = data;
// try {
// inStream = getContentResolver().openInputStream(data);
// } catch (FileNotFoundException e) {
// // didn't work
// Toast.makeText(this, "failed to open stream", Toast.LENGTH_SHORT).show();
// }
// }
// }
//
// if (inStream == null) {
// Toast.makeText(this, "no data found", Toast.LENGTH_SHORT).show();
// finish();
// return;
// }
//
// int contentType = Id.content.unknown;
// try {
// contentType = PGPHelper.getStreamContent(this, inStream);
// inStream.close();
// } catch (IOException e) {
// // just means that there's no PGP data in there
// }
//
// mList = (ListView) findViewById(R.id.options);
// Vector<Choice> choices = new Vector<Choice>();
//
// if (contentType == Id.content.keys) {
// choices.add(new Choice(Id.choice.action.import_public,
// getString(R.string.action_importPublic)));
// choices.add(new Choice(Id.choice.action.import_secret,
// getString(R.string.action_importSecret)));
// }
//
// if (contentType == Id.content.encrypted_data) {
// choices.add(new Choice(Id.choice.action.decrypt, getString(R.string.action_decrypt)));
// }
//
// if (contentType == Id.content.unknown) {
// choices.add(new Choice(Id.choice.action.encrypt, getString(R.string.action_encrypt)));
// }
//
// mAdapter = new ArrayAdapter<Choice>(this, android.R.layout.simple_list_item_1, choices);
// mList.setAdapter(mAdapter);
//
// mList.setOnItemClickListener(new OnItemClickListener() {
// public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// clicked(mAdapter.getItem(arg2).getId());
// }
// });
//
// mCancelButton = (Button) findViewById(R.id.btn_cancel);
// mCancelButton.setOnClickListener(new OnClickListener() {
// public void onClick(View v) {
// GeneralActivity.this.finish();
// }
// });
//
// if (choices.size() == 1) {
// clicked(choices.get(0).getId());
// }
// }
//
// private void clicked(int id) {
// Intent intent = new Intent();
// switch (id) {
// case Id.choice.action.encrypt: {
// intent.setClass(this, EncryptActivity.class);
// if (mDataString != null) {
// intent.setAction(EncryptActivity.ENCRYPT);
// intent.putExtra(PGPHelper.EXTRA_TEXT, mDataString);
// } else if (mDataUri != null) {
// intent.setAction(EncryptActivity.ENCRYPT_FILE);
// intent.setDataAndType(mDataUri, mIntent.getType());
// }
//
// break;
// }
//
// case Id.choice.action.decrypt: {
// intent.setClass(this, DecryptActivity.class);
// if (mDataString != null) {
// intent.setAction(DecryptActivity.DECRYPT);
// intent.putExtra(PGPHelper.EXTRA_TEXT, mDataString);
// } else if (mDataUri != null) {
// intent.setAction(DecryptActivity.DECRYPT_FILE);
// intent.setDataAndType(mDataUri, mIntent.getType());
// }
//
// break;
// }
//
// case Id.choice.action.import_public: {
// intent.setClass(this, PublicKeyListActivity.class);
// intent.setAction(PublicKeyListActivity.IMPORT);
// if (mDataString != null) {
// intent.putExtra(PGPHelper.EXTRA_TEXT, mDataString);
// } else if (mDataUri != null) {
// intent.setDataAndType(mDataUri, mIntent.getType());
// }
// break;
// }
//
// case Id.choice.action.import_secret: {
// intent.setClass(this, SecretKeyListActivity.class);
// intent.setAction(SecretKeyListActivity.IMPORT);
// if (mDataString != null) {
// intent.putExtra(PGPHelper.EXTRA_TEXT, mDataString);
// } else if (mDataUri != null) {
// intent.setDataAndType(mDataUri, mIntent.getType());
// }
// break;
// }
//
// default: {
// // shouldn't happen
// return;
// }
// }
//
// startActivity(intent);
// finish();
// }
//}

View File

@ -23,6 +23,7 @@ import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import org.spongycastle.openpgp.PGPObjectFactory; import org.spongycastle.openpgp.PGPObjectFactory;
import org.spongycastle.openpgp.PGPPublicKeyRing;
import org.spongycastle.openpgp.PGPSecretKey; import org.spongycastle.openpgp.PGPSecretKey;
import org.spongycastle.openpgp.PGPSecretKeyRing; import org.spongycastle.openpgp.PGPSecretKeyRing;
import org.thialfihar.android.apg.Constants; import org.thialfihar.android.apg.Constants;
@ -54,7 +55,7 @@ public class PGPConversionHelper {
} }
/** /**
* Convert from byte[] to ArrayList<PGPSecretKey> * Convert from byte[] to PGPSecretKeyRing
* *
* @param keysBytes * @param keysBytes
* @return * @return
@ -73,6 +74,26 @@ public class PGPConversionHelper {
return keyRing; return keyRing;
} }
/**
* Convert from byte[] to PGPPublicKeyRing
*
* @param keysBytes
* @return
*/
public static PGPPublicKeyRing BytesToPGPPublicKeyRing(byte[] keysBytes) {
PGPObjectFactory factory = new PGPObjectFactory(keysBytes);
PGPPublicKeyRing keyRing = null;
try {
if ((keyRing = (PGPPublicKeyRing) factory.nextObject()) == null) {
Log.e(Constants.TAG, "No keys given!");
}
} catch (IOException e) {
e.printStackTrace();
}
return keyRing;
}
public static ArrayList<PGPSecretKey> BytesToPGPSecretKeyList(byte[] keysBytes) { public static ArrayList<PGPSecretKey> BytesToPGPSecretKeyList(byte[] keysBytes) {
PGPSecretKeyRing keyRing = BytesToPGPSecretKeyRing(keysBytes); PGPSecretKeyRing keyRing = BytesToPGPSecretKeyRing(keysBytes);
ArrayList<PGPSecretKey> keys = new ArrayList<PGPSecretKey>(); ArrayList<PGPSecretKey> keys = new ArrayList<PGPSecretKey>();

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -23,6 +23,7 @@ import org.spongycastle.openpgp.PGPSecretKey;
import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.Id;
import org.thialfihar.android.apg.R; import org.thialfihar.android.apg.R;
import org.thialfihar.android.apg.helper.PGPHelper; import org.thialfihar.android.apg.helper.PGPHelper;
import org.thialfihar.android.apg.helper.PGPMain;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
@ -55,7 +56,7 @@ public class AskForPassphrase {
secretKey = null; secretKey = null;
alert.setMessage(context.getString(R.string.passPhraseForSymmetricEncryption)); alert.setMessage(context.getString(R.string.passPhraseForSymmetricEncryption));
} else { } else {
secretKey = PGPHelper.getMasterKey(PGPHelper.getSecretKeyRing(secretKeyId)); secretKey = PGPHelper.getMasterKey(PGPMain.getSecretKeyRing(secretKeyId));
if (secretKey == null) { if (secretKey == null) {
alert.setTitle(R.string.title_keyNotFound); alert.setTitle(R.string.title_keyNotFound);
alert.setMessage(context.getString(R.string.keyNotFound, secretKeyId)); alert.setMessage(context.getString(R.string.keyNotFound, secretKeyId));
@ -111,7 +112,7 @@ public class AskForPassphrase {
} }
// cache again // cache again
PGPHelper.setCachedPassPhrase(keyId, passPhrase); PGPMain.setCachedPassPhrase(keyId, passPhrase);
// return by callback // return by callback
cb.passPhraseCallback(keyId, passPhrase); cb.passPhraseCallback(keyId, passPhrase);
} }
@ -133,7 +134,7 @@ public class AskForPassphrase {
Log.d("APG", "Key has no passphrase!"); Log.d("APG", "Key has no passphrase!");
// cache null // cache null
PGPHelper.setCachedPassPhrase(secretKey.getKeyID(), null); PGPMain.setCachedPassPhrase(secretKey.getKeyID(), null);
// return by callback // return by callback
cb.passPhraseCallback(secretKey.getKeyID(), null); cb.passPhraseCallback(secretKey.getKeyID(), null);

View File

@ -14,7 +14,7 @@
package org.thialfihar.android.apg.passphrase; package org.thialfihar.android.apg.passphrase;
import org.thialfihar.android.apg.helper.PGPHelper; import org.thialfihar.android.apg.helper.PGPMain;
import org.thialfihar.android.apg.helper.Preferences; import org.thialfihar.android.apg.helper.Preferences;
import android.app.Service; import android.app.Service;
@ -47,7 +47,7 @@ public class PassphraseCacheService extends Service {
delay = 60000; delay = 60000;
} }
delay = PGPHelper.cleanUpCache(mPassPhraseCacheTtl, delay); delay = PGPMain.cleanUpCache(mPassPhraseCacheTtl, delay);
// don't check too often, even if we were close // don't check too often, even if we were close
if (delay < 5000) { if (delay < 5000) {
delay = 5000; delay = 5000;

View File

@ -33,9 +33,9 @@ import org.thialfihar.android.apg.Id;
import org.thialfihar.android.apg.ProgressDialogUpdater; import org.thialfihar.android.apg.ProgressDialogUpdater;
import org.thialfihar.android.apg.R; import org.thialfihar.android.apg.R;
import org.thialfihar.android.apg.helper.FileHelper; import org.thialfihar.android.apg.helper.FileHelper;
import org.thialfihar.android.apg.helper.PGPHelper; import org.thialfihar.android.apg.helper.PGPMain;
import org.thialfihar.android.apg.helper.Preferences; import org.thialfihar.android.apg.helper.Preferences;
import org.thialfihar.android.apg.helper.PGPHelper.GeneralException; import org.thialfihar.android.apg.helper.PGPMain.GeneralException;
import org.thialfihar.android.apg.helper.PGPConversionHelper; import org.thialfihar.android.apg.helper.PGPConversionHelper;
import org.thialfihar.android.apg.provider.DataProvider; import org.thialfihar.android.apg.provider.DataProvider;
import org.thialfihar.android.apg.util.InputData; import org.thialfihar.android.apg.util.InputData;
@ -197,9 +197,9 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
long masterKeyId = data.getLong(MASTER_KEY_ID); long masterKeyId = data.getLong(MASTER_KEY_ID);
/* Operation */ /* Operation */
PGPHelper.buildSecretKey(this, userIds, keys, keysUsages, masterKeyId, PGPMain.buildSecretKey(this, userIds, keys, keysUsages, masterKeyId,
oldPassPhrase, newPassPhrase, this); oldPassPhrase, newPassPhrase, this);
PGPHelper.setCachedPassPhrase(masterKeyId, newPassPhrase); PGPMain.setCachedPassPhrase(masterKeyId, newPassPhrase);
/* Output */ /* Output */
sendMessageToHandler(ApgHandler.MESSAGE_OKAY); sendMessageToHandler(ApgHandler.MESSAGE_OKAY);
@ -223,7 +223,7 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
} }
/* Operation */ /* Operation */
PGPSecretKeyRing newKeyRing = PGPHelper.createKey(this, algorithm, keysize, PGPSecretKeyRing newKeyRing = PGPMain.createKey(this, algorithm, keysize,
passphrase, masterKey); passphrase, masterKey);
/* Output */ /* Output */
@ -244,10 +244,10 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
String passphrase = data.getString(SYMMETRIC_PASSPHRASE); String passphrase = data.getString(SYMMETRIC_PASSPHRASE);
/* Operation */ /* Operation */
PGPSecretKeyRing masterKeyRing = PGPHelper.createKey(this, Id.choice.algorithm.rsa, PGPSecretKeyRing masterKeyRing = PGPMain.createKey(this, Id.choice.algorithm.rsa,
2048, passphrase, null); 2048, passphrase, null);
PGPSecretKeyRing subKeyRing = PGPHelper.createKey(this, Id.choice.algorithm.rsa, PGPSecretKeyRing subKeyRing = PGPMain.createKey(this, Id.choice.algorithm.rsa,
2048, passphrase, masterKeyRing.getSecretKey()); 2048, passphrase, masterKeyRing.getSecretKey());
/* Output */ /* Output */
@ -288,20 +288,20 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
if (generateSignature) { if (generateSignature) {
Log.d(Constants.TAG, "generate signature..."); Log.d(Constants.TAG, "generate signature...");
PGPHelper.generateSignature(this, inputData, outStream, useAsciiArmour, false, PGPMain.generateSignature(this, inputData, outStream, useAsciiArmour, false,
secretKeyId, PGPHelper.getCachedPassPhrase(secretKeyId), Preferences secretKeyId, PGPMain.getCachedPassPhrase(secretKeyId), Preferences
.getPreferences(this).getDefaultHashAlgorithm(), Preferences .getPreferences(this).getDefaultHashAlgorithm(), Preferences
.getPreferences(this).getForceV3Signatures(), this); .getPreferences(this).getForceV3Signatures(), this);
} else if (signOnly) { } else if (signOnly) {
Log.d(Constants.TAG, "sign only..."); Log.d(Constants.TAG, "sign only...");
PGPHelper.signText(this, inputData, outStream, secretKeyId, PGPHelper PGPMain.signText(this, inputData, outStream, secretKeyId, PGPMain
.getCachedPassPhrase(secretKeyId), Preferences.getPreferences(this) .getCachedPassPhrase(secretKeyId), Preferences.getPreferences(this)
.getDefaultHashAlgorithm(), Preferences.getPreferences(this) .getDefaultHashAlgorithm(), Preferences.getPreferences(this)
.getForceV3Signatures(), this); .getForceV3Signatures(), this);
} else { } else {
Log.d(Constants.TAG, "encrypt..."); Log.d(Constants.TAG, "encrypt...");
PGPHelper.encrypt(this, inputData, outStream, useAsciiArmour, encryptionKeyIds, PGPMain.encrypt(this, inputData, outStream, useAsciiArmour, encryptionKeyIds,
signatureKeyId, PGPHelper.getCachedPassPhrase(signatureKeyId), this, signatureKeyId, PGPMain.getCachedPassPhrase(signatureKeyId), this,
Preferences.getPreferences(this).getDefaultEncryptionAlgorithm(), Preferences.getPreferences(this).getDefaultEncryptionAlgorithm(),
Preferences.getPreferences(this).getDefaultHashAlgorithm(), Preferences.getPreferences(this).getDefaultHashAlgorithm(),
compressionId, Preferences.getPreferences(this).getForceV3Signatures(), compressionId, Preferences.getPreferences(this).getForceV3Signatures(),
@ -373,20 +373,20 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
if (generateSignature) { if (generateSignature) {
Log.d(Constants.TAG, "generate signature..."); Log.d(Constants.TAG, "generate signature...");
PGPHelper.generateSignature(this, inputData, outStream, useAsciiArmour, true, PGPMain.generateSignature(this, inputData, outStream, useAsciiArmour, true,
secretKeyId, PGPHelper.getCachedPassPhrase(secretKeyId), Preferences secretKeyId, PGPMain.getCachedPassPhrase(secretKeyId), Preferences
.getPreferences(this).getDefaultHashAlgorithm(), Preferences .getPreferences(this).getDefaultHashAlgorithm(), Preferences
.getPreferences(this).getForceV3Signatures(), this); .getPreferences(this).getForceV3Signatures(), this);
} else if (signOnly) { } else if (signOnly) {
Log.d(Constants.TAG, "sign only..."); Log.d(Constants.TAG, "sign only...");
PGPHelper.signText(this, inputData, outStream, secretKeyId, PGPHelper PGPMain.signText(this, inputData, outStream, secretKeyId, PGPMain
.getCachedPassPhrase(secretKeyId), Preferences.getPreferences(this) .getCachedPassPhrase(secretKeyId), Preferences.getPreferences(this)
.getDefaultHashAlgorithm(), Preferences.getPreferences(this) .getDefaultHashAlgorithm(), Preferences.getPreferences(this)
.getForceV3Signatures(), this); .getForceV3Signatures(), this);
} else { } else {
Log.d(Constants.TAG, "encrypt..."); Log.d(Constants.TAG, "encrypt...");
PGPHelper.encrypt(this, inputData, outStream, useAsciiArmour, encryptionKeyIds, PGPMain.encrypt(this, inputData, outStream, useAsciiArmour, encryptionKeyIds,
signatureKeyId, PGPHelper.getCachedPassPhrase(signatureKeyId), this, signatureKeyId, PGPMain.getCachedPassPhrase(signatureKeyId), this,
Preferences.getPreferences(this).getDefaultEncryptionAlgorithm(), Preferences.getPreferences(this).getDefaultEncryptionAlgorithm(),
Preferences.getPreferences(this).getDefaultHashAlgorithm(), Preferences.getPreferences(this).getDefaultHashAlgorithm(),
compressionId, Preferences.getPreferences(this).getForceV3Signatures(), compressionId, Preferences.getPreferences(this).getForceV3Signatures(),
@ -420,16 +420,16 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
/* Operation */ /* Operation */
// InputStream // InputStream
InputStream in = getContentResolver().openInputStream(providerUri); InputStream in = getContentResolver().openInputStream(providerUri);
long inLength = PGPHelper.getLengthOfStream(in); long inLength = PGPMain.getLengthOfStream(in);
InputData inputData = new InputData(in, inLength); InputData inputData = new InputData(in, inLength);
// OutputStream // OutputStream
String streamFilename = null; String streamFilename = null;
try { try {
while (true) { while (true) {
streamFilename = PGPHelper.generateRandomString(32); streamFilename = PGPMain.generateRandomString(32);
if (streamFilename == null) { if (streamFilename == null) {
throw new PGPHelper.GeneralException( throw new PGPMain.GeneralException(
"couldn't generate random file name"); "couldn't generate random file name");
} }
openFileInput(streamFilename).close(); openFileInput(streamFilename).close();
@ -440,18 +440,18 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
FileOutputStream outStream = openFileOutput(streamFilename, Context.MODE_PRIVATE); FileOutputStream outStream = openFileOutput(streamFilename, Context.MODE_PRIVATE);
if (generateSignature) { if (generateSignature) {
PGPHelper.generateSignature(this, inputData, outStream, useAsciiArmour, true, PGPMain.generateSignature(this, inputData, outStream, useAsciiArmour, true,
secretKeyId, PGPHelper.getCachedPassPhrase(secretKeyId), Preferences secretKeyId, PGPMain.getCachedPassPhrase(secretKeyId), Preferences
.getPreferences(this).getDefaultHashAlgorithm(), Preferences .getPreferences(this).getDefaultHashAlgorithm(), Preferences
.getPreferences(this).getForceV3Signatures(), this); .getPreferences(this).getForceV3Signatures(), this);
} else if (signOnly) { } else if (signOnly) {
PGPHelper.signText(this, inputData, outStream, secretKeyId, PGPHelper PGPMain.signText(this, inputData, outStream, secretKeyId, PGPMain
.getCachedPassPhrase(secretKeyId), Preferences.getPreferences(this) .getCachedPassPhrase(secretKeyId), Preferences.getPreferences(this)
.getDefaultHashAlgorithm(), Preferences.getPreferences(this) .getDefaultHashAlgorithm(), Preferences.getPreferences(this)
.getForceV3Signatures(), this); .getForceV3Signatures(), this);
} else { } else {
PGPHelper.encrypt(this, inputData, outStream, useAsciiArmour, encryptionKeyIds, PGPMain.encrypt(this, inputData, outStream, useAsciiArmour, encryptionKeyIds,
signatureKeyId, PGPHelper.getCachedPassPhrase(signatureKeyId), this, signatureKeyId, PGPMain.getCachedPassPhrase(signatureKeyId), this,
Preferences.getPreferences(this).getDefaultEncryptionAlgorithm(), Preferences.getPreferences(this).getDefaultEncryptionAlgorithm(),
Preferences.getPreferences(this).getDefaultHashAlgorithm(), Preferences.getPreferences(this).getDefaultHashAlgorithm(),
compressionId, Preferences.getPreferences(this).getForceV3Signatures(), compressionId, Preferences.getPreferences(this).getForceV3Signatures(),
@ -480,12 +480,12 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
/* Operation */ /* Operation */
try { try {
PGPHelper.deleteFileSecurely(this, new File(deleteFile), this); PGPMain.deleteFileSecurely(this, new File(deleteFile), this);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
throw new PGPHelper.GeneralException(getString(R.string.error_fileNotFound, throw new PGPMain.GeneralException(getString(R.string.error_fileNotFound,
deleteFile)); deleteFile));
} catch (IOException e) { } catch (IOException e) {
throw new PGPHelper.GeneralException(getString(R.string.error_fileDeleteFailed, throw new PGPMain.GeneralException(getString(R.string.error_fileDeleteFailed,
deleteFile)); deleteFile));
} }
@ -518,10 +518,10 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
// verifyText and decrypt returning additional resultData values for the // verifyText and decrypt returning additional resultData values for the
// verification of signatures // verification of signatures
if (signedOnly) { if (signedOnly) {
resultData = PGPHelper.verifyText(this, inputData, outStream, this); resultData = PGPMain.verifyText(this, inputData, outStream, this);
} else { } else {
resultData = PGPHelper.decrypt(this, inputData, outStream, resultData = PGPMain.decrypt(this, inputData, outStream,
PGPHelper.getCachedPassPhrase(secretKeyId), this, PGPMain.getCachedPassPhrase(secretKeyId), this,
assumeSymmetricEncryption); assumeSymmetricEncryption);
} }
@ -577,10 +577,10 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
// verifyText and decrypt returning additional output values for the // verifyText and decrypt returning additional output values for the
// verification of signatures // verification of signatures
if (signedOnly) { if (signedOnly) {
resultData = PGPHelper.verifyText(this, inputData, outStream, this); resultData = PGPMain.verifyText(this, inputData, outStream, this);
} else { } else {
resultData = PGPHelper.decrypt(this, inputData, outStream, resultData = PGPMain.decrypt(this, inputData, outStream,
PGPHelper.getCachedPassPhrase(secretKeyId), this, PGPMain.getCachedPassPhrase(secretKeyId), this,
assumeSymmetricEncryption); assumeSymmetricEncryption);
} }
@ -604,16 +604,16 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
/* Operation */ /* Operation */
// InputStream // InputStream
InputStream in = getContentResolver().openInputStream(providerUri); InputStream in = getContentResolver().openInputStream(providerUri);
long inLength = PGPHelper.getLengthOfStream(in); long inLength = PGPMain.getLengthOfStream(in);
InputData inputData = new InputData(in, inLength); InputData inputData = new InputData(in, inLength);
// OutputStream // OutputStream
String streamFilename = null; String streamFilename = null;
try { try {
while (true) { while (true) {
streamFilename = PGPHelper.generateRandomString(32); streamFilename = PGPMain.generateRandomString(32);
if (streamFilename == null) { if (streamFilename == null) {
throw new PGPHelper.GeneralException( throw new PGPMain.GeneralException(
"couldn't generate random file name"); "couldn't generate random file name");
} }
openFileInput(streamFilename).close(); openFileInput(streamFilename).close();
@ -628,10 +628,10 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
// verifyText and decrypt returning additional output values for the // verifyText and decrypt returning additional output values for the
// verification of signatures // verification of signatures
if (signedOnly) { if (signedOnly) {
resultData = PGPHelper.verifyText(this, inputData, outStream, this); resultData = PGPMain.verifyText(this, inputData, outStream, this);
} else { } else {
resultData = PGPHelper.decrypt(this, inputData, outStream, resultData = PGPMain.decrypt(this, inputData, outStream,
PGPHelper.getCachedPassPhrase(secretKeyId), this, PGPMain.getCachedPassPhrase(secretKeyId), this,
assumeSymmetricEncryption); assumeSymmetricEncryption);
} }

View File

@ -25,7 +25,7 @@ import org.thialfihar.android.apg.Constants;
import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.Id;
import org.thialfihar.android.apg.ProgressDialogUpdater; import org.thialfihar.android.apg.ProgressDialogUpdater;
import org.thialfihar.android.apg.deprecated.PausableThread; import org.thialfihar.android.apg.deprecated.PausableThread;
import org.thialfihar.android.apg.helper.PGPHelper; import org.thialfihar.android.apg.helper.PGPMain;
import org.thialfihar.android.apg.helper.Preferences; import org.thialfihar.android.apg.helper.Preferences;
import org.thialfihar.android.apg.passphrase.AskForPassphrase; import org.thialfihar.android.apg.passphrase.AskForPassphrase;
import org.thialfihar.android.apg.passphrase.PassphraseCacheService; import org.thialfihar.android.apg.passphrase.PassphraseCacheService;
@ -79,7 +79,7 @@ public class BaseActivity extends SherlockFragmentActivity implements Runnable,
// not needed later: // not needed later:
mPreferences = Preferences.getPreferences(this); mPreferences = Preferences.getPreferences(this);
PGPHelper.initialize(this); PGPMain.initialize(this);
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
File dir = new File(Constants.path.APP_DIR); File dir = new File(Constants.path.APP_DIR);
@ -378,7 +378,7 @@ public class BaseActivity extends SherlockFragmentActivity implements Runnable,
public void passPhraseCallback(long keyId, String passPhrase) { public void passPhraseCallback(long keyId, String passPhrase) {
// TODO: Not needed anymore, now implemented in AskForSecretKeyPass // TODO: Not needed anymore, now implemented in AskForSecretKeyPass
PGPHelper.setCachedPassPhrase(keyId, passPhrase); PGPMain.setCachedPassPhrase(keyId, passPhrase);
} }
public void sendMessage(Message msg) { public void sendMessage(Message msg) {

View File

@ -21,6 +21,7 @@ import org.thialfihar.android.apg.Constants;
import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.Id;
import org.thialfihar.android.apg.helper.FileHelper; import org.thialfihar.android.apg.helper.FileHelper;
import org.thialfihar.android.apg.helper.PGPHelper; import org.thialfihar.android.apg.helper.PGPHelper;
import org.thialfihar.android.apg.helper.PGPMain;
import org.thialfihar.android.apg.service.ApgHandler; import org.thialfihar.android.apg.service.ApgHandler;
import org.thialfihar.android.apg.service.ApgService; import org.thialfihar.android.apg.service.ApgService;
import org.thialfihar.android.apg.ui.dialog.DeleteFileDialogFragment; import org.thialfihar.android.apg.ui.dialog.DeleteFileDialogFragment;
@ -299,7 +300,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
} }
if (textData != null) { if (textData != null) {
Log.d(Constants.TAG, "textData null, matching text ..."); Log.d(Constants.TAG, "textData null, matching text ...");
Matcher matcher = PGPHelper.PGP_MESSAGE.matcher(textData); Matcher matcher = PGPMain.PGP_MESSAGE.matcher(textData);
if (matcher.matches()) { if (matcher.matches()) {
Log.d(Constants.TAG, "PGP_MESSAGE matched"); Log.d(Constants.TAG, "PGP_MESSAGE matched");
textData = matcher.group(1); textData = matcher.group(1);
@ -307,7 +308,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
textData = textData.replaceAll("\\xa0", " "); textData = textData.replaceAll("\\xa0", " ");
mMessage.setText(textData); mMessage.setText(textData);
} else { } else {
matcher = PGPHelper.PGP_SIGNED_MESSAGE.matcher(textData); matcher = PGPMain.PGP_SIGNED_MESSAGE.matcher(textData);
if (matcher.matches()) { if (matcher.matches()) {
Log.d(Constants.TAG, "PGP_SIGNED_MESSAGE matched"); Log.d(Constants.TAG, "PGP_SIGNED_MESSAGE matched");
textData = matcher.group(1); textData = matcher.group(1);
@ -350,14 +351,14 @@ public class DecryptActivity extends SherlockFragmentActivity {
mData = extras.getByteArray(EXTRA_DATA); mData = extras.getByteArray(EXTRA_DATA);
String data = extras.getString(EXTRA_TEXT); String data = extras.getString(EXTRA_TEXT);
if (data != null) { if (data != null) {
Matcher matcher = PGPHelper.PGP_MESSAGE.matcher(data); Matcher matcher = PGPMain.PGP_MESSAGE.matcher(data);
if (matcher.matches()) { if (matcher.matches()) {
data = matcher.group(1); data = matcher.group(1);
// replace non breakable spaces // replace non breakable spaces
data = data.replaceAll("\\xa0", " "); data = data.replaceAll("\\xa0", " ");
mMessage.setText(data); mMessage.setText(data);
} else { } else {
matcher = PGPHelper.PGP_SIGNED_MESSAGE.matcher(data); matcher = PGPMain.PGP_SIGNED_MESSAGE.matcher(data);
if (matcher.matches()) { if (matcher.matches()) {
data = matcher.group(1); data = matcher.group(1);
// replace non breakable spaces // replace non breakable spaces
@ -381,9 +382,9 @@ public class DecryptActivity extends SherlockFragmentActivity {
String data = ""; String data = "";
if (clipboardText != null) { if (clipboardText != null) {
Matcher matcher = PGPHelper.PGP_MESSAGE.matcher(clipboardText); Matcher matcher = PGPMain.PGP_MESSAGE.matcher(clipboardText);
if (!matcher.matches()) { if (!matcher.matches()) {
matcher = PGPHelper.PGP_SIGNED_MESSAGE.matcher(clipboardText); matcher = PGPMain.PGP_SIGNED_MESSAGE.matcher(clipboardText);
} }
if (matcher.matches()) { if (matcher.matches()) {
data = matcher.group(1); data = matcher.group(1);
@ -399,7 +400,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
if (mSignatureKeyId == 0) { if (mSignatureKeyId == 0) {
return; return;
} }
PGPPublicKeyRing key = PGPHelper.getPublicKeyRing(mSignatureKeyId); PGPPublicKeyRing key = PGPMain.getPublicKeyRing(mSignatureKeyId);
if (key != null) { if (key != null) {
Intent intent = new Intent(DecryptActivity.this, KeyServerQueryActivity.class); Intent intent = new Intent(DecryptActivity.this, KeyServerQueryActivity.class);
intent.setAction(KeyServerQueryActivity.ACTION_LOOK_UP_KEY_ID); intent.setAction(KeyServerQueryActivity.ACTION_LOOK_UP_KEY_ID);
@ -506,7 +507,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
if (mDecryptTarget == Id.target.message) { if (mDecryptTarget == Id.target.message) {
String messageData = mMessage.getText().toString(); String messageData = mMessage.getText().toString();
Matcher matcher = PGPHelper.PGP_SIGNED_MESSAGE.matcher(messageData); Matcher matcher = PGPMain.PGP_SIGNED_MESSAGE.matcher(messageData);
if (matcher.matches()) { if (matcher.matches()) {
mSignedOnly = true; mSignedOnly = true;
decryptStart(); decryptStart();
@ -523,7 +524,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
// if we need a symmetric passphrase or a passphrase to use a sekret key ask for it // if we need a symmetric passphrase or a passphrase to use a sekret key ask for it
if (getSecretKeyId() == Id.key.symmetric if (getSecretKeyId() == Id.key.symmetric
|| PGPHelper.getCachedPassPhrase(getSecretKeyId()) == null) { || PGPMain.getCachedPassPhrase(getSecretKeyId()) == null) {
// showDialog(Id.dialog.pass_phrase); // showDialog(Id.dialog.pass_phrase);
showPassphraseDialog(); showPassphraseDialog();
} else { } else {
@ -563,7 +564,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
messenger, mSecretKeyId); messenger, mSecretKeyId);
passphraseDialog.show(getSupportFragmentManager(), "passphraseDialog"); passphraseDialog.show(getSupportFragmentManager(), "passphraseDialog");
} catch (PGPHelper.GeneralException e) { } catch (PGPMain.GeneralException e) {
Log.d(Constants.TAG, "No passphrase for this secret key, encrypt directly!"); Log.d(Constants.TAG, "No passphrase for this secret key, encrypt directly!");
// send message to handler to start encryption directly // send message to handler to start encryption directly
returnHandler.sendEmptyMessage(PassphraseDialogFragment.MESSAGE_OKAY); returnHandler.sendEmptyMessage(PassphraseDialogFragment.MESSAGE_OKAY);
@ -609,15 +610,15 @@ public class DecryptActivity extends SherlockFragmentActivity {
try { try {
try { try {
setSecretKeyId(PGPHelper.getDecryptionKeyId(this, inStream)); setSecretKeyId(PGPMain.getDecryptionKeyId(this, inStream));
if (getSecretKeyId() == Id.key.none) { if (getSecretKeyId() == Id.key.none) {
throw new PGPHelper.GeneralException(getString(R.string.error_noSecretKeyFound)); throw new PGPMain.GeneralException(getString(R.string.error_noSecretKeyFound));
} }
mAssumeSymmetricEncryption = false; mAssumeSymmetricEncryption = false;
} catch (PGPHelper.NoAsymmetricEncryptionException e) { } catch (PGPMain.NoAsymmetricEncryptionException e) {
setSecretKeyId(Id.key.symmetric); setSecretKeyId(Id.key.symmetric);
if (!PGPHelper.hasSymmetricEncryption(this, inStream)) { if (!PGPMain.hasSymmetricEncryption(this, inStream)) {
throw new PGPHelper.GeneralException( throw new PGPMain.GeneralException(
getString(R.string.error_noKnownEncryptionFound)); getString(R.string.error_noKnownEncryptionFound));
} }
mAssumeSymmetricEncryption = true; mAssumeSymmetricEncryption = true;

View File

@ -22,6 +22,7 @@ import org.spongycastle.openpgp.PGPSecretKeyRing;
import org.thialfihar.android.apg.Constants; import org.thialfihar.android.apg.Constants;
import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.Id;
import org.thialfihar.android.apg.helper.PGPHelper; import org.thialfihar.android.apg.helper.PGPHelper;
import org.thialfihar.android.apg.helper.PGPMain;
import org.thialfihar.android.apg.helper.OtherHelper; import org.thialfihar.android.apg.helper.OtherHelper;
import org.thialfihar.android.apg.helper.PGPConversionHelper; import org.thialfihar.android.apg.helper.PGPConversionHelper;
import org.thialfihar.android.apg.service.ApgHandler; import org.thialfihar.android.apg.service.ApgHandler;
@ -256,7 +257,7 @@ public class EditKeyActivity extends SherlockFragmentActivity {
} else if (ACTION_EDIT_KEY.equals(mIntent.getAction())) { } else if (ACTION_EDIT_KEY.equals(mIntent.getAction())) {
mActionBar.setTitle(R.string.title_editKey); mActionBar.setTitle(R.string.title_editKey);
mCurrentPassPhrase = PGPHelper.getEditPassPhrase(); mCurrentPassPhrase = PGPMain.getEditPassPhrase();
if (mCurrentPassPhrase == null) { if (mCurrentPassPhrase == null) {
mCurrentPassPhrase = ""; mCurrentPassPhrase = "";
} }
@ -274,7 +275,7 @@ public class EditKeyActivity extends SherlockFragmentActivity {
if (keyId != 0) { if (keyId != 0) {
PGPSecretKey masterKey = null; PGPSecretKey masterKey = null;
mKeyRing = PGPHelper.getSecretKeyRing(keyId); mKeyRing = PGPMain.getSecretKeyRing(keyId);
if (mKeyRing != null) { if (mKeyRing != null) {
masterKey = PGPHelper.getMasterKey(mKeyRing); masterKey = PGPHelper.getMasterKey(mKeyRing);
for (PGPSecretKey key : new IterableIterator<PGPSecretKey>( for (PGPSecretKey key : new IterableIterator<PGPSecretKey>(
@ -420,7 +421,7 @@ public class EditKeyActivity extends SherlockFragmentActivity {
try { try {
if (!isPassphraseSet()) { if (!isPassphraseSet()) {
throw new PGPHelper.GeneralException(this.getString(R.string.setAPassPhrase)); throw new PGPMain.GeneralException(this.getString(R.string.setAPassPhrase));
} }
// Send all information needed to service to edit key in other thread // Send all information needed to service to edit key in other thread
@ -464,7 +465,7 @@ public class EditKeyActivity extends SherlockFragmentActivity {
// start service with intent // start service with intent
startService(intent); startService(intent);
} catch (PGPHelper.GeneralException e) { } catch (PGPMain.GeneralException e) {
Toast.makeText(this, getString(R.string.errorMessage, e.getMessage()), Toast.makeText(this, getString(R.string.errorMessage, e.getMessage()),
Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show();
} }
@ -476,7 +477,7 @@ public class EditKeyActivity extends SherlockFragmentActivity {
* @param userIdsView * @param userIdsView
* @return * @return
*/ */
private Vector<String> getUserIds(SectionView userIdsView) throws PGPHelper.GeneralException { private Vector<String> getUserIds(SectionView userIdsView) throws PGPMain.GeneralException {
Vector<String> userIds = new Vector<String>(); Vector<String> userIds = new Vector<String>();
ViewGroup userIdEditors = userIdsView.getEditors(); ViewGroup userIdEditors = userIdsView.getEditors();
@ -488,13 +489,13 @@ public class EditKeyActivity extends SherlockFragmentActivity {
try { try {
userId = editor.getValue(); userId = editor.getValue();
} catch (UserIdEditor.NoNameException e) { } catch (UserIdEditor.NoNameException e) {
throw new PGPHelper.GeneralException( throw new PGPMain.GeneralException(
this.getString(R.string.error_userIdNeedsAName)); this.getString(R.string.error_userIdNeedsAName));
} catch (UserIdEditor.NoEmailException e) { } catch (UserIdEditor.NoEmailException e) {
throw new PGPHelper.GeneralException( throw new PGPMain.GeneralException(
this.getString(R.string.error_userIdNeedsAnEmailAddress)); this.getString(R.string.error_userIdNeedsAnEmailAddress));
} catch (UserIdEditor.InvalidEmailException e) { } catch (UserIdEditor.InvalidEmailException e) {
throw new PGPHelper.GeneralException(e.getMessage()); throw new PGPMain.GeneralException(e.getMessage());
} }
if (userId.equals("")) { if (userId.equals("")) {
@ -510,11 +511,11 @@ public class EditKeyActivity extends SherlockFragmentActivity {
} }
if (userIds.size() == 0) { if (userIds.size() == 0) {
throw new PGPHelper.GeneralException(getString(R.string.error_keyNeedsAUserId)); throw new PGPMain.GeneralException(getString(R.string.error_keyNeedsAUserId));
} }
if (!gotMainUserId) { if (!gotMainUserId) {
throw new PGPHelper.GeneralException(getString(R.string.error_mainUserIdMustNotBeEmpty)); throw new PGPMain.GeneralException(getString(R.string.error_mainUserIdMustNotBeEmpty));
} }
return userIds; return userIds;
@ -526,13 +527,13 @@ public class EditKeyActivity extends SherlockFragmentActivity {
* @param keysView * @param keysView
* @return * @return
*/ */
private Vector<PGPSecretKey> getKeys(SectionView keysView) throws PGPHelper.GeneralException { private Vector<PGPSecretKey> getKeys(SectionView keysView) throws PGPMain.GeneralException {
Vector<PGPSecretKey> keys = new Vector<PGPSecretKey>(); Vector<PGPSecretKey> keys = new Vector<PGPSecretKey>();
ViewGroup keyEditors = keysView.getEditors(); ViewGroup keyEditors = keysView.getEditors();
if (keyEditors.getChildCount() == 0) { if (keyEditors.getChildCount() == 0) {
throw new PGPHelper.GeneralException(getString(R.string.error_keyNeedsMasterKey)); throw new PGPMain.GeneralException(getString(R.string.error_keyNeedsMasterKey));
} }
for (int i = 0; i < keyEditors.getChildCount(); ++i) { for (int i = 0; i < keyEditors.getChildCount(); ++i) {
@ -549,13 +550,13 @@ public class EditKeyActivity extends SherlockFragmentActivity {
* @param keysView * @param keysView
* @return * @return
*/ */
private Vector<Integer> getKeysUsages(SectionView keysView) throws PGPHelper.GeneralException { private Vector<Integer> getKeysUsages(SectionView keysView) throws PGPMain.GeneralException {
Vector<Integer> getKeysUsages = new Vector<Integer>(); Vector<Integer> getKeysUsages = new Vector<Integer>();
ViewGroup keyEditors = keysView.getEditors(); ViewGroup keyEditors = keysView.getEditors();
if (keyEditors.getChildCount() == 0) { if (keyEditors.getChildCount() == 0) {
throw new PGPHelper.GeneralException(getString(R.string.error_keyNeedsMasterKey)); throw new PGPMain.GeneralException(getString(R.string.error_keyNeedsMasterKey));
} }
for (int i = 0; i < keyEditors.getChildCount(); ++i) { for (int i = 0; i < keyEditors.getChildCount(); ++i) {

View File

@ -25,6 +25,7 @@ import org.thialfihar.android.apg.Constants;
import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.Id;
import org.thialfihar.android.apg.helper.FileHelper; import org.thialfihar.android.apg.helper.FileHelper;
import org.thialfihar.android.apg.helper.PGPHelper; import org.thialfihar.android.apg.helper.PGPHelper;
import org.thialfihar.android.apg.helper.PGPMain;
import org.thialfihar.android.apg.helper.Preferences; import org.thialfihar.android.apg.helper.Preferences;
import org.thialfihar.android.apg.service.ApgHandler; import org.thialfihar.android.apg.service.ApgHandler;
import org.thialfihar.android.apg.service.ApgService; import org.thialfihar.android.apg.service.ApgService;
@ -390,7 +391,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
long signatureKeyId = extras.getLong(EXTRA_SIGNATURE_KEY_ID); long signatureKeyId = extras.getLong(EXTRA_SIGNATURE_KEY_ID);
long encryptionKeyIds[] = extras.getLongArray(EXTRA_ENCRYPTION_KEY_IDS); long encryptionKeyIds[] = extras.getLongArray(EXTRA_ENCRYPTION_KEY_IDS);
if (signatureKeyId != 0) { if (signatureKeyId != 0) {
PGPSecretKeyRing keyRing = PGPHelper.getSecretKeyRing(signatureKeyId); PGPSecretKeyRing keyRing = PGPMain.getSecretKeyRing(signatureKeyId);
PGPSecretKey masterKey = null; PGPSecretKey masterKey = null;
if (keyRing != null) { if (keyRing != null) {
masterKey = PGPHelper.getMasterKey(keyRing); masterKey = PGPHelper.getMasterKey(keyRing);
@ -406,7 +407,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
if (encryptionKeyIds != null) { if (encryptionKeyIds != null) {
Vector<Long> goodIds = new Vector<Long>(); Vector<Long> goodIds = new Vector<Long>();
for (int i = 0; i < encryptionKeyIds.length; ++i) { for (int i = 0; i < encryptionKeyIds.length; ++i) {
PGPPublicKeyRing keyRing = PGPHelper.getPublicKeyRing(encryptionKeyIds[i]); PGPPublicKeyRing keyRing = PGPMain.getPublicKeyRing(encryptionKeyIds[i]);
PGPPublicKey masterKey = null; PGPPublicKey masterKey = null;
if (keyRing == null) { if (keyRing == null) {
continue; continue;
@ -669,7 +670,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
return; return;
} }
if (getSecretKeyId() != 0 && PGPHelper.getCachedPassPhrase(getSecretKeyId()) == null) { if (getSecretKeyId() != 0 && PGPMain.getCachedPassPhrase(getSecretKeyId()) == null) {
showPassphraseDialog(); showPassphraseDialog();
return; return;
@ -710,7 +711,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
messenger, mSecretKeyId); messenger, mSecretKeyId);
passphraseDialog.show(getSupportFragmentManager(), "passphraseDialog"); passphraseDialog.show(getSupportFragmentManager(), "passphraseDialog");
} catch (PGPHelper.GeneralException e) { } catch (PGPMain.GeneralException e) {
Log.d(Constants.TAG, "No passphrase for this secret key, encrypt directly!"); Log.d(Constants.TAG, "No passphrase for this secret key, encrypt directly!");
// send message to handler to start encryption directly // send message to handler to start encryption directly
returnHandler.sendEmptyMessage(PassphraseDialogFragment.MESSAGE_OKAY); returnHandler.sendEmptyMessage(PassphraseDialogFragment.MESSAGE_OKAY);
@ -935,7 +936,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
} else { } else {
String uid = getResources().getString(R.string.unknownUserId); String uid = getResources().getString(R.string.unknownUserId);
String uidExtra = ""; String uidExtra = "";
PGPSecretKeyRing keyRing = PGPHelper.getSecretKeyRing(getSecretKeyId()); PGPSecretKeyRing keyRing = PGPMain.getSecretKeyRing(getSecretKeyId());
if (keyRing != null) { if (keyRing != null) {
PGPSecretKey key = PGPHelper.getMasterKey(keyRing); PGPSecretKey key = PGPHelper.getMasterKey(keyRing);
if (key != null) { if (key != null) {

View File

@ -24,6 +24,7 @@ import org.spongycastle.openpgp.PGPPublicKeyRing;
import org.thialfihar.android.apg.Constants; import org.thialfihar.android.apg.Constants;
import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.Id;
import org.thialfihar.android.apg.helper.PGPHelper; import org.thialfihar.android.apg.helper.PGPHelper;
import org.thialfihar.android.apg.helper.PGPMain;
import org.thialfihar.android.apg.util.HkpKeyServer; import org.thialfihar.android.apg.util.HkpKeyServer;
import org.thialfihar.android.apg.util.KeyServer.QueryException; import org.thialfihar.android.apg.util.KeyServer.QueryException;
import org.thialfihar.android.apg.R; import org.thialfihar.android.apg.R;
@ -83,7 +84,7 @@ public class ImportFromQRCodeActivity extends BaseActivity {
.getPublicKey().getFingerprint()); .getPublicKey().getFingerprint());
if (expectedFingerprint.equals(actualFingerprint)) { if (expectedFingerprint.equals(actualFingerprint)) {
// store the signed key in our local cache // store the signed key in our local cache
int retval = PGPHelper.storeKeyRingInCache(publicKeyRing); int retval = PGPMain.storeKeyRingInCache(publicKeyRing);
if (retval != Id.return_value.ok if (retval != Id.return_value.ok
&& retval != Id.return_value.updated) { && retval != Id.return_value.updated) {
status.putString(EXTRA_ERROR, status.putString(EXTRA_ERROR,

View File

@ -22,6 +22,7 @@ import org.spongycastle.openpgp.PGPSecretKeyRing;
import org.thialfihar.android.apg.Constants; import org.thialfihar.android.apg.Constants;
import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.Id;
import org.thialfihar.android.apg.helper.PGPHelper; import org.thialfihar.android.apg.helper.PGPHelper;
import org.thialfihar.android.apg.helper.PGPMain;
import org.thialfihar.android.apg.provider.KeyRings; import org.thialfihar.android.apg.provider.KeyRings;
import org.thialfihar.android.apg.provider.Keys; import org.thialfihar.android.apg.provider.Keys;
import org.thialfihar.android.apg.provider.UserIds; import org.thialfihar.android.apg.provider.UserIds;
@ -269,7 +270,7 @@ public class KeyListActivity extends BaseActivity {
mSelectedItem = -1; mSelectedItem = -1;
// TODO: better way to do this? // TODO: better way to do this?
String userId = "<unknown>"; String userId = "<unknown>";
Object keyRing = PGPHelper.getKeyRing(keyRingId); Object keyRing = PGPMain.getKeyRing(keyRingId);
if (keyRing != null) { if (keyRing != null) {
if (keyRing instanceof PGPPublicKeyRing) { if (keyRing instanceof PGPPublicKeyRing) {
userId = PGPHelper.getMainUserIdSafe(this, userId = PGPHelper.getMainUserIdSafe(this,
@ -344,12 +345,12 @@ public class KeyListActivity extends BaseActivity {
} }
if (mTask == Id.task.import_keys) { if (mTask == Id.task.import_keys) {
data = PGPHelper.importKeyRings(this, mKeyType, new InputData(importInputStream, data = PGPMain.importKeyRings(this, mKeyType, new InputData(importInputStream,
size), this); size), this);
} else { } else {
Vector<Integer> keyRingIds = new Vector<Integer>(); Vector<Integer> keyRingIds = new Vector<Integer>();
if (mSelectedItem == -1) { if (mSelectedItem == -1) {
keyRingIds = PGPHelper keyRingIds = PGPMain
.getKeyRingIds(mKeyType == Id.type.public_key ? Id.database.type_public .getKeyRingIds(mKeyType == Id.type.public_key ? Id.database.type_public
: Id.database.type_secret); : Id.database.type_secret);
} else { } else {
@ -357,7 +358,7 @@ public class KeyListActivity extends BaseActivity {
keyRingIds.add(keyRingId); keyRingIds.add(keyRingId);
mSelectedItem = -1; mSelectedItem = -1;
} }
data = PGPHelper.exportKeyRings(this, keyRingIds, exportOutputStream, this); data = PGPMain.exportKeyRings(this, keyRingIds, exportOutputStream, this);
} }
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
error = getString(R.string.error_fileNotFound); error = getString(R.string.error_fileNotFound);
@ -365,7 +366,7 @@ public class KeyListActivity extends BaseActivity {
error = "" + e; error = "" + e;
} catch (PGPException e) { } catch (PGPException e) {
error = "" + e; error = "" + e;
} catch (PGPHelper.GeneralException e) { } catch (PGPMain.GeneralException e) {
error = "" + e; error = "" + e;
} }
@ -386,7 +387,7 @@ public class KeyListActivity extends BaseActivity {
} }
protected void deleteKey(int keyRingId) { protected void deleteKey(int keyRingId) {
PGPHelper.deleteKey(keyRingId); PGPMain.deleteKey(keyRingId);
refreshList(); refreshList();
} }
@ -527,7 +528,7 @@ public class KeyListActivity extends BaseActivity {
mSearchString = searchString; mSearchString = searchString;
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mDatabase = PGPHelper.getDatabase().db(); mDatabase = PGPMain.getDatabase().db();
SQLiteQueryBuilder qb = new SQLiteQueryBuilder(); SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
qb.setTables(KeyRings.TABLE_NAME + " INNER JOIN " + Keys.TABLE_NAME + " ON " + "(" qb.setTables(KeyRings.TABLE_NAME + " INNER JOIN " + Keys.TABLE_NAME + " ON " + "("
+ KeyRings.TABLE_NAME + "." + KeyRings._ID + " = " + Keys.TABLE_NAME + "." + KeyRings.TABLE_NAME + "." + KeyRings._ID + " = " + Keys.TABLE_NAME + "."

View File

@ -21,7 +21,7 @@ import org.spongycastle.openpgp.PGPPublicKeyRing;
import org.thialfihar.android.apg.Constants; import org.thialfihar.android.apg.Constants;
import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.Id;
import org.thialfihar.android.apg.R; import org.thialfihar.android.apg.R;
import org.thialfihar.android.apg.helper.PGPHelper; import org.thialfihar.android.apg.helper.PGPMain;
import org.thialfihar.android.apg.util.HkpKeyServer; import org.thialfihar.android.apg.util.HkpKeyServer;
import com.actionbarsherlock.view.MenuItem; import com.actionbarsherlock.view.MenuItem;
@ -110,9 +110,9 @@ public class KeyServerExportActivity extends BaseActivity {
int keyRingId = getIntent().getIntExtra(EXTRA_KEY_ID, -1); int keyRingId = getIntent().getIntExtra(EXTRA_KEY_ID, -1);
PGPKeyRing keyring = PGPHelper.getKeyRing(keyRingId); PGPKeyRing keyring = PGPMain.getKeyRing(keyRingId);
if (keyring != null && keyring instanceof PGPPublicKeyRing) { if (keyring != null && keyring instanceof PGPPublicKeyRing) {
boolean uploaded = PGPHelper.uploadKeyRingToServer(server, (PGPPublicKeyRing) keyring); boolean uploaded = PGPMain.uploadKeyRingToServer(server, (PGPPublicKeyRing) keyring);
if (!uploaded) { if (!uploaded) {
error = "Unable to export key to selected server"; error = "Unable to export key to selected server";
} }

View File

@ -21,6 +21,7 @@ import org.thialfihar.android.apg.R;
import org.thialfihar.android.apg.Constants; import org.thialfihar.android.apg.Constants;
import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.Id;
import org.thialfihar.android.apg.helper.PGPHelper; import org.thialfihar.android.apg.helper.PGPHelper;
import org.thialfihar.android.apg.helper.PGPMain;
import org.thialfihar.android.apg.util.HkpKeyServer; import org.thialfihar.android.apg.util.HkpKeyServer;
import org.thialfihar.android.apg.util.KeyServer.InsufficientQuery; import org.thialfihar.android.apg.util.KeyServer.InsufficientQuery;
import org.thialfihar.android.apg.util.KeyServer.KeyInfo; import org.thialfihar.android.apg.util.KeyServer.KeyInfo;

View File

@ -20,7 +20,7 @@ import java.util.Vector;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import org.thialfihar.android.apg.R; import org.thialfihar.android.apg.R;
import org.thialfihar.android.apg.helper.PGPHelper; import org.thialfihar.android.apg.helper.PGPMain;
import org.thialfihar.android.apg.helper.Preferences; import org.thialfihar.android.apg.helper.Preferences;
import android.app.ListActivity; import android.app.ListActivity;
@ -121,11 +121,11 @@ public class MailListActivity extends ListActivity {
String data = messageCursor.getString(bodyIndex); String data = messageCursor.getString(bodyIndex);
data = Html.fromHtml(data).toString(); data = Html.fromHtml(data).toString();
boolean signedOnly = false; boolean signedOnly = false;
Matcher matcher = PGPHelper.PGP_MESSAGE.matcher(data); Matcher matcher = PGPMain.PGP_MESSAGE.matcher(data);
if (matcher.matches()) { if (matcher.matches()) {
data = matcher.group(1); data = matcher.group(1);
} else { } else {
matcher = PGPHelper.PGP_SIGNED_MESSAGE.matcher(data); matcher = PGPMain.PGP_SIGNED_MESSAGE.matcher(data);
if (matcher.matches()) { if (matcher.matches()) {
data = matcher.group(1); data = matcher.group(1);
signedOnly = true; signedOnly = true;

View File

@ -22,7 +22,7 @@ import java.security.Security;
import org.spongycastle.jce.provider.BouncyCastleProvider; import org.spongycastle.jce.provider.BouncyCastleProvider;
import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.Id;
import org.thialfihar.android.apg.R; import org.thialfihar.android.apg.R;
import org.thialfihar.android.apg.helper.PGPHelper; import org.thialfihar.android.apg.helper.PGPMain;
import com.actionbarsherlock.app.ActionBar; import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockActivity; import com.actionbarsherlock.app.SherlockActivity;

View File

@ -20,7 +20,7 @@ import org.spongycastle.bcpg.HashAlgorithmTags;
import org.spongycastle.openpgp.PGPEncryptedData; import org.spongycastle.openpgp.PGPEncryptedData;
import org.thialfihar.android.apg.Constants; import org.thialfihar.android.apg.Constants;
import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.Id;
import org.thialfihar.android.apg.helper.PGPHelper; import org.thialfihar.android.apg.helper.PGPMain;
import org.thialfihar.android.apg.helper.Preferences; import org.thialfihar.android.apg.helper.Preferences;
import org.thialfihar.android.apg.passphrase.PassphraseCacheService; import org.thialfihar.android.apg.passphrase.PassphraseCacheService;
import org.thialfihar.android.apg.ui.widget.IntegerListPreference; import org.thialfihar.android.apg.ui.widget.IntegerListPreference;

View File

@ -20,7 +20,7 @@ import java.util.Vector;
import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.Id;
import org.thialfihar.android.apg.R; import org.thialfihar.android.apg.R;
import org.thialfihar.android.apg.helper.PGPHelper; import org.thialfihar.android.apg.helper.PGPMain;
import org.thialfihar.android.apg.ui.widget.Editor; import org.thialfihar.android.apg.ui.widget.Editor;
import org.thialfihar.android.apg.ui.widget.KeyServerEditor; import org.thialfihar.android.apg.ui.widget.KeyServerEditor;
import org.thialfihar.android.apg.ui.widget.Editor.EditorListener; import org.thialfihar.android.apg.ui.widget.Editor.EditorListener;

View File

@ -21,6 +21,7 @@ import org.thialfihar.android.apg.Constants;
import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.Id;
import org.thialfihar.android.apg.R; import org.thialfihar.android.apg.R;
import org.thialfihar.android.apg.helper.PGPHelper; import org.thialfihar.android.apg.helper.PGPHelper;
import org.thialfihar.android.apg.helper.PGPMain;
import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem; import com.actionbarsherlock.view.MenuItem;
@ -115,7 +116,7 @@ public class PublicKeyListActivity extends KeyListActivity {
mSelectedItem = groupPosition; mSelectedItem = groupPosition;
final int keyRingId = mListAdapter.getKeyRingId(groupPosition); final int keyRingId = mListAdapter.getKeyRingId(groupPosition);
long keyId = 0; long keyId = 0;
Object keyRing = PGPHelper.getKeyRing(keyRingId); Object keyRing = PGPMain.getKeyRing(keyRingId);
if (keyRing != null && keyRing instanceof PGPPublicKeyRing) { if (keyRing != null && keyRing instanceof PGPPublicKeyRing) {
keyId = PGPHelper.getMasterKey((PGPPublicKeyRing) keyRing).getKeyID(); keyId = PGPHelper.getMasterKey((PGPPublicKeyRing) keyRing).getKeyID();
} }
@ -148,7 +149,7 @@ public class PublicKeyListActivity extends KeyListActivity {
mSelectedItem = groupPosition; mSelectedItem = groupPosition;
final int keyRingId = mListAdapter.getKeyRingId(groupPosition); final int keyRingId = mListAdapter.getKeyRingId(groupPosition);
long keyId = 0; long keyId = 0;
Object keyRing = PGPHelper.getKeyRing(keyRingId); Object keyRing = PGPMain.getKeyRing(keyRingId);
if (keyRing != null && keyRing instanceof PGPPublicKeyRing) { if (keyRing != null && keyRing instanceof PGPPublicKeyRing) {
keyId = PGPHelper.getMasterKey((PGPPublicKeyRing) keyRing).getKeyID(); keyId = PGPHelper.getMasterKey((PGPPublicKeyRing) keyRing).getKeyID();
} }

View File

@ -20,6 +20,7 @@ import org.thialfihar.android.apg.R;
import org.thialfihar.android.apg.Constants; import org.thialfihar.android.apg.Constants;
import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.Id;
import org.thialfihar.android.apg.helper.PGPHelper; import org.thialfihar.android.apg.helper.PGPHelper;
import org.thialfihar.android.apg.helper.PGPMain;
import org.thialfihar.android.apg.passphrase.AskForPassphrase; import org.thialfihar.android.apg.passphrase.AskForPassphrase;
import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.Menu;
@ -146,11 +147,11 @@ public class SecretKeyListActivity extends KeyListActivity implements OnChildCli
public void checkPassPhraseAndEdit() { public void checkPassPhraseAndEdit() {
long keyId = ((KeyListAdapter) mList.getExpandableListAdapter()).getGroupId(mSelectedItem); long keyId = ((KeyListAdapter) mList.getExpandableListAdapter()).getGroupId(mSelectedItem);
String passPhrase = PGPHelper.getCachedPassPhrase(keyId); String passPhrase = PGPMain.getCachedPassPhrase(keyId);
if (passPhrase == null) { if (passPhrase == null) {
showDialog(Id.dialog.pass_phrase); showDialog(Id.dialog.pass_phrase);
} else { } else {
PGPHelper.setEditPassPhrase(passPhrase); PGPMain.setEditPassPhrase(passPhrase);
editKey(); editKey();
} }
} }
@ -158,12 +159,12 @@ public class SecretKeyListActivity extends KeyListActivity implements OnChildCli
@Override @Override
public void passPhraseCallback(long keyId, String passPhrase) { public void passPhraseCallback(long keyId, String passPhrase) {
super.passPhraseCallback(keyId, passPhrase); super.passPhraseCallback(keyId, passPhrase);
PGPHelper.setEditPassPhrase(passPhrase); PGPMain.setEditPassPhrase(passPhrase);
editKey(); editKey();
} }
private void createKey() { private void createKey() {
PGPHelper.setEditPassPhrase(""); PGPMain.setEditPassPhrase("");
Intent intent = new Intent(EditKeyActivity.ACTION_CREATE_KEY); Intent intent = new Intent(EditKeyActivity.ACTION_CREATE_KEY);
startActivityForResult(intent, Id.message.create_key); startActivityForResult(intent, Id.message.create_key);
} }

View File

@ -21,7 +21,7 @@ import java.util.Vector;
import org.thialfihar.android.apg.Constants; import org.thialfihar.android.apg.Constants;
import org.thialfihar.android.apg.R; import org.thialfihar.android.apg.R;
import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.Id;
import org.thialfihar.android.apg.helper.PGPHelper; import org.thialfihar.android.apg.helper.PGPMain;
import org.thialfihar.android.apg.ui.widget.SelectPublicKeyListAdapter; import org.thialfihar.android.apg.ui.widget.SelectPublicKeyListAdapter;
import com.actionbarsherlock.app.ActionBar; import com.actionbarsherlock.app.ActionBar;

View File

@ -19,7 +19,7 @@ package org.thialfihar.android.apg.ui;
import org.thialfihar.android.apg.Constants; import org.thialfihar.android.apg.Constants;
import org.thialfihar.android.apg.R; import org.thialfihar.android.apg.R;
import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.Id;
import org.thialfihar.android.apg.helper.PGPHelper; import org.thialfihar.android.apg.helper.PGPMain;
import org.thialfihar.android.apg.ui.widget.SelectSecretKeyListAdapter; import org.thialfihar.android.apg.ui.widget.SelectSecretKeyListAdapter;
import com.actionbarsherlock.app.ActionBar; import com.actionbarsherlock.app.ActionBar;

View File

@ -35,7 +35,7 @@ import org.spongycastle.openpgp.PGPUtil;
import org.thialfihar.android.apg.Constants; import org.thialfihar.android.apg.Constants;
import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.Id;
import org.thialfihar.android.apg.R; import org.thialfihar.android.apg.R;
import org.thialfihar.android.apg.helper.PGPHelper; import org.thialfihar.android.apg.helper.PGPMain;
import org.thialfihar.android.apg.util.HkpKeyServer; import org.thialfihar.android.apg.util.HkpKeyServer;
import com.actionbarsherlock.view.MenuItem; import com.actionbarsherlock.view.MenuItem;
@ -143,7 +143,7 @@ public class SignKeyActivity extends BaseActivity {
* handles the UI bits of the signing process on the UI thread * handles the UI bits of the signing process on the UI thread
*/ */
private void initiateSigning() { private void initiateSigning() {
PGPPublicKeyRing pubring = PGPHelper.getPublicKeyRing(pubKeyId); PGPPublicKeyRing pubring = PGPMain.getPublicKeyRing(pubKeyId);
if (pubring != null) { if (pubring != null) {
// if we have already signed this key, dont bother doing it again // if we have already signed this key, dont bother doing it again
boolean alreadySigned = false; boolean alreadySigned = false;
@ -162,7 +162,7 @@ public class SignKeyActivity extends BaseActivity {
/* /*
* get the user's passphrase for this key (if required) * get the user's passphrase for this key (if required)
*/ */
String passphrase = PGPHelper.getCachedPassPhrase(masterKeyId); String passphrase = PGPMain.getCachedPassPhrase(masterKeyId);
if (passphrase == null) { if (passphrase == null) {
showDialog(Id.dialog.pass_phrase); showDialog(Id.dialog.pass_phrase);
return; // bail out; need to wait until the user has entered the passphrase return; // bail out; need to wait until the user has entered the passphrase
@ -212,16 +212,16 @@ public class SignKeyActivity extends BaseActivity {
Message msg = new Message(); Message msg = new Message();
try { try {
String passphrase = PGPHelper.getCachedPassPhrase(masterKeyId); String passphrase = PGPMain.getCachedPassPhrase(masterKeyId);
if (passphrase == null || passphrase.length() <= 0) { if (passphrase == null || passphrase.length() <= 0) {
status.putString(EXTRA_ERROR, "Unable to obtain passphrase"); status.putString(EXTRA_ERROR, "Unable to obtain passphrase");
} else { } else {
PGPPublicKeyRing pubring = PGPHelper.getPublicKeyRing(pubKeyId); PGPPublicKeyRing pubring = PGPMain.getPublicKeyRing(pubKeyId);
/* /*
* sign the incoming key * sign the incoming key
*/ */
PGPSecretKey secretKey = PGPHelper.getSecretKey(masterKeyId); PGPSecretKey secretKey = PGPMain.getSecretKey(masterKeyId);
PGPPrivateKey signingKey = secretKey.extractPrivateKey(passphrase.toCharArray(), PGPPrivateKey signingKey = secretKey.extractPrivateKey(passphrase.toCharArray(),
BouncyCastleProvider.PROVIDER_NAME); BouncyCastleProvider.PROVIDER_NAME);
PGPSignatureGenerator sGen = new PGPSignatureGenerator(secretKey.getPublicKey() PGPSignatureGenerator sGen = new PGPSignatureGenerator(secretKey.getPublicKey()
@ -247,11 +247,11 @@ public class SignKeyActivity extends BaseActivity {
* upload the newly signed key to the key server * upload the newly signed key to the key server
*/ */
PGPHelper.uploadKeyRingToServer(server, pubring); PGPMain.uploadKeyRingToServer(server, pubring);
} }
// store the signed key in our local cache // store the signed key in our local cache
int retval = PGPHelper.storeKeyRingInCache(pubring); int retval = PGPMain.storeKeyRingInCache(pubring);
if (retval != Id.return_value.ok && retval != Id.return_value.updated) { if (retval != Id.return_value.ok && retval != Id.return_value.updated) {
status.putString(EXTRA_ERROR, "Failed to store signed key in local cache"); status.putString(EXTRA_ERROR, "Failed to store signed key in local cache");
} }

View File

@ -19,7 +19,6 @@ package org.thialfihar.android.apg.ui.dialog;
import org.thialfihar.android.apg.Constants; import org.thialfihar.android.apg.Constants;
import org.thialfihar.android.apg.R; import org.thialfihar.android.apg.R;
import org.thialfihar.android.apg.helper.FileHelper; import org.thialfihar.android.apg.helper.FileHelper;
import org.thialfihar.android.apg.helper.OtherHelper;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;

View File

@ -22,7 +22,8 @@ import org.spongycastle.openpgp.PGPSecretKey;
import org.spongycastle.openpgp.operator.PBESecretKeyDecryptor; import org.spongycastle.openpgp.operator.PBESecretKeyDecryptor;
import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder; import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder;
import org.thialfihar.android.apg.helper.PGPHelper; import org.thialfihar.android.apg.helper.PGPHelper;
import org.thialfihar.android.apg.helper.PGPHelper.GeneralException; import org.thialfihar.android.apg.helper.PGPMain;
import org.thialfihar.android.apg.helper.PGPMain.GeneralException;
import org.thialfihar.android.apg.Constants; import org.thialfihar.android.apg.Constants;
import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.Id;
import org.thialfihar.android.apg.R; import org.thialfihar.android.apg.R;
@ -68,7 +69,7 @@ public class PassphraseDialogFragment extends DialogFragment {
// check if secret key has a passphrase // check if secret key has a passphrase
if (!(secretKeyId == Id.key.symmetric || secretKeyId == Id.key.none)) { if (!(secretKeyId == Id.key.symmetric || secretKeyId == Id.key.none)) {
if (!hasPassphrase(secretKeyId)) { if (!hasPassphrase(secretKeyId)) {
throw new PGPHelper.GeneralException("No passphrase! No passphrase dialog needed!"); throw new PGPMain.GeneralException("No passphrase! No passphrase dialog needed!");
} }
} }
@ -91,7 +92,8 @@ public class PassphraseDialogFragment extends DialogFragment {
private static boolean hasPassphrase(long secretKeyId) { private static boolean hasPassphrase(long secretKeyId) {
// check if the key has no passphrase // check if the key has no passphrase
try { try {
PGPSecretKey secretKey = PGPHelper.getMasterKey(PGPHelper.getSecretKeyRing(secretKeyId)); PGPSecretKey secretKey = PGPHelper.getMasterKey(PGPMain
.getSecretKeyRing(secretKeyId));
Log.d(Constants.TAG, "Check if key has no passphrase..."); Log.d(Constants.TAG, "Check if key has no passphrase...");
PBESecretKeyDecryptor keyDecryptor = new JcePBESecretKeyDecryptorBuilder().setProvider( PBESecretKeyDecryptor keyDecryptor = new JcePBESecretKeyDecryptorBuilder().setProvider(
@ -101,7 +103,7 @@ public class PassphraseDialogFragment extends DialogFragment {
Log.d(Constants.TAG, "Key has no passphrase! Caches empty passphrase!"); Log.d(Constants.TAG, "Key has no passphrase! Caches empty passphrase!");
// cache empty passphrase // cache empty passphrase
PGPHelper.setCachedPassPhrase(secretKey.getKeyID(), ""); PGPMain.setCachedPassPhrase(secretKey.getKeyID(), "");
return false; return false;
} }
@ -132,7 +134,7 @@ public class PassphraseDialogFragment extends DialogFragment {
secretKey = null; secretKey = null;
alert.setMessage(getString(R.string.passPhraseForSymmetricEncryption)); alert.setMessage(getString(R.string.passPhraseForSymmetricEncryption));
} else { } else {
secretKey = PGPHelper.getMasterKey(PGPHelper.getSecretKeyRing(secretKeyId)); secretKey = PGPHelper.getMasterKey(PGPMain.getSecretKeyRing(secretKeyId));
if (secretKey == null) { if (secretKey == null) {
alert.setTitle(R.string.title_keyNotFound); alert.setTitle(R.string.title_keyNotFound);
alert.setMessage(getString(R.string.keyNotFound, secretKeyId)); alert.setMessage(getString(R.string.keyNotFound, secretKeyId));
@ -189,7 +191,7 @@ public class PassphraseDialogFragment extends DialogFragment {
// cache the new passphrase // cache the new passphrase
Log.d(Constants.TAG, "Everything okay! Caching entered passphrase"); Log.d(Constants.TAG, "Everything okay! Caching entered passphrase");
PGPHelper.setCachedPassPhrase(keyId, passPhrase); PGPMain.setCachedPassPhrase(keyId, passPhrase);
sendMessageToHandler(MESSAGE_OKAY); sendMessageToHandler(MESSAGE_OKAY);
} }

View File

@ -20,6 +20,7 @@ import org.spongycastle.openpgp.PGPPublicKey;
import org.spongycastle.openpgp.PGPSecretKey; import org.spongycastle.openpgp.PGPSecretKey;
import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.Id;
import org.thialfihar.android.apg.helper.PGPHelper; import org.thialfihar.android.apg.helper.PGPHelper;
import org.thialfihar.android.apg.helper.PGPMain;
import org.thialfihar.android.apg.util.Choice; import org.thialfihar.android.apg.util.Choice;
import org.thialfihar.android.apg.R; import org.thialfihar.android.apg.R;

View File

@ -19,7 +19,7 @@ package org.thialfihar.android.apg.ui.widget;
import org.spongycastle.openpgp.PGPSecretKey; import org.spongycastle.openpgp.PGPSecretKey;
import org.spongycastle.openpgp.PGPSecretKeyRing; import org.spongycastle.openpgp.PGPSecretKeyRing;
import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.Id;
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.PGPConversionHelper;
import org.thialfihar.android.apg.service.ApgHandler; import org.thialfihar.android.apg.service.ApgHandler;
import org.thialfihar.android.apg.service.ApgService; import org.thialfihar.android.apg.service.ApgService;
@ -259,7 +259,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
String passPhrase; String passPhrase;
if (mEditors.getChildCount() > 0) { if (mEditors.getChildCount() > 0) {
PGPSecretKey masterKey = ((KeyEditor) mEditors.getChildAt(0)).getValue(); PGPSecretKey masterKey = ((KeyEditor) mEditors.getChildAt(0)).getValue();
passPhrase = PGPHelper.getCachedPassPhrase(masterKey.getKeyID()); passPhrase = PGPMain.getCachedPassPhrase(masterKey.getKeyID());
data.putByteArray(ApgService.MASTER_KEY, data.putByteArray(ApgService.MASTER_KEY,
PGPConversionHelper.PGPSecretKeyToBytes(masterKey)); PGPConversionHelper.PGPSecretKeyToBytes(masterKey));

View File

@ -21,6 +21,7 @@ import java.util.Date;
import org.thialfihar.android.apg.R; import org.thialfihar.android.apg.R;
import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.Id;
import org.thialfihar.android.apg.helper.PGPHelper; import org.thialfihar.android.apg.helper.PGPHelper;
import org.thialfihar.android.apg.helper.PGPMain;
import org.thialfihar.android.apg.provider.KeyRings; import org.thialfihar.android.apg.provider.KeyRings;
import org.thialfihar.android.apg.provider.Keys; import org.thialfihar.android.apg.provider.Keys;
import org.thialfihar.android.apg.provider.UserIds; import org.thialfihar.android.apg.provider.UserIds;
@ -53,7 +54,7 @@ public class SelectPublicKeyListAdapter extends BaseAdapter {
mActivity = activity; mActivity = activity;
mParent = parent; mParent = parent;
mDatabase = PGPHelper.getDatabase().db(); mDatabase = PGPMain.getDatabase().db();
mInflater = (LayoutInflater) parent.getContext().getSystemService( mInflater = (LayoutInflater) parent.getContext().getSystemService(
Context.LAYOUT_INFLATER_SERVICE); Context.LAYOUT_INFLATER_SERVICE);
long now = new Date().getTime() / 1000; long now = new Date().getTime() / 1000;

View File

@ -19,6 +19,7 @@ import java.util.Date;
import org.thialfihar.android.apg.R; import org.thialfihar.android.apg.R;
import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.Id;
import org.thialfihar.android.apg.helper.PGPHelper; import org.thialfihar.android.apg.helper.PGPHelper;
import org.thialfihar.android.apg.helper.PGPMain;
import org.thialfihar.android.apg.provider.KeyRings; import org.thialfihar.android.apg.provider.KeyRings;
import org.thialfihar.android.apg.provider.Keys; import org.thialfihar.android.apg.provider.Keys;
import org.thialfihar.android.apg.provider.UserIds; import org.thialfihar.android.apg.provider.UserIds;
@ -48,7 +49,7 @@ public class SelectSecretKeyListAdapter extends BaseAdapter {
mActivity = activity; mActivity = activity;
mParent = parent; mParent = parent;
mDatabase = PGPHelper.getDatabase().db(); mDatabase = PGPMain.getDatabase().db();
mInflater = (LayoutInflater) parent.getContext().getSystemService( mInflater = (LayoutInflater) parent.getContext().getSystemService(
Context.LAYOUT_INFLATER_SERVICE); Context.LAYOUT_INFLATER_SERVICE);
long now = new Date().getTime() / 1000; long now = new Date().getTime() / 1000;

View File

@ -45,6 +45,7 @@ import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair; import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
import org.thialfihar.android.apg.helper.PGPHelper; import org.thialfihar.android.apg.helper.PGPHelper;
import org.thialfihar.android.apg.helper.PGPMain;
import android.text.Html; import android.text.Html;
@ -223,7 +224,7 @@ public class HkpKeyServer extends KeyServer {
HttpEntity entity = response.getEntity(); HttpEntity entity = response.getEntity();
InputStream is = entity.getContent(); InputStream is = entity.getContent();
String data = readAll(is, EntityUtils.getContentCharSet(entity)); String data = readAll(is, EntityUtils.getContentCharSet(entity));
Matcher matcher = PGPHelper.PGP_PUBLIC_KEY.matcher(data); Matcher matcher = PGPMain.PGP_PUBLIC_KEY.matcher(data);
if (matcher.find()) { if (matcher.find()) {
return matcher.group(1); return matcher.group(1);
} }