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
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)
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
# 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.
* 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
* 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.R.string;
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.passphrase.PassphraseCacheService;
import org.thialfihar.android.apg.provider.KeyRings;
@ -204,7 +205,7 @@ public class ApgService2 extends PassphraseCacheService {
typeWhere = KeyRings.TABLE_NAME + "." + KeyRings.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);
}
@ -427,7 +428,7 @@ public class ApgService2 extends PassphraseCacheService {
}
private boolean prepareArgs(String pCall, Bundle pArgs, Bundle pReturn) {
PGPHelper.initialize(getBaseContext());
PGPMain.initialize(getBaseContext());
/* add default return values for all functions */
addDefaultReturns(pReturn);
@ -493,7 +494,7 @@ public class ApgService2 extends PassphraseCacheService {
if (LOCAL_LOGV)
Log.v(TAG, "About to encrypt");
try {
PGPHelper.encrypt(getBaseContext(), // context
PGPMain.encrypt(getBaseContext(), // context
in, // input stream
out, // output stream
pArgs.getBoolean(arg.ARMORED_OUTPUT.name()), // ARMORED_OUTPUT
@ -625,7 +626,7 @@ public class ApgService2 extends PassphraseCacheService {
if (LOCAL_LOGV)
Log.v(TAG, "About to decrypt");
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
);
} 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 org.spongycastle.openpgp.PGPObjectFactory;
import org.spongycastle.openpgp.PGPPublicKeyRing;
import org.spongycastle.openpgp.PGPSecretKey;
import org.spongycastle.openpgp.PGPSecretKeyRing;
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
* @return
@ -72,6 +73,26 @@ public class PGPConversionHelper {
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) {
PGPSecretKeyRing keyRing = BytesToPGPSecretKeyRing(keysBytes);

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

View File

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

View File

@ -25,7 +25,7 @@ import org.thialfihar.android.apg.Constants;
import org.thialfihar.android.apg.Id;
import org.thialfihar.android.apg.ProgressDialogUpdater;
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.passphrase.AskForPassphrase;
import org.thialfihar.android.apg.passphrase.PassphraseCacheService;
@ -79,7 +79,7 @@ public class BaseActivity extends SherlockFragmentActivity implements Runnable,
// not needed later:
mPreferences = Preferences.getPreferences(this);
PGPHelper.initialize(this);
PGPMain.initialize(this);
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
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) {
// TODO: Not needed anymore, now implemented in AskForSecretKeyPass
PGPHelper.setCachedPassPhrase(keyId, passPhrase);
PGPMain.setCachedPassPhrase(keyId, passPhrase);
}
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.helper.FileHelper;
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.ApgService;
import org.thialfihar.android.apg.ui.dialog.DeleteFileDialogFragment;
@ -299,7 +300,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
}
if (textData != null) {
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()) {
Log.d(Constants.TAG, "PGP_MESSAGE matched");
textData = matcher.group(1);
@ -307,7 +308,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
textData = textData.replaceAll("\\xa0", " ");
mMessage.setText(textData);
} else {
matcher = PGPHelper.PGP_SIGNED_MESSAGE.matcher(textData);
matcher = PGPMain.PGP_SIGNED_MESSAGE.matcher(textData);
if (matcher.matches()) {
Log.d(Constants.TAG, "PGP_SIGNED_MESSAGE matched");
textData = matcher.group(1);
@ -350,14 +351,14 @@ public class DecryptActivity extends SherlockFragmentActivity {
mData = extras.getByteArray(EXTRA_DATA);
String data = extras.getString(EXTRA_TEXT);
if (data != null) {
Matcher matcher = PGPHelper.PGP_MESSAGE.matcher(data);
Matcher matcher = PGPMain.PGP_MESSAGE.matcher(data);
if (matcher.matches()) {
data = matcher.group(1);
// replace non breakable spaces
data = data.replaceAll("\\xa0", " ");
mMessage.setText(data);
} else {
matcher = PGPHelper.PGP_SIGNED_MESSAGE.matcher(data);
matcher = PGPMain.PGP_SIGNED_MESSAGE.matcher(data);
if (matcher.matches()) {
data = matcher.group(1);
// replace non breakable spaces
@ -381,9 +382,9 @@ public class DecryptActivity extends SherlockFragmentActivity {
String data = "";
if (clipboardText != null) {
Matcher matcher = PGPHelper.PGP_MESSAGE.matcher(clipboardText);
Matcher matcher = PGPMain.PGP_MESSAGE.matcher(clipboardText);
if (!matcher.matches()) {
matcher = PGPHelper.PGP_SIGNED_MESSAGE.matcher(clipboardText);
matcher = PGPMain.PGP_SIGNED_MESSAGE.matcher(clipboardText);
}
if (matcher.matches()) {
data = matcher.group(1);
@ -399,7 +400,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
if (mSignatureKeyId == 0) {
return;
}
PGPPublicKeyRing key = PGPHelper.getPublicKeyRing(mSignatureKeyId);
PGPPublicKeyRing key = PGPMain.getPublicKeyRing(mSignatureKeyId);
if (key != null) {
Intent intent = new Intent(DecryptActivity.this, KeyServerQueryActivity.class);
intent.setAction(KeyServerQueryActivity.ACTION_LOOK_UP_KEY_ID);
@ -506,7 +507,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
if (mDecryptTarget == Id.target.message) {
String messageData = mMessage.getText().toString();
Matcher matcher = PGPHelper.PGP_SIGNED_MESSAGE.matcher(messageData);
Matcher matcher = PGPMain.PGP_SIGNED_MESSAGE.matcher(messageData);
if (matcher.matches()) {
mSignedOnly = true;
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 (getSecretKeyId() == Id.key.symmetric
|| PGPHelper.getCachedPassPhrase(getSecretKeyId()) == null) {
|| PGPMain.getCachedPassPhrase(getSecretKeyId()) == null) {
// showDialog(Id.dialog.pass_phrase);
showPassphraseDialog();
} else {
@ -563,7 +564,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
messenger, mSecretKeyId);
passphraseDialog.show(getSupportFragmentManager(), "passphraseDialog");
} catch (PGPHelper.GeneralException e) {
} catch (PGPMain.GeneralException 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);
@ -609,15 +610,15 @@ public class DecryptActivity extends SherlockFragmentActivity {
try {
try {
setSecretKeyId(PGPHelper.getDecryptionKeyId(this, inStream));
setSecretKeyId(PGPMain.getDecryptionKeyId(this, inStream));
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;
} catch (PGPHelper.NoAsymmetricEncryptionException e) {
} catch (PGPMain.NoAsymmetricEncryptionException e) {
setSecretKeyId(Id.key.symmetric);
if (!PGPHelper.hasSymmetricEncryption(this, inStream)) {
throw new PGPHelper.GeneralException(
if (!PGPMain.hasSymmetricEncryption(this, inStream)) {
throw new PGPMain.GeneralException(
getString(R.string.error_noKnownEncryptionFound));
}
mAssumeSymmetricEncryption = true;

View File

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

View File

@ -25,6 +25,7 @@ import org.thialfihar.android.apg.Constants;
import org.thialfihar.android.apg.Id;
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.service.ApgHandler;
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 encryptionKeyIds[] = extras.getLongArray(EXTRA_ENCRYPTION_KEY_IDS);
if (signatureKeyId != 0) {
PGPSecretKeyRing keyRing = PGPHelper.getSecretKeyRing(signatureKeyId);
PGPSecretKeyRing keyRing = PGPMain.getSecretKeyRing(signatureKeyId);
PGPSecretKey masterKey = null;
if (keyRing != null) {
masterKey = PGPHelper.getMasterKey(keyRing);
@ -406,7 +407,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
if (encryptionKeyIds != null) {
Vector<Long> goodIds = new Vector<Long>();
for (int i = 0; i < encryptionKeyIds.length; ++i) {
PGPPublicKeyRing keyRing = PGPHelper.getPublicKeyRing(encryptionKeyIds[i]);
PGPPublicKeyRing keyRing = PGPMain.getPublicKeyRing(encryptionKeyIds[i]);
PGPPublicKey masterKey = null;
if (keyRing == null) {
continue;
@ -669,7 +670,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
return;
}
if (getSecretKeyId() != 0 && PGPHelper.getCachedPassPhrase(getSecretKeyId()) == null) {
if (getSecretKeyId() != 0 && PGPMain.getCachedPassPhrase(getSecretKeyId()) == null) {
showPassphraseDialog();
return;
@ -710,7 +711,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
messenger, mSecretKeyId);
passphraseDialog.show(getSupportFragmentManager(), "passphraseDialog");
} catch (PGPHelper.GeneralException e) {
} catch (PGPMain.GeneralException 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);
@ -935,7 +936,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
} else {
String uid = getResources().getString(R.string.unknownUserId);
String uidExtra = "";
PGPSecretKeyRing keyRing = PGPHelper.getSecretKeyRing(getSecretKeyId());
PGPSecretKeyRing keyRing = PGPMain.getSecretKeyRing(getSecretKeyId());
if (keyRing != null) {
PGPSecretKey key = PGPHelper.getMasterKey(keyRing);
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.Id;
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.KeyServer.QueryException;
import org.thialfihar.android.apg.R;
@ -83,7 +84,7 @@ public class ImportFromQRCodeActivity extends BaseActivity {
.getPublicKey().getFingerprint());
if (expectedFingerprint.equals(actualFingerprint)) {
// store the signed key in our local cache
int retval = PGPHelper.storeKeyRingInCache(publicKeyRing);
int retval = PGPMain.storeKeyRingInCache(publicKeyRing);
if (retval != Id.return_value.ok
&& retval != Id.return_value.updated) {
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.Id;
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.Keys;
import org.thialfihar.android.apg.provider.UserIds;
@ -269,7 +270,7 @@ public class KeyListActivity extends BaseActivity {
mSelectedItem = -1;
// TODO: better way to do this?
String userId = "<unknown>";
Object keyRing = PGPHelper.getKeyRing(keyRingId);
Object keyRing = PGPMain.getKeyRing(keyRingId);
if (keyRing != null) {
if (keyRing instanceof PGPPublicKeyRing) {
userId = PGPHelper.getMainUserIdSafe(this,
@ -344,12 +345,12 @@ public class KeyListActivity extends BaseActivity {
}
if (mTask == Id.task.import_keys) {
data = PGPHelper.importKeyRings(this, mKeyType, new InputData(importInputStream,
data = PGPMain.importKeyRings(this, mKeyType, new InputData(importInputStream,
size), this);
} else {
Vector<Integer> keyRingIds = new Vector<Integer>();
if (mSelectedItem == -1) {
keyRingIds = PGPHelper
keyRingIds = PGPMain
.getKeyRingIds(mKeyType == Id.type.public_key ? Id.database.type_public
: Id.database.type_secret);
} else {
@ -357,7 +358,7 @@ public class KeyListActivity extends BaseActivity {
keyRingIds.add(keyRingId);
mSelectedItem = -1;
}
data = PGPHelper.exportKeyRings(this, keyRingIds, exportOutputStream, this);
data = PGPMain.exportKeyRings(this, keyRingIds, exportOutputStream, this);
}
} catch (FileNotFoundException e) {
error = getString(R.string.error_fileNotFound);
@ -365,7 +366,7 @@ public class KeyListActivity extends BaseActivity {
error = "" + e;
} catch (PGPException e) {
error = "" + e;
} catch (PGPHelper.GeneralException e) {
} catch (PGPMain.GeneralException e) {
error = "" + e;
}
@ -386,7 +387,7 @@ public class KeyListActivity extends BaseActivity {
}
protected void deleteKey(int keyRingId) {
PGPHelper.deleteKey(keyRingId);
PGPMain.deleteKey(keyRingId);
refreshList();
}
@ -527,7 +528,7 @@ public class KeyListActivity extends BaseActivity {
mSearchString = searchString;
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mDatabase = PGPHelper.getDatabase().db();
mDatabase = PGPMain.getDatabase().db();
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
qb.setTables(KeyRings.TABLE_NAME + " INNER JOIN " + Keys.TABLE_NAME + " ON " + "("
+ 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.Id;
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 com.actionbarsherlock.view.MenuItem;
@ -110,9 +110,9 @@ public class KeyServerExportActivity extends BaseActivity {
int keyRingId = getIntent().getIntExtra(EXTRA_KEY_ID, -1);
PGPKeyRing keyring = PGPHelper.getKeyRing(keyRingId);
PGPKeyRing keyring = PGPMain.getKeyRing(keyRingId);
if (keyring != null && keyring instanceof PGPPublicKeyRing) {
boolean uploaded = PGPHelper.uploadKeyRingToServer(server, (PGPPublicKeyRing) keyring);
boolean uploaded = PGPMain.uploadKeyRingToServer(server, (PGPPublicKeyRing) keyring);
if (!uploaded) {
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.Id;
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.KeyServer.InsufficientQuery;
import org.thialfihar.android.apg.util.KeyServer.KeyInfo;

View File

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

View File

@ -22,7 +22,7 @@ import java.security.Security;
import org.spongycastle.jce.provider.BouncyCastleProvider;
import org.thialfihar.android.apg.Id;
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.SherlockActivity;

View File

@ -20,7 +20,7 @@ import org.spongycastle.bcpg.HashAlgorithmTags;
import org.spongycastle.openpgp.PGPEncryptedData;
import org.thialfihar.android.apg.Constants;
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.passphrase.PassphraseCacheService;
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.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.KeyServerEditor;
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.R;
import org.thialfihar.android.apg.helper.PGPHelper;
import org.thialfihar.android.apg.helper.PGPMain;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
@ -115,7 +116,7 @@ public class PublicKeyListActivity extends KeyListActivity {
mSelectedItem = groupPosition;
final int keyRingId = mListAdapter.getKeyRingId(groupPosition);
long keyId = 0;
Object keyRing = PGPHelper.getKeyRing(keyRingId);
Object keyRing = PGPMain.getKeyRing(keyRingId);
if (keyRing != null && keyRing instanceof PGPPublicKeyRing) {
keyId = PGPHelper.getMasterKey((PGPPublicKeyRing) keyRing).getKeyID();
}
@ -148,7 +149,7 @@ public class PublicKeyListActivity extends KeyListActivity {
mSelectedItem = groupPosition;
final int keyRingId = mListAdapter.getKeyRingId(groupPosition);
long keyId = 0;
Object keyRing = PGPHelper.getKeyRing(keyRingId);
Object keyRing = PGPMain.getKeyRing(keyRingId);
if (keyRing != null && keyRing instanceof PGPPublicKeyRing) {
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.Id;
import org.thialfihar.android.apg.helper.PGPHelper;
import org.thialfihar.android.apg.helper.PGPMain;
import org.thialfihar.android.apg.passphrase.AskForPassphrase;
import com.actionbarsherlock.view.Menu;
@ -146,11 +147,11 @@ public class SecretKeyListActivity extends KeyListActivity implements OnChildCli
public void checkPassPhraseAndEdit() {
long keyId = ((KeyListAdapter) mList.getExpandableListAdapter()).getGroupId(mSelectedItem);
String passPhrase = PGPHelper.getCachedPassPhrase(keyId);
String passPhrase = PGPMain.getCachedPassPhrase(keyId);
if (passPhrase == null) {
showDialog(Id.dialog.pass_phrase);
} else {
PGPHelper.setEditPassPhrase(passPhrase);
PGPMain.setEditPassPhrase(passPhrase);
editKey();
}
}
@ -158,12 +159,12 @@ public class SecretKeyListActivity extends KeyListActivity implements OnChildCli
@Override
public void passPhraseCallback(long keyId, String passPhrase) {
super.passPhraseCallback(keyId, passPhrase);
PGPHelper.setEditPassPhrase(passPhrase);
PGPMain.setEditPassPhrase(passPhrase);
editKey();
}
private void createKey() {
PGPHelper.setEditPassPhrase("");
PGPMain.setEditPassPhrase("");
Intent intent = new Intent(EditKeyActivity.ACTION_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.R;
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 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.R;
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 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.Id;
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 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
*/
private void initiateSigning() {
PGPPublicKeyRing pubring = PGPHelper.getPublicKeyRing(pubKeyId);
PGPPublicKeyRing pubring = PGPMain.getPublicKeyRing(pubKeyId);
if (pubring != null) {
// if we have already signed this key, dont bother doing it again
boolean alreadySigned = false;
@ -162,7 +162,7 @@ public class SignKeyActivity extends BaseActivity {
/*
* get the user's passphrase for this key (if required)
*/
String passphrase = PGPHelper.getCachedPassPhrase(masterKeyId);
String passphrase = PGPMain.getCachedPassPhrase(masterKeyId);
if (passphrase == null) {
showDialog(Id.dialog.pass_phrase);
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();
try {
String passphrase = PGPHelper.getCachedPassPhrase(masterKeyId);
String passphrase = PGPMain.getCachedPassPhrase(masterKeyId);
if (passphrase == null || passphrase.length() <= 0) {
status.putString(EXTRA_ERROR, "Unable to obtain passphrase");
} else {
PGPPublicKeyRing pubring = PGPHelper.getPublicKeyRing(pubKeyId);
PGPPublicKeyRing pubring = PGPMain.getPublicKeyRing(pubKeyId);
/*
* sign the incoming key
*/
PGPSecretKey secretKey = PGPHelper.getSecretKey(masterKeyId);
PGPSecretKey secretKey = PGPMain.getSecretKey(masterKeyId);
PGPPrivateKey signingKey = secretKey.extractPrivateKey(passphrase.toCharArray(),
BouncyCastleProvider.PROVIDER_NAME);
PGPSignatureGenerator sGen = new PGPSignatureGenerator(secretKey.getPublicKey()
@ -247,11 +247,11 @@ public class SignKeyActivity extends BaseActivity {
* 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
int retval = PGPHelper.storeKeyRingInCache(pubring);
int retval = PGPMain.storeKeyRingInCache(pubring);
if (retval != Id.return_value.ok && retval != Id.return_value.updated) {
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.R;
import org.thialfihar.android.apg.helper.FileHelper;
import org.thialfihar.android.apg.helper.OtherHelper;
import android.app.Activity;
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.jcajce.JcePBESecretKeyDecryptorBuilder;
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.Id;
import org.thialfihar.android.apg.R;
@ -68,7 +69,7 @@ public class PassphraseDialogFragment extends DialogFragment {
// check if secret key has a passphrase
if (!(secretKeyId == Id.key.symmetric || secretKeyId == Id.key.none)) {
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) {
// check if the key has no passphrase
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...");
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!");
// cache empty passphrase
PGPHelper.setCachedPassPhrase(secretKey.getKeyID(), "");
PGPMain.setCachedPassPhrase(secretKey.getKeyID(), "");
return false;
}
@ -132,7 +134,7 @@ public class PassphraseDialogFragment extends DialogFragment {
secretKey = null;
alert.setMessage(getString(R.string.passPhraseForSymmetricEncryption));
} else {
secretKey = PGPHelper.getMasterKey(PGPHelper.getSecretKeyRing(secretKeyId));
secretKey = PGPHelper.getMasterKey(PGPMain.getSecretKeyRing(secretKeyId));
if (secretKey == null) {
alert.setTitle(R.string.title_keyNotFound);
alert.setMessage(getString(R.string.keyNotFound, secretKeyId));
@ -189,7 +191,7 @@ public class PassphraseDialogFragment extends DialogFragment {
// cache the new passphrase
Log.d(Constants.TAG, "Everything okay! Caching entered passphrase");
PGPHelper.setCachedPassPhrase(keyId, passPhrase);
PGPMain.setCachedPassPhrase(keyId, passPhrase);
sendMessageToHandler(MESSAGE_OKAY);
}

View File

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

View File

@ -21,6 +21,7 @@ import java.util.Date;
import org.thialfihar.android.apg.R;
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.provider.KeyRings;
import org.thialfihar.android.apg.provider.Keys;
import org.thialfihar.android.apg.provider.UserIds;
@ -53,7 +54,7 @@ public class SelectPublicKeyListAdapter extends BaseAdapter {
mActivity = activity;
mParent = parent;
mDatabase = PGPHelper.getDatabase().db();
mDatabase = PGPMain.getDatabase().db();
mInflater = (LayoutInflater) parent.getContext().getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
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.Id;
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.Keys;
import org.thialfihar.android.apg.provider.UserIds;
@ -48,7 +49,7 @@ public class SelectSecretKeyListAdapter extends BaseAdapter {
mActivity = activity;
mParent = parent;
mDatabase = PGPHelper.getDatabase().db();
mDatabase = PGPMain.getDatabase().db();
mInflater = (LayoutInflater) parent.getContext().getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
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.util.EntityUtils;
import org.thialfihar.android.apg.helper.PGPHelper;
import org.thialfihar.android.apg.helper.PGPMain;
import android.text.Html;
@ -223,7 +224,7 @@ public class HkpKeyServer extends KeyServer {
HttpEntity entity = response.getEntity();
InputStream is = entity.getContent();
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()) {
return matcher.group(1);
}