Switch to spongycastle

https://github.com/rtyley/spongycastle

It replaces bouncycastle2. Looks like a cleaner and better integration. A
precompiled .jar ist in the "lib/"-dir.
This commit is contained in:
Markus Doits 2011-11-03 22:15:31 +01:00
parent e6c86a8892
commit 8d9b0e1db8
15 changed files with 162 additions and 155 deletions

BIN
lib/bcprov-jdk16-146.jar Normal file

Binary file not shown.

11
project.properties Normal file
View File

@ -0,0 +1,11 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-10

View File

@ -16,6 +16,64 @@
package org.thialfihar.android.apg; package org.thialfihar.android.apg;
import org.spongycastle.bcpg.ArmoredInputStream;
import org.spongycastle.bcpg.ArmoredOutputStream;
import org.spongycastle.bcpg.BCPGOutputStream;
import org.spongycastle.bcpg.CompressionAlgorithmTags;
import org.spongycastle.bcpg.HashAlgorithmTags;
import org.spongycastle.bcpg.SymmetricKeyAlgorithmTags;
import org.spongycastle.bcpg.sig.KeyFlags;
import org.spongycastle.jce.provider.BouncyCastleProvider;
import org.spongycastle.jce.spec.ElGamalParameterSpec;
import org.spongycastle.openpgp.PGPCompressedData;
import org.spongycastle.openpgp.PGPCompressedDataGenerator;
import org.spongycastle.openpgp.PGPEncryptedData;
import org.spongycastle.openpgp.PGPEncryptedDataGenerator;
import org.spongycastle.openpgp.PGPEncryptedDataList;
import org.spongycastle.openpgp.PGPException;
import org.spongycastle.openpgp.PGPKeyPair;
import org.spongycastle.openpgp.PGPKeyRingGenerator;
import org.spongycastle.openpgp.PGPLiteralData;
import org.spongycastle.openpgp.PGPLiteralDataGenerator;
import org.spongycastle.openpgp.PGPObjectFactory;
import org.spongycastle.openpgp.PGPOnePassSignature;
import org.spongycastle.openpgp.PGPOnePassSignatureList;
import org.spongycastle.openpgp.PGPPBEEncryptedData;
import org.spongycastle.openpgp.PGPPrivateKey;
import org.spongycastle.openpgp.PGPPublicKey;
import org.spongycastle.openpgp.PGPPublicKeyEncryptedData;
import org.spongycastle.openpgp.PGPPublicKeyRing;
import org.spongycastle.openpgp.PGPSecretKey;
import org.spongycastle.openpgp.PGPSecretKeyRing;
import org.spongycastle.openpgp.PGPSignature;
import org.spongycastle.openpgp.PGPSignatureGenerator;
import org.spongycastle.openpgp.PGPSignatureList;
import org.spongycastle.openpgp.PGPSignatureSubpacketGenerator;
import org.spongycastle.openpgp.PGPSignatureSubpacketVector;
import org.spongycastle.openpgp.PGPUtil;
import org.spongycastle.openpgp.PGPV3SignatureGenerator;
import org.thialfihar.android.apg.provider.DataProvider;
import org.thialfihar.android.apg.provider.Database;
import org.thialfihar.android.apg.provider.KeyRings;
import org.thialfihar.android.apg.provider.Keys;
import org.thialfihar.android.apg.provider.UserIds;
import org.thialfihar.android.apg.ui.widget.KeyEditor;
import org.thialfihar.android.apg.ui.widget.SectionView;
import org.thialfihar.android.apg.ui.widget.UserIdEditor;
import org.thialfihar.android.apg.utils.IterableIterator;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Message;
import android.view.ViewGroup;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@ -45,64 +103,6 @@ import java.util.Map;
import java.util.Vector; import java.util.Vector;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.bouncycastle2.bcpg.ArmoredInputStream;
import org.bouncycastle2.bcpg.ArmoredOutputStream;
import org.bouncycastle2.bcpg.BCPGOutputStream;
import org.bouncycastle2.bcpg.CompressionAlgorithmTags;
import org.bouncycastle2.bcpg.HashAlgorithmTags;
import org.bouncycastle2.bcpg.SymmetricKeyAlgorithmTags;
import org.bouncycastle2.bcpg.sig.KeyFlags;
import org.bouncycastle2.jce.provider.BouncyCastleProvider;
import org.bouncycastle2.jce.spec.ElGamalParameterSpec;
import org.bouncycastle2.openpgp.PGPCompressedData;
import org.bouncycastle2.openpgp.PGPCompressedDataGenerator;
import org.bouncycastle2.openpgp.PGPEncryptedData;
import org.bouncycastle2.openpgp.PGPEncryptedDataGenerator;
import org.bouncycastle2.openpgp.PGPEncryptedDataList;
import org.bouncycastle2.openpgp.PGPException;
import org.bouncycastle2.openpgp.PGPKeyPair;
import org.bouncycastle2.openpgp.PGPKeyRingGenerator;
import org.bouncycastle2.openpgp.PGPLiteralData;
import org.bouncycastle2.openpgp.PGPLiteralDataGenerator;
import org.bouncycastle2.openpgp.PGPObjectFactory;
import org.bouncycastle2.openpgp.PGPOnePassSignature;
import org.bouncycastle2.openpgp.PGPOnePassSignatureList;
import org.bouncycastle2.openpgp.PGPPBEEncryptedData;
import org.bouncycastle2.openpgp.PGPPrivateKey;
import org.bouncycastle2.openpgp.PGPPublicKey;
import org.bouncycastle2.openpgp.PGPPublicKeyEncryptedData;
import org.bouncycastle2.openpgp.PGPPublicKeyRing;
import org.bouncycastle2.openpgp.PGPSecretKey;
import org.bouncycastle2.openpgp.PGPSecretKeyRing;
import org.bouncycastle2.openpgp.PGPSignature;
import org.bouncycastle2.openpgp.PGPSignatureGenerator;
import org.bouncycastle2.openpgp.PGPSignatureList;
import org.bouncycastle2.openpgp.PGPSignatureSubpacketGenerator;
import org.bouncycastle2.openpgp.PGPSignatureSubpacketVector;
import org.bouncycastle2.openpgp.PGPUtil;
import org.bouncycastle2.openpgp.PGPV3SignatureGenerator;
import org.thialfihar.android.apg.provider.DataProvider;
import org.thialfihar.android.apg.provider.Database;
import org.thialfihar.android.apg.provider.KeyRings;
import org.thialfihar.android.apg.provider.Keys;
import org.thialfihar.android.apg.provider.UserIds;
import org.thialfihar.android.apg.ui.widget.KeyEditor;
import org.thialfihar.android.apg.ui.widget.SectionView;
import org.thialfihar.android.apg.ui.widget.UserIdEditor;
import org.thialfihar.android.apg.utils.IterableIterator;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Message;
import android.view.ViewGroup;
public class Apg { public class Apg {
private static final String mApgPackageName = "org.thialfihar.android.apg"; private static final String mApgPackageName = "org.thialfihar.android.apg";
@ -1145,11 +1145,8 @@ public class Apg {
if (keyRing == null) { if (keyRing == null) {
return null; return null;
} }
try {
return keyRing.getPublicKey(keyId); return keyRing.getPublicKey(keyId);
} catch (PGPException e) {
return null;
}
} }
public static Vector<Integer> getKeyRingIds(int type) { public static Vector<Integer> getKeyRingIds(int type) {

View File

@ -16,11 +16,10 @@
package org.thialfihar.android.apg; package org.thialfihar.android.apg;
import org.bouncycastle2.jce.provider.BouncyCastleProvider; import org.spongycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle2.openpgp.PGPException; import org.spongycastle.openpgp.PGPException;
import org.bouncycastle2.openpgp.PGPPrivateKey; import org.spongycastle.openpgp.PGPPrivateKey;
import org.bouncycastle2.openpgp.PGPSecretKey; import org.spongycastle.openpgp.PGPSecretKey;
import org.thialfihar.android.apg.Apg.GeneralException;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;

View File

@ -16,19 +16,9 @@
package org.thialfihar.android.apg; package org.thialfihar.android.apg;
import java.io.ByteArrayOutputStream; import org.spongycastle.jce.provider.BouncyCastleProvider;
import java.io.File; import org.spongycastle.openpgp.PGPException;
import java.io.FileNotFoundException; import org.spongycastle.openpgp.PGPPublicKeyRing;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.Security;
import java.security.SignatureException;
import java.util.regex.Matcher;
import org.bouncycastle2.jce.provider.BouncyCastleProvider;
import org.bouncycastle2.openpgp.PGPException;
import org.bouncycastle2.openpgp.PGPPublicKeyRing;
import org.thialfihar.android.apg.provider.DataProvider; import org.thialfihar.android.apg.provider.DataProvider;
import android.app.AlertDialog; import android.app.AlertDialog;
@ -53,6 +43,16 @@ import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import android.widget.ViewFlipper; import android.widget.ViewFlipper;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.Security;
import java.security.SignatureException;
import java.util.regex.Matcher;
public class DecryptActivity extends BaseActivity { public class DecryptActivity extends BaseActivity {
private long mSignatureKeyId = 0; private long mSignatureKeyId = 0;

View File

@ -16,15 +16,9 @@
package org.thialfihar.android.apg; package org.thialfihar.android.apg;
import java.io.IOException; import org.spongycastle.openpgp.PGPException;
import java.security.NoSuchAlgorithmException; import org.spongycastle.openpgp.PGPSecretKey;
import java.security.NoSuchProviderException; import org.spongycastle.openpgp.PGPSecretKeyRing;
import java.security.SignatureException;
import java.util.Vector;
import org.bouncycastle2.openpgp.PGPException;
import org.bouncycastle2.openpgp.PGPSecretKey;
import org.bouncycastle2.openpgp.PGPSecretKeyRing;
import org.thialfihar.android.apg.provider.Database; import org.thialfihar.android.apg.provider.Database;
import org.thialfihar.android.apg.ui.widget.KeyEditor; import org.thialfihar.android.apg.ui.widget.KeyEditor;
import org.thialfihar.android.apg.ui.widget.SectionView; import org.thialfihar.android.apg.ui.widget.SectionView;
@ -46,6 +40,12 @@ import android.widget.EditText;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.Toast; import android.widget.Toast;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.SignatureException;
import java.util.Vector;
public class EditKeyActivity extends BaseActivity implements OnClickListener { public class EditKeyActivity extends BaseActivity implements OnClickListener {
private PGPSecretKeyRing mKeyRing = null; private PGPSecretKeyRing mKeyRing = null;

View File

@ -16,21 +16,11 @@
package org.thialfihar.android.apg; package org.thialfihar.android.apg;
import java.io.ByteArrayOutputStream; import org.spongycastle.openpgp.PGPException;
import java.io.File; import org.spongycastle.openpgp.PGPPublicKey;
import java.io.FileOutputStream; import org.spongycastle.openpgp.PGPPublicKeyRing;
import java.io.IOException; import org.spongycastle.openpgp.PGPSecretKey;
import java.io.OutputStream; import org.spongycastle.openpgp.PGPSecretKeyRing;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.SignatureException;
import java.util.Vector;
import org.bouncycastle2.openpgp.PGPException;
import org.bouncycastle2.openpgp.PGPPublicKey;
import org.bouncycastle2.openpgp.PGPPublicKeyRing;
import org.bouncycastle2.openpgp.PGPSecretKey;
import org.bouncycastle2.openpgp.PGPSecretKeyRing;
import org.thialfihar.android.apg.provider.DataProvider; import org.thialfihar.android.apg.provider.DataProvider;
import org.thialfihar.android.apg.utils.Choice; import org.thialfihar.android.apg.utils.Choice;
@ -55,6 +45,16 @@ import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import android.widget.ViewFlipper; import android.widget.ViewFlipper;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.SignatureException;
import java.util.Vector;
public class EncryptActivity extends BaseActivity { public class EncryptActivity extends BaseActivity {
private Intent mIntent = null; private Intent mIntent = null;
private String mSubject = null; private String mSubject = null;

View File

@ -16,7 +16,7 @@
package org.thialfihar.android.apg; package org.thialfihar.android.apg;
import org.bouncycastle2.bcpg.CompressionAlgorithmTags; import org.spongycastle.bcpg.CompressionAlgorithmTags;
public final class Id { public final class Id {
public static final class menu { public static final class menu {

View File

@ -16,19 +16,9 @@
package org.thialfihar.android.apg; package org.thialfihar.android.apg;
import java.io.ByteArrayInputStream; import org.spongycastle.openpgp.PGPException;
import java.io.File; import org.spongycastle.openpgp.PGPPublicKeyRing;
import java.io.FileInputStream; import org.spongycastle.openpgp.PGPSecretKeyRing;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Vector;
import org.bouncycastle2.openpgp.PGPException;
import org.bouncycastle2.openpgp.PGPPublicKeyRing;
import org.bouncycastle2.openpgp.PGPSecretKeyRing;
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;
@ -58,6 +48,16 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Vector;
public class KeyListActivity extends BaseActivity { public class KeyListActivity extends BaseActivity {
protected ExpandableListView mList; protected ExpandableListView mList;
protected KeyListAdapter mListAdapter; protected KeyListAdapter mListAdapter;

View File

@ -1,13 +1,13 @@
package org.thialfihar.android.apg; package org.thialfihar.android.apg;
import java.util.Vector; import org.spongycastle.bcpg.HashAlgorithmTags;
import org.spongycastle.openpgp.PGPEncryptedData;
import org.bouncycastle2.bcpg.HashAlgorithmTags;
import org.bouncycastle2.openpgp.PGPEncryptedData;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import java.util.Vector;
public class Preferences { public class Preferences {
private static Preferences mPreferences; private static Preferences mPreferences;
private SharedPreferences mSharedPreferences; private SharedPreferences mSharedPreferences;

View File

@ -16,12 +16,8 @@
package org.thialfihar.android.apg; package org.thialfihar.android.apg;
import java.util.Arrays; import org.spongycastle.bcpg.HashAlgorithmTags;
import java.util.HashSet; import org.spongycastle.openpgp.PGPEncryptedData;
import java.util.Vector;
import org.bouncycastle2.bcpg.HashAlgorithmTags;
import org.bouncycastle2.openpgp.PGPEncryptedData;
import org.thialfihar.android.apg.ui.widget.IntegerListPreference; import org.thialfihar.android.apg.ui.widget.IntegerListPreference;
import android.content.Intent; import android.content.Intent;
@ -32,6 +28,10 @@ import android.preference.Preference;
import android.preference.PreferenceActivity; import android.preference.PreferenceActivity;
import android.preference.PreferenceScreen; import android.preference.PreferenceScreen;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Vector;
public class PreferencesActivity extends PreferenceActivity { public class PreferencesActivity extends PreferenceActivity {
private ListPreference mLanguage = null; private ListPreference mLanguage = null;
private IntegerListPreference mPassPhraseCacheTtl = null; private IntegerListPreference mPassPhraseCacheTtl = null;

View File

@ -16,7 +16,7 @@
package org.thialfihar.android.apg; package org.thialfihar.android.apg;
import org.bouncycastle2.openpgp.PGPPublicKeyRing; import org.spongycastle.openpgp.PGPPublicKeyRing;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;

View File

@ -1,15 +1,10 @@
package org.thialfihar.android.apg.provider; package org.thialfihar.android.apg.provider;
import java.io.IOException; import org.spongycastle.openpgp.PGPException;
import java.util.Date; import org.spongycastle.openpgp.PGPPublicKey;
import java.util.HashMap; import org.spongycastle.openpgp.PGPPublicKeyRing;
import java.util.Vector; import org.spongycastle.openpgp.PGPSecretKey;
import org.spongycastle.openpgp.PGPSecretKeyRing;
import org.bouncycastle2.openpgp.PGPException;
import org.bouncycastle2.openpgp.PGPPublicKey;
import org.bouncycastle2.openpgp.PGPPublicKeyRing;
import org.bouncycastle2.openpgp.PGPSecretKey;
import org.bouncycastle2.openpgp.PGPSecretKeyRing;
import org.thialfihar.android.apg.Apg; import org.thialfihar.android.apg.Apg;
import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.Id;
import org.thialfihar.android.apg.utils.IterableIterator; import org.thialfihar.android.apg.utils.IterableIterator;
@ -21,6 +16,11 @@ import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log; import android.util.Log;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Vector;
public class Database extends SQLiteOpenHelper { public class Database extends SQLiteOpenHelper {
public static class GeneralException extends Exception { public static class GeneralException extends Exception {
static final long serialVersionUID = 0xf812773343L; static final long serialVersionUID = 0xf812773343L;

View File

@ -16,14 +16,8 @@
package org.thialfihar.android.apg.ui.widget; package org.thialfihar.android.apg.ui.widget;
import java.text.DateFormat; import org.spongycastle.openpgp.PGPPublicKey;
import java.util.Calendar; import org.spongycastle.openpgp.PGPSecretKey;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Vector;
import org.bouncycastle2.openpgp.PGPPublicKey;
import org.bouncycastle2.openpgp.PGPSecretKey;
import org.thialfihar.android.apg.Apg; import org.thialfihar.android.apg.Apg;
import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.Id;
import org.thialfihar.android.apg.R; import org.thialfihar.android.apg.R;
@ -45,6 +39,12 @@ import android.widget.LinearLayout;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Vector;
public class KeyEditor extends LinearLayout implements Editor, OnClickListener { public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
private PGPSecretKey mKey; private PGPSecretKey mKey;

View File

@ -16,14 +16,8 @@
package org.thialfihar.android.apg.ui.widget; package org.thialfihar.android.apg.ui.widget;
import java.security.InvalidAlgorithmParameterException; import org.spongycastle.openpgp.PGPException;
import java.security.InvalidParameterException; import org.spongycastle.openpgp.PGPSecretKey;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.util.Vector;
import org.bouncycastle2.openpgp.PGPException;
import org.bouncycastle2.openpgp.PGPSecretKey;
import org.thialfihar.android.apg.Apg; import org.thialfihar.android.apg.Apg;
import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.Id;
import org.thialfihar.android.apg.R; import org.thialfihar.android.apg.R;
@ -49,6 +43,12 @@ import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidParameterException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.util.Vector;
public class SectionView extends LinearLayout implements OnClickListener, EditorListener, Runnable { public class SectionView extends LinearLayout implements OnClickListener, EditorListener, Runnable {
private LayoutInflater mInflater; private LayoutInflater mInflater;
private View mAdd; private View mAdd;