mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-12 03:55:09 -05:00
more code style changes in /ui and /util
This commit is contained in:
parent
4353ea37e2
commit
2ff6949c95
@ -848,7 +848,7 @@ public class EncryptActivity extends DrawerActivity {
|
|||||||
new Choice(Id.choice.compression.zlib, "ZLIB ("
|
new Choice(Id.choice.compression.zlib, "ZLIB ("
|
||||||
+ getString(R.string.compression_fast) + ")"),
|
+ getString(R.string.compression_fast) + ")"),
|
||||||
new Choice(Id.choice.compression.bzip2, "BZIP2 ("
|
new Choice(Id.choice.compression.bzip2, "BZIP2 ("
|
||||||
+ getString(R.string.compression_very_slow) + ")"),};
|
+ getString(R.string.compression_very_slow) + ")"), };
|
||||||
ArrayAdapter<Choice> adapter = new ArrayAdapter<Choice>(this,
|
ArrayAdapter<Choice> adapter = new ArrayAdapter<Choice>(this,
|
||||||
android.R.layout.simple_spinner_item, choices);
|
android.R.layout.simple_spinner_item, choices);
|
||||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
|
@ -167,7 +167,8 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa
|
|||||||
query = "0x" + fingerprint;
|
query = "0x" + fingerprint;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.e(Constants.TAG, "IMPORT_KEY_FROM_KEYSERVER action needs to contain the 'query', 'key_id', or 'fingerprint' extra!");
|
Log.e(Constants.TAG,
|
||||||
|
"IMPORT_KEY_FROM_KEYSERVER action needs to contain the 'query', 'key_id', or 'fingerprint' extra!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,7 +337,7 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa
|
|||||||
// } else {
|
// } else {
|
||||||
// status.putString(
|
// status.putString(
|
||||||
// EXTRA_ERROR,
|
// EXTRA_ERROR,
|
||||||
// "Scanned fingerprint does NOT match the fingerprint of the received key. You shouldnt trust this key.");
|
// "Scanned fingerprint does NOT match the fingerprint of the received key. You shouldnt trust this key.");
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// } catch (QueryException e) {
|
// } catch (QueryException e) {
|
||||||
@ -398,7 +399,8 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa
|
|||||||
AppMsg.makeText(ImportKeysActivity.this, toastMessage, AppMsg.STYLE_INFO)
|
AppMsg.makeText(ImportKeysActivity.this, toastMessage, AppMsg.STYLE_INFO)
|
||||||
.show();
|
.show();
|
||||||
if (bad > 0) {
|
if (bad > 0) {
|
||||||
BadImportKeyDialogFragment badImportKeyDialogFragment = BadImportKeyDialogFragment.newInstance(bad);
|
BadImportKeyDialogFragment badImportKeyDialogFragment =
|
||||||
|
BadImportKeyDialogFragment.newInstance(bad);
|
||||||
badImportKeyDialogFragment.show(getSupportFragmentManager(), "badKeyDialog");
|
badImportKeyDialogFragment.show(getSupportFragmentManager(), "badKeyDialog");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,8 @@ public class ImportKeysServerFragment extends Fragment {
|
|||||||
search(query, keyServer);
|
search(query, keyServer);
|
||||||
|
|
||||||
// close keyboard after pressing search
|
// close keyboard after pressing search
|
||||||
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
InputMethodManager imm =
|
||||||
|
(InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
imm.hideSoftInputFromWindow(mQueryEditText.getWindowToken(), 0);
|
imm.hideSoftInputFromWindow(mQueryEditText.getWindowToken(), 0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -108,7 +109,6 @@ public class ImportKeysServerFragment extends Fragment {
|
|||||||
search(query, keyServer);
|
search(query, keyServer);
|
||||||
|
|
||||||
// Don't return true to let the keyboard close itself after pressing search
|
// Don't return true to let the keyboard close itself after pressing search
|
||||||
// http://stackoverflow.com/questions/2342620/how-to-hide-keyboard-after-typing-in-edittext-in-android
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -141,7 +141,7 @@ public class SelectSecretKeyFragment extends ListFragment implements
|
|||||||
+ Keys.IS_REVOKED + " = '0' AND valid_keys." + Keys.CAN_SIGN
|
+ Keys.IS_REVOKED + " = '0' AND valid_keys." + Keys.CAN_SIGN
|
||||||
+ " = '1' AND valid_keys." + Keys.CREATION + " <= '" + now + "' AND "
|
+ " = '1' AND valid_keys." + Keys.CREATION + " <= '" + now + "' AND "
|
||||||
+ "(valid_keys." + Keys.EXPIRY + " IS NULL OR valid_keys." + Keys.EXPIRY
|
+ "(valid_keys." + Keys.EXPIRY + " IS NULL OR valid_keys." + Keys.EXPIRY
|
||||||
+ " >= '" + now + "')) AS " + SelectKeyCursorAdapter.PROJECTION_ROW_VALID,};
|
+ " >= '" + now + "')) AS " + SelectKeyCursorAdapter.PROJECTION_ROW_VALID, };
|
||||||
|
|
||||||
String orderBy = UserIds.USER_ID + " ASC";
|
String orderBy = UserIds.USER_ID + " ASC";
|
||||||
|
|
||||||
|
@ -27,20 +27,20 @@ package org.sufficientlysecure.keychain.ui.adapter;
|
|||||||
*/
|
*/
|
||||||
public class AsyncTaskResultWrapper<T> {
|
public class AsyncTaskResultWrapper<T> {
|
||||||
|
|
||||||
private final T result;
|
private final T mResult;
|
||||||
private final Exception error;
|
private final Exception mError;
|
||||||
|
|
||||||
public AsyncTaskResultWrapper(T result, Exception error) {
|
public AsyncTaskResultWrapper(T result, Exception error) {
|
||||||
this.result = result;
|
this.mResult = result;
|
||||||
this.error = error;
|
this.mError = error;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T getResult() {
|
public T getResult() {
|
||||||
return result;
|
return mResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Exception getError() {
|
public Exception getError() {
|
||||||
return error;
|
return mError;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,15 +40,15 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
|
|||||||
protected LayoutInflater mInflater;
|
protected LayoutInflater mInflater;
|
||||||
protected Activity mActivity;
|
protected Activity mActivity;
|
||||||
|
|
||||||
protected List<ImportKeysListEntry> data;
|
protected List<ImportKeysListEntry> mData;
|
||||||
|
|
||||||
static class ViewHolder {
|
static class ViewHolder {
|
||||||
private TextView mainUserId;
|
private TextView mMainUserId;
|
||||||
private TextView mainUserIdRest;
|
private TextView mMainUserIdRest;
|
||||||
private TextView keyId;
|
private TextView mKeyId;
|
||||||
private TextView fingerprint;
|
private TextView mFingerprint;
|
||||||
private TextView algorithm;
|
private TextView mAlgorithm;
|
||||||
private TextView status;
|
private TextView mStatus;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
|
|||||||
public void setData(List<ImportKeysListEntry> data) {
|
public void setData(List<ImportKeysListEntry> data) {
|
||||||
clear();
|
clear();
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
this.data = data;
|
this.mData = data;
|
||||||
|
|
||||||
// add data to extended ArrayAdapter
|
// add data to extended ArrayAdapter
|
||||||
if (Build.VERSION.SDK_INT >= 11) {
|
if (Build.VERSION.SDK_INT >= 11) {
|
||||||
@ -76,14 +76,15 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<ImportKeysListEntry> getData() {
|
public List<ImportKeysListEntry> getData() {
|
||||||
return data;
|
return mData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<ImportKeysListEntry> getSelectedData() {
|
public ArrayList<ImportKeysListEntry> getSelectedData() {
|
||||||
ArrayList<ImportKeysListEntry> selectedData = new ArrayList<ImportKeysListEntry>();
|
ArrayList<ImportKeysListEntry> selectedData = new ArrayList<ImportKeysListEntry>();
|
||||||
for (ImportKeysListEntry entry : data) {
|
for (ImportKeysListEntry entry : mData) {
|
||||||
if (entry.isSelected())
|
if (entry.isSelected()) {
|
||||||
selectedData.add(entry);
|
selectedData.add(entry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return selectedData;
|
return selectedData;
|
||||||
}
|
}
|
||||||
@ -94,17 +95,17 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
ImportKeysListEntry entry = data.get(position);
|
ImportKeysListEntry entry = mData.get(position);
|
||||||
ViewHolder holder;
|
ViewHolder holder;
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
holder = new ViewHolder();
|
holder = new ViewHolder();
|
||||||
convertView = mInflater.inflate(R.layout.import_keys_list_entry, null);
|
convertView = mInflater.inflate(R.layout.import_keys_list_entry, null);
|
||||||
holder.mainUserId = (TextView) convertView.findViewById(R.id.mainUserId);
|
holder.mMainUserId = (TextView) convertView.findViewById(R.id.mainUserId);
|
||||||
holder.mainUserIdRest = (TextView) convertView.findViewById(R.id.mainUserIdRest);
|
holder.mMainUserIdRest = (TextView) convertView.findViewById(R.id.mainUserIdRest);
|
||||||
holder.keyId = (TextView) convertView.findViewById(R.id.keyId);
|
holder.mKeyId = (TextView) convertView.findViewById(R.id.keyId);
|
||||||
holder.fingerprint = (TextView) convertView.findViewById(R.id.fingerprint);
|
holder.mFingerprint = (TextView) convertView.findViewById(R.id.fingerprint);
|
||||||
holder.algorithm = (TextView) convertView.findViewById(R.id.algorithm);
|
holder.mAlgorithm = (TextView) convertView.findViewById(R.id.algorithm);
|
||||||
holder.status = (TextView) convertView.findViewById(R.id.status);
|
holder.mStatus = (TextView) convertView.findViewById(R.id.status);
|
||||||
convertView.setTag(holder);
|
convertView.setTag(holder);
|
||||||
} else {
|
} else {
|
||||||
holder = (ViewHolder) convertView.getTag();
|
holder = (ViewHolder) convertView.getTag();
|
||||||
@ -118,36 +119,36 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
|
|||||||
// show red user id if it is a secret key
|
// show red user id if it is a secret key
|
||||||
if (entry.secretKey) {
|
if (entry.secretKey) {
|
||||||
userIdSplit[0] = mActivity.getString(R.string.secret_key) + " " + userIdSplit[0];
|
userIdSplit[0] = mActivity.getString(R.string.secret_key) + " " + userIdSplit[0];
|
||||||
holder.mainUserId.setTextColor(Color.RED);
|
holder.mMainUserId.setTextColor(Color.RED);
|
||||||
}
|
}
|
||||||
holder.mainUserId.setText(userIdSplit[0]);
|
holder.mMainUserId.setText(userIdSplit[0]);
|
||||||
} else {
|
} else {
|
||||||
holder.mainUserId.setText(R.string.user_id_no_name);
|
holder.mMainUserId.setText(R.string.user_id_no_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// email
|
// email
|
||||||
if (userIdSplit[1] != null) {
|
if (userIdSplit[1] != null) {
|
||||||
holder.mainUserIdRest.setText(userIdSplit[1]);
|
holder.mMainUserIdRest.setText(userIdSplit[1]);
|
||||||
holder.mainUserIdRest.setVisibility(View.VISIBLE);
|
holder.mMainUserIdRest.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
holder.mainUserIdRest.setVisibility(View.GONE);
|
holder.mMainUserIdRest.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.keyId.setText(entry.hexKeyId);
|
holder.mKeyId.setText(entry.hexKeyId);
|
||||||
|
|
||||||
if (entry.fingerPrint != null) {
|
if (entry.fingerPrint != null) {
|
||||||
holder.fingerprint.setText(mActivity.getString(R.string.fingerprint) + " " + entry.fingerPrint);
|
holder.mFingerprint.setText(mActivity.getString(R.string.fingerprint) + " " + entry.fingerPrint);
|
||||||
holder.fingerprint.setVisibility(View.VISIBLE);
|
holder.mFingerprint.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
holder.fingerprint.setVisibility(View.GONE);
|
holder.mFingerprint.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.algorithm.setText("" + entry.bitStrength + "/" + entry.algorithm);
|
holder.mAlgorithm.setText("" + entry.bitStrength + "/" + entry.algorithm);
|
||||||
|
|
||||||
if (entry.revoked) {
|
if (entry.revoked) {
|
||||||
holder.status.setText(R.string.revoked);
|
holder.mStatus.setText(R.string.revoked);
|
||||||
} else {
|
} else {
|
||||||
holder.status.setVisibility(View.GONE);
|
holder.mStatus.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
LinearLayout ll = (LinearLayout) convertView.findViewById(R.id.list);
|
LinearLayout ll = (LinearLayout) convertView.findViewById(R.id.list);
|
||||||
|
@ -45,9 +45,9 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||||||
public String algorithm;
|
public String algorithm;
|
||||||
public boolean secretKey;
|
public boolean secretKey;
|
||||||
|
|
||||||
private boolean selected;
|
private boolean mSelected;
|
||||||
|
|
||||||
private byte[] bytes = new byte[]{};
|
private byte[] mBytes = new byte[]{};
|
||||||
|
|
||||||
public ImportKeysListEntry(ImportKeysListEntry b) {
|
public ImportKeysListEntry(ImportKeysListEntry b) {
|
||||||
this.userIds = b.userIds;
|
this.userIds = b.userIds;
|
||||||
@ -59,8 +59,8 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||||||
this.bitStrength = b.bitStrength;
|
this.bitStrength = b.bitStrength;
|
||||||
this.algorithm = b.algorithm;
|
this.algorithm = b.algorithm;
|
||||||
this.secretKey = b.secretKey;
|
this.secretKey = b.secretKey;
|
||||||
this.selected = b.selected;
|
this.mSelected = b.mSelected;
|
||||||
this.bytes = b.bytes;
|
this.mBytes = b.mBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int describeContents() {
|
public int describeContents() {
|
||||||
@ -78,9 +78,9 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||||||
dest.writeInt(bitStrength);
|
dest.writeInt(bitStrength);
|
||||||
dest.writeString(algorithm);
|
dest.writeString(algorithm);
|
||||||
dest.writeByte((byte) (secretKey ? 1 : 0));
|
dest.writeByte((byte) (secretKey ? 1 : 0));
|
||||||
dest.writeByte((byte) (selected ? 1 : 0));
|
dest.writeByte((byte) (mSelected ? 1 : 0));
|
||||||
dest.writeInt(bytes.length);
|
dest.writeInt(mBytes.length);
|
||||||
dest.writeByteArray(bytes);
|
dest.writeByteArray(mBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Creator<ImportKeysListEntry> CREATOR = new Creator<ImportKeysListEntry>() {
|
public static final Creator<ImportKeysListEntry> CREATOR = new Creator<ImportKeysListEntry>() {
|
||||||
@ -96,9 +96,9 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||||||
vr.bitStrength = source.readInt();
|
vr.bitStrength = source.readInt();
|
||||||
vr.algorithm = source.readString();
|
vr.algorithm = source.readString();
|
||||||
vr.secretKey = source.readByte() == 1;
|
vr.secretKey = source.readByte() == 1;
|
||||||
vr.selected = source.readByte() == 1;
|
vr.mSelected = source.readByte() == 1;
|
||||||
vr.bytes = new byte[source.readInt()];
|
vr.mBytes = new byte[source.readInt()];
|
||||||
source.readByteArray(vr.bytes);
|
source.readByteArray(vr.mBytes);
|
||||||
|
|
||||||
return vr;
|
return vr;
|
||||||
}
|
}
|
||||||
@ -113,11 +113,11 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getBytes() {
|
public byte[] getBytes() {
|
||||||
return bytes;
|
return mBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBytes(byte[] bytes) {
|
public void setBytes(byte[] bytes) {
|
||||||
this.bytes = bytes;
|
this.mBytes = bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -127,16 +127,16 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||||||
// keys from keyserver are always public keys
|
// keys from keyserver are always public keys
|
||||||
secretKey = false;
|
secretKey = false;
|
||||||
// do not select by default
|
// do not select by default
|
||||||
selected = false;
|
mSelected = false;
|
||||||
userIds = new ArrayList<String>();
|
userIds = new ArrayList<String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSelected() {
|
public boolean isSelected() {
|
||||||
return selected;
|
return mSelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelected(boolean selected) {
|
public void setSelected(boolean selected) {
|
||||||
this.selected = selected;
|
this.mSelected = selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -146,13 +146,13 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||||||
public ImportKeysListEntry(PGPKeyRing pgpKeyRing) {
|
public ImportKeysListEntry(PGPKeyRing pgpKeyRing) {
|
||||||
// save actual key object into entry, used to import it later
|
// save actual key object into entry, used to import it later
|
||||||
try {
|
try {
|
||||||
this.bytes = pgpKeyRing.getEncoded();
|
this.mBytes = pgpKeyRing.getEncoded();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(Constants.TAG, "IOException on pgpKeyRing.getEncoded()", e);
|
Log.e(Constants.TAG, "IOException on pgpKeyRing.getEncoded()", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// selected is default
|
// selected is default
|
||||||
this.selected = true;
|
this.mSelected = true;
|
||||||
|
|
||||||
if (pgpKeyRing instanceof PGPSecretKeyRing) {
|
if (pgpKeyRing instanceof PGPSecretKeyRing) {
|
||||||
secretKey = true;
|
secretKey = true;
|
||||||
|
@ -31,21 +31,22 @@ import java.io.BufferedInputStream;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class ImportKeysListLoader extends AsyncTaskLoader<AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>> {
|
public class ImportKeysListLoader
|
||||||
|
extends AsyncTaskLoader<AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>> {
|
||||||
|
|
||||||
public static class FileHasNoContent extends Exception {
|
public static class FileHasNoContent extends Exception {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class NonPgpPart extends Exception {
|
public static class NonPgpPart extends Exception {
|
||||||
private int count;
|
private int mCount;
|
||||||
|
|
||||||
public NonPgpPart(int count) {
|
public NonPgpPart(int count) {
|
||||||
this.count = count;
|
this.mCount = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return count;
|
return mCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,8 +54,8 @@ public class ImportKeysListLoader extends AsyncTaskLoader<AsyncTaskResultWrapper
|
|||||||
|
|
||||||
InputData mInputData;
|
InputData mInputData;
|
||||||
|
|
||||||
ArrayList<ImportKeysListEntry> data = new ArrayList<ImportKeysListEntry>();
|
ArrayList<ImportKeysListEntry> mData = new ArrayList<ImportKeysListEntry>();
|
||||||
AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> entryListWrapper;
|
AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> mEntryListWrapper;
|
||||||
|
|
||||||
public ImportKeysListLoader(Context context, InputData inputData) {
|
public ImportKeysListLoader(Context context, InputData inputData) {
|
||||||
super(context);
|
super(context);
|
||||||
@ -65,16 +66,16 @@ public class ImportKeysListLoader extends AsyncTaskLoader<AsyncTaskResultWrapper
|
|||||||
@Override
|
@Override
|
||||||
public AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> loadInBackground() {
|
public AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> loadInBackground() {
|
||||||
|
|
||||||
entryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(data, null);
|
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mData, null);
|
||||||
|
|
||||||
if (mInputData == null) {
|
if (mInputData == null) {
|
||||||
Log.e(Constants.TAG, "Input data is null!");
|
Log.e(Constants.TAG, "Input data is null!");
|
||||||
return entryListWrapper;
|
return mEntryListWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
generateListOfKeyrings(mInputData);
|
generateListOfKeyrings(mInputData);
|
||||||
|
|
||||||
return entryListWrapper;
|
return mEntryListWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -142,25 +143,25 @@ public class ImportKeysListLoader extends AsyncTaskLoader<AsyncTaskResultWrapper
|
|||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(Constants.TAG, "Exception on parsing key file!", e);
|
Log.e(Constants.TAG, "Exception on parsing key file!", e);
|
||||||
entryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(data, e);
|
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mData, e);
|
||||||
nonPgpCounter = 0;
|
nonPgpCounter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isEmpty) {
|
if (isEmpty) {
|
||||||
Log.e(Constants.TAG, "File has no content!", new FileHasNoContent());
|
Log.e(Constants.TAG, "File has no content!", new FileHasNoContent());
|
||||||
entryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>
|
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>
|
||||||
(data, new FileHasNoContent());
|
(mData, new FileHasNoContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nonPgpCounter > 0) {
|
if (nonPgpCounter > 0) {
|
||||||
entryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>
|
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>
|
||||||
(data, new NonPgpPart(nonPgpCounter));
|
(mData, new NonPgpPart(nonPgpCounter));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addToData(PGPKeyRing keyring) {
|
private void addToData(PGPKeyRing keyring) {
|
||||||
ImportKeysListEntry item = new ImportKeysListEntry(keyring);
|
ImportKeysListEntry item = new ImportKeysListEntry(keyring);
|
||||||
data.add(item);
|
mData.add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,14 +26,15 @@ import org.sufficientlysecure.keychain.util.Log;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class ImportKeysListServerLoader extends AsyncTaskLoader<AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>> {
|
public class ImportKeysListServerLoader
|
||||||
|
extends AsyncTaskLoader<AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>> {
|
||||||
Context mContext;
|
Context mContext;
|
||||||
|
|
||||||
String mServerQuery;
|
String mServerQuery;
|
||||||
String mKeyServer;
|
String mKeyServer;
|
||||||
|
|
||||||
private ArrayList<ImportKeysListEntry> entryList = new ArrayList<ImportKeysListEntry>();
|
private ArrayList<ImportKeysListEntry> mEntryList = new ArrayList<ImportKeysListEntry>();
|
||||||
private AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> entryListWrapper;
|
private AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> mEntryListWrapper;
|
||||||
|
|
||||||
public ImportKeysListServerLoader(Context context, String serverQuery, String keyServer) {
|
public ImportKeysListServerLoader(Context context, String serverQuery, String keyServer) {
|
||||||
super(context);
|
super(context);
|
||||||
@ -45,16 +46,16 @@ public class ImportKeysListServerLoader extends AsyncTaskLoader<AsyncTaskResultW
|
|||||||
@Override
|
@Override
|
||||||
public AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> loadInBackground() {
|
public AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> loadInBackground() {
|
||||||
|
|
||||||
entryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(entryList, null);
|
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, null);
|
||||||
|
|
||||||
if (mServerQuery == null) {
|
if (mServerQuery == null) {
|
||||||
Log.e(Constants.TAG, "mServerQuery is null!");
|
Log.e(Constants.TAG, "mServerQuery is null!");
|
||||||
return entryListWrapper;
|
return mEntryListWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
queryServer(mServerQuery, mKeyServer);
|
queryServer(mServerQuery, mKeyServer);
|
||||||
|
|
||||||
return entryListWrapper;
|
return mEntryListWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -89,17 +90,17 @@ public class ImportKeysListServerLoader extends AsyncTaskLoader<AsyncTaskResultW
|
|||||||
ArrayList<ImportKeysListEntry> searchResult = server.search(query);
|
ArrayList<ImportKeysListEntry> searchResult = server.search(query);
|
||||||
|
|
||||||
// add result to data
|
// add result to data
|
||||||
entryList.addAll(searchResult);
|
mEntryList.addAll(searchResult);
|
||||||
entryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(entryList, null);
|
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, null);
|
||||||
} catch (KeyServer.InsufficientQuery e) {
|
} catch (KeyServer.InsufficientQuery e) {
|
||||||
Log.e(Constants.TAG, "InsufficientQuery", e);
|
Log.e(Constants.TAG, "InsufficientQuery", e);
|
||||||
entryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(entryList, e);
|
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, e);
|
||||||
} catch (KeyServer.QueryException e) {
|
} catch (KeyServer.QueryException e) {
|
||||||
Log.e(Constants.TAG, "QueryException", e);
|
Log.e(Constants.TAG, "QueryException", e);
|
||||||
entryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(entryList, e);
|
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, e);
|
||||||
} catch (KeyServer.TooManyResponses e) {
|
} catch (KeyServer.TooManyResponses e) {
|
||||||
Log.e(Constants.TAG, "TooManyResponses", e);
|
Log.e(Constants.TAG, "TooManyResponses", e);
|
||||||
entryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(entryList, e);
|
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,8 +44,8 @@ public class SelectKeyCursorAdapter extends HighlightQueryCursorAdapter {
|
|||||||
private int mIndexProjectionValid;
|
private int mIndexProjectionValid;
|
||||||
private int mIndexProjectionAvailable;
|
private int mIndexProjectionAvailable;
|
||||||
|
|
||||||
public final static String PROJECTION_ROW_AVAILABLE = "available";
|
public static final String PROJECTION_ROW_AVAILABLE = "available";
|
||||||
public final static String PROJECTION_ROW_VALID = "valid";
|
public static final String PROJECTION_ROW_VALID = "valid";
|
||||||
|
|
||||||
public SelectKeyCursorAdapter(Context context, Cursor c, int flags, ListView listView,
|
public SelectKeyCursorAdapter(Context context, Cursor c, int flags, ListView listView,
|
||||||
int keyType) {
|
int keyType) {
|
||||||
|
@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2012-2014 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package org.sufficientlysecure.keychain.ui.adapter;
|
package org.sufficientlysecure.keychain.ui.adapter;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -19,12 +36,12 @@ public class TabsAdapter extends FragmentStatePagerAdapter implements ActionBar.
|
|||||||
private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>();
|
private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>();
|
||||||
|
|
||||||
static final class TabInfo {
|
static final class TabInfo {
|
||||||
private final Class<?> clss;
|
private final Class<?> mClss;
|
||||||
private final Bundle args;
|
private final Bundle mArgs;
|
||||||
|
|
||||||
TabInfo(Class<?> _class, Bundle _args) {
|
TabInfo(Class<?> mClss, Bundle mArgs) {
|
||||||
clss = _class;
|
this.mClss = mClss;
|
||||||
args = _args;
|
this.mArgs = mArgs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +71,7 @@ public class TabsAdapter extends FragmentStatePagerAdapter implements ActionBar.
|
|||||||
@Override
|
@Override
|
||||||
public Fragment getItem(int position) {
|
public Fragment getItem(int position) {
|
||||||
TabInfo info = mTabs.get(position);
|
TabInfo info = mTabs.get(position);
|
||||||
return Fragment.instantiate(mContext, info.clss.getName(), info.args);
|
return Fragment.instantiate(mContext, info.mClss.getName(), info.mArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||||
|
@ -17,13 +17,14 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.util;
|
package org.sufficientlysecure.keychain.util;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.app.Activity;
|
||||||
import org.spongycastle.bcpg.HashAlgorithmTags;
|
import org.spongycastle.bcpg.HashAlgorithmTags;
|
||||||
import org.spongycastle.openpgp.PGPEncryptedData;
|
import org.spongycastle.openpgp.PGPEncryptedData;
|
||||||
import org.sufficientlysecure.keychain.Id;
|
import org.sufficientlysecure.keychain.Id;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.app.Activity;
|
import java.util.HashMap;
|
||||||
|
|
||||||
@SuppressLint("UseSparseArrays")
|
@SuppressLint("UseSparseArrays")
|
||||||
public class AlgorithmNames {
|
public class AlgorithmNames {
|
||||||
|
@ -39,7 +39,7 @@ public class Choice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return mName;
|
return mName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,25 +85,25 @@ public class HkpKeyServer extends KeyServer {
|
|||||||
public static Pattern USER_ID_LINE = Pattern.compile("^ +(.+)$", Pattern.MULTILINE
|
public static Pattern USER_ID_LINE = Pattern.compile("^ +(.+)$", Pattern.MULTILINE
|
||||||
| Pattern.CASE_INSENSITIVE);
|
| Pattern.CASE_INSENSITIVE);
|
||||||
|
|
||||||
private static final short PORT_DEFAULT = 11371;
|
private static final short PORT_DEFAULT = 11371;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param hostAndPort may be just "<code>hostname</code>" (eg. "<code>pool.sks-keyservers.net</code>"), then it will
|
* @param hostAndPort may be just "<code>hostname</code>" (eg. "<code>pool.sks-keyservers.net</code>"), then it will
|
||||||
* connect using {@link #PORT_DEFAULT}. However, port may be specified after colon
|
* connect using {@link #PORT_DEFAULT}. However, port may be specified after colon
|
||||||
* ("<code>hostname:port</code>", eg. "<code>p80.pool.sks-keyservers.net:80</code>").
|
* ("<code>hostname:port</code>", eg. "<code>p80.pool.sks-keyservers.net:80</code>").
|
||||||
*/
|
*/
|
||||||
public HkpKeyServer(String hostAndPort) {
|
public HkpKeyServer(String hostAndPort) {
|
||||||
String host = hostAndPort;
|
String host = hostAndPort;
|
||||||
short port = PORT_DEFAULT;
|
short port = PORT_DEFAULT;
|
||||||
final int colonPosition = hostAndPort.lastIndexOf(':');
|
final int colonPosition = hostAndPort.lastIndexOf(':');
|
||||||
if (colonPosition > 0) {
|
if (colonPosition > 0) {
|
||||||
host = hostAndPort.substring(0, colonPosition);
|
host = hostAndPort.substring(0, colonPosition);
|
||||||
final String portStr = hostAndPort.substring(colonPosition + 1);
|
final String portStr = hostAndPort.substring(colonPosition + 1);
|
||||||
port = Short.decode(portStr);
|
port = Short.decode(portStr);
|
||||||
}
|
}
|
||||||
mHost = host;
|
mHost = host;
|
||||||
mPort = port;
|
mPort = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HkpKeyServer(String host, short port) {
|
public HkpKeyServer(String host, short port) {
|
||||||
mHost = host;
|
mHost = host;
|
||||||
|
@ -18,7 +18,6 @@ package org.sufficientlysecure.keychain.util;
|
|||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
|
||||||
import com.google.zxing.integration.android.IntentIntegrator;
|
import com.google.zxing.integration.android.IntentIntegrator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,20 +27,19 @@ import com.google.zxing.integration.android.IntentIntegrator;
|
|||||||
*/
|
*/
|
||||||
public final class IntentIntegratorSupportV4 extends IntentIntegrator {
|
public final class IntentIntegratorSupportV4 extends IntentIntegrator {
|
||||||
|
|
||||||
private final Fragment fragment;
|
private final Fragment mFragment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param fragment
|
* @param fragment Fragment to handle activity response.
|
||||||
* Fragment to handle activity response.
|
|
||||||
*/
|
*/
|
||||||
public IntentIntegratorSupportV4(Fragment fragment) {
|
public IntentIntegratorSupportV4(Fragment fragment) {
|
||||||
super(fragment.getActivity());
|
super(fragment.getActivity());
|
||||||
this.fragment = fragment;
|
this.mFragment = fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void startActivityForResult(Intent intent, int code) {
|
protected void startActivityForResult(Intent intent, int code) {
|
||||||
fragment.startActivityForResult(intent, code);
|
mFragment.startActivityForResult(intent, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,12 +18,12 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.util;
|
package org.sufficientlysecure.keychain.util;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry;
|
import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class KeyServer {
|
public abstract class KeyServer {
|
||||||
static public class QueryException extends Exception {
|
public static class QueryException extends Exception {
|
||||||
private static final long serialVersionUID = 2703768928624654512L;
|
private static final long serialVersionUID = 2703768928624654512L;
|
||||||
|
|
||||||
public QueryException(String message) {
|
public QueryException(String message) {
|
||||||
@ -31,15 +31,15 @@ public abstract class KeyServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static public class TooManyResponses extends Exception {
|
public static class TooManyResponses extends Exception {
|
||||||
private static final long serialVersionUID = 2703768928624654513L;
|
private static final long serialVersionUID = 2703768928624654513L;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public class InsufficientQuery extends Exception {
|
public static class InsufficientQuery extends Exception {
|
||||||
private static final long serialVersionUID = 2703768928624654514L;
|
private static final long serialVersionUID = 2703768928624654514L;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public class AddKeyException extends Exception {
|
public static class AddKeyException extends Exception {
|
||||||
private static final long serialVersionUID = -507574859137295530L;
|
private static final long serialVersionUID = -507574859137295530L;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* 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.sufficientlysecure.keychain.util;
|
package org.sufficientlysecure.keychain.util;
|
||||||
|
|
||||||
public interface KeychainServiceListener {
|
public interface KeychainServiceListener {
|
||||||
|
@ -21,7 +21,6 @@ import org.sufficientlysecure.keychain.Constants;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Wraps Android Logging to enable or disable debug output using Constants
|
* Wraps Android Logging to enable or disable debug output using Constants
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public final class Log {
|
public final class Log {
|
||||||
|
|
||||||
|
@ -14,48 +14,36 @@ import android.os.Build;
|
|||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.*;
|
||||||
import java.io.DataInputStream;
|
import java.security.*;
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
|
||||||
import java.security.Provider;
|
|
||||||
import java.security.SecureRandom;
|
|
||||||
import java.security.SecureRandomSpi;
|
|
||||||
import java.security.Security;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fixes for the output of the default PRNG having low entropy.
|
* Fixes for the output of the default PRNG having low entropy.
|
||||||
*
|
* <p/>
|
||||||
* The fixes need to be applied via {@link #apply()} before any use of Java Cryptography
|
* The fixes need to be applied via {@link #apply()} before any use of Java Cryptography
|
||||||
* Architecture primitives. A good place to invoke them is in the application's {@code onCreate}.
|
* Architecture primitives. A good place to invoke them is in the application's {@code onCreate}.
|
||||||
*
|
* <p/>
|
||||||
* copied from http://android-developers.blogspot.de/2013/08/some-securerandom-thoughts.html
|
* copied from http://android-developers.blogspot.de/2013/08/some-securerandom-thoughts.html
|
||||||
*
|
* <p/>
|
||||||
*
|
* <p/>
|
||||||
* More information on these Android bugs:
|
* More information on these Android bugs:
|
||||||
* http://blog.k3170makan.com/2013/08/more-details-on-android-jca-prng-flaw.html
|
* http://blog.k3170makan.com/2013/08/more-details-on-android-jca-prng-flaw.html
|
||||||
* Paper: "Randomly failed! Weaknesses in Java Pseudo Random Number Generators (PRNGs)"
|
* Paper: "Randomly failed! Weaknesses in Java Pseudo Random Number Generators (PRNGs)"
|
||||||
*
|
* <p/>
|
||||||
*
|
* <p/>
|
||||||
* Sep 15, 2013:
|
* Sep 15, 2013:
|
||||||
* On some devices /dev/urandom is non-writable!
|
* On some devices /dev/urandom is non-writable!
|
||||||
* No need to seed /dev/urandom. urandom should have enough seeds from the OS and kernel.
|
* No need to seed /dev/urandom. urandom should have enough seeds from the OS and kernel.
|
||||||
* Only OpenSSL seeds are broken. See http://emboss.github.io/blog/2013/08/21/openssl-prng-is-not-really-fork-safe
|
* Only OpenSSL seeds are broken. See http://emboss.github.io/blog/2013/08/21/openssl-prng-is-not-really-fork-safe
|
||||||
*
|
* <p/>
|
||||||
* see also:
|
* see also:
|
||||||
* https://github.com/k9mail/k-9/commit/dda8f64276d4d29c43f86237cd77819c28f22f21
|
* https://github.com/k9mail/k-9/commit/dda8f64276d4d29c43f86237cd77819c28f22f21
|
||||||
* In addition to a couple of custom ROMs linking /dev/urandom to a non-writable
|
* In addition to a couple of custom ROMs linking /dev/urandom to a non-writable
|
||||||
* random version, now Samsung's SELinux policy also prevents apps from opening
|
* random version, now Samsung's SELinux policy also prevents apps from opening
|
||||||
* /dev/urandom for writing. Since we shouldn't need to write to /dev/urandom anyway
|
* /dev/urandom for writing. Since we shouldn't need to write to /dev/urandom anyway
|
||||||
* we now simply don't.
|
* we now simply don't.
|
||||||
*
|
* <p/>
|
||||||
*
|
* <p/>
|
||||||
* Sep 17, 2013:
|
* Sep 17, 2013:
|
||||||
* Updated from official blogpost:
|
* Updated from official blogpost:
|
||||||
* Update: the original code sample below crashed on a small fraction of Android
|
* Update: the original code sample below crashed on a small fraction of Android
|
||||||
@ -66,10 +54,13 @@ public final class PRNGFixes {
|
|||||||
private static final int VERSION_CODE_JELLY_BEAN = 16;
|
private static final int VERSION_CODE_JELLY_BEAN = 16;
|
||||||
private static final int VERSION_CODE_JELLY_BEAN_MR2 = 18;
|
private static final int VERSION_CODE_JELLY_BEAN_MR2 = 18;
|
||||||
private static final byte[] BUILD_FINGERPRINT_AND_DEVICE_SERIAL =
|
private static final byte[] BUILD_FINGERPRINT_AND_DEVICE_SERIAL =
|
||||||
getBuildFingerprintAndDeviceSerial();
|
getBuildFingerprintAndDeviceSerial();
|
||||||
|
|
||||||
/** Hidden constructor to prevent instantiation. */
|
/**
|
||||||
private PRNGFixes() {}
|
* Hidden constructor to prevent instantiation.
|
||||||
|
*/
|
||||||
|
private PRNGFixes() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies all fixes.
|
* Applies all fixes.
|
||||||
@ -136,7 +127,7 @@ public final class PRNGFixes {
|
|||||||
if ((secureRandomProviders == null)
|
if ((secureRandomProviders == null)
|
||||||
|| (secureRandomProviders.length < 1)
|
|| (secureRandomProviders.length < 1)
|
||||||
|| (!LinuxPRNGSecureRandomProvider.class.equals(
|
|| (!LinuxPRNGSecureRandomProvider.class.equals(
|
||||||
secureRandomProviders[0].getClass()))) {
|
secureRandomProviders[0].getClass()))) {
|
||||||
Security.insertProviderAt(new LinuxPRNGSecureRandomProvider(), 1);
|
Security.insertProviderAt(new LinuxPRNGSecureRandomProvider(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +152,7 @@ public final class PRNGFixes {
|
|||||||
rng2.getProvider().getClass())) {
|
rng2.getProvider().getClass())) {
|
||||||
throw new SecurityException(
|
throw new SecurityException(
|
||||||
"SecureRandom.getInstance(\"SHA1PRNG\") backed by wrong"
|
"SecureRandom.getInstance(\"SHA1PRNG\") backed by wrong"
|
||||||
+ " Provider: " + rng2.getProvider().getClass());
|
+ " Provider: " + rng2.getProvider().getClass());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +166,7 @@ public final class PRNGFixes {
|
|||||||
super("LinuxPRNG",
|
super("LinuxPRNG",
|
||||||
1.0,
|
1.0,
|
||||||
"A Linux-specific random number provider that uses"
|
"A Linux-specific random number provider that uses"
|
||||||
+ " /dev/urandom");
|
+ " /dev/urandom");
|
||||||
// Although /dev/urandom is not a SHA-1 PRNG, some apps
|
// Although /dev/urandom is not a SHA-1 PRNG, some apps
|
||||||
// explicitly request a SHA1PRNG SecureRandom and we thus need to
|
// explicitly request a SHA1PRNG SecureRandom and we thus need to
|
||||||
// prevent them from getting the default implementation whose output
|
// prevent them from getting the default implementation whose output
|
||||||
|
@ -17,11 +17,7 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.util;
|
package org.sufficientlysecure.keychain.util;
|
||||||
|
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.*;
|
||||||
import java.util.concurrent.RejectedExecutionHandler;
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.concurrent.locks.Condition;
|
import java.util.concurrent.locks.Condition;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
@ -32,59 +28,63 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||||||
public class PausableThreadPoolExecutor extends ThreadPoolExecutor {
|
public class PausableThreadPoolExecutor extends ThreadPoolExecutor {
|
||||||
|
|
||||||
public PausableThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime,
|
public PausableThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime,
|
||||||
TimeUnit unit, BlockingQueue<Runnable> workQueue, RejectedExecutionHandler handler) {
|
TimeUnit unit, BlockingQueue<Runnable> workQueue,
|
||||||
|
RejectedExecutionHandler handler) {
|
||||||
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, handler);
|
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PausableThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime,
|
public PausableThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime,
|
||||||
TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory,
|
TimeUnit unit, BlockingQueue<Runnable> workQueue,
|
||||||
RejectedExecutionHandler handler) {
|
ThreadFactory threadFactory,
|
||||||
|
RejectedExecutionHandler handler) {
|
||||||
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory, handler);
|
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PausableThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime,
|
public PausableThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime,
|
||||||
TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory) {
|
TimeUnit unit, BlockingQueue<Runnable> workQueue,
|
||||||
|
ThreadFactory threadFactory) {
|
||||||
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory);
|
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PausableThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime,
|
public PausableThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime,
|
||||||
TimeUnit unit, BlockingQueue<Runnable> workQueue) {
|
TimeUnit unit, BlockingQueue<Runnable> workQueue) {
|
||||||
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue);
|
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isPaused;
|
private boolean mIsPaused;
|
||||||
private ReentrantLock pauseLock = new ReentrantLock();
|
private ReentrantLock mPauseLock = new ReentrantLock();
|
||||||
private Condition unpaused = pauseLock.newCondition();
|
private Condition mUnPaused = mPauseLock.newCondition();
|
||||||
|
|
||||||
protected void beforeExecute(Thread t, Runnable r) {
|
protected void beforeExecute(Thread t, Runnable r) {
|
||||||
super.beforeExecute(t, r);
|
super.beforeExecute(t, r);
|
||||||
pauseLock.lock();
|
mPauseLock.lock();
|
||||||
try {
|
try {
|
||||||
while (isPaused)
|
while (mIsPaused) {
|
||||||
unpaused.await();
|
mUnPaused.await();
|
||||||
|
}
|
||||||
} catch (InterruptedException ie) {
|
} catch (InterruptedException ie) {
|
||||||
t.interrupt();
|
t.interrupt();
|
||||||
} finally {
|
} finally {
|
||||||
pauseLock.unlock();
|
mPauseLock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pause() {
|
public void pause() {
|
||||||
pauseLock.lock();
|
mPauseLock.lock();
|
||||||
try {
|
try {
|
||||||
isPaused = true;
|
mIsPaused = true;
|
||||||
} finally {
|
} finally {
|
||||||
pauseLock.unlock();
|
mPauseLock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resume() {
|
public void resume() {
|
||||||
pauseLock.lock();
|
mPauseLock.lock();
|
||||||
try {
|
try {
|
||||||
isPaused = false;
|
mIsPaused = false;
|
||||||
unpaused.signalAll();
|
mUnPaused.signalAll();
|
||||||
} finally {
|
} finally {
|
||||||
pauseLock.unlock();
|
mPauseLock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,147 +25,147 @@ public final class Primes {
|
|||||||
// taken from http://www.ietf.org/rfc/rfc3526.txt
|
// taken from http://www.ietf.org/rfc/rfc3526.txt
|
||||||
public static final String P1536 =
|
public static final String P1536 =
|
||||||
"FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1" +
|
"FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1" +
|
||||||
"29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD" +
|
"29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD" +
|
||||||
"EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245" +
|
"EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245" +
|
||||||
"E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED" +
|
"E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED" +
|
||||||
"EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D" +
|
"EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D" +
|
||||||
"C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F" +
|
"C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F" +
|
||||||
"83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D" +
|
"83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D" +
|
||||||
"670C354E 4ABC9804 F1746C08 CA237327 FFFFFFFF FFFFFFFF";
|
"670C354E 4ABC9804 F1746C08 CA237327 FFFFFFFF FFFFFFFF";
|
||||||
|
|
||||||
public static final String P2048 =
|
public static final String P2048 =
|
||||||
"FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1" +
|
"FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1" +
|
||||||
"29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD" +
|
"29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD" +
|
||||||
"EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245" +
|
"EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245" +
|
||||||
"E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED" +
|
"E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED" +
|
||||||
"EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D" +
|
"EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D" +
|
||||||
"C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F" +
|
"C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F" +
|
||||||
"83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D" +
|
"83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D" +
|
||||||
"670C354E 4ABC9804 F1746C08 CA18217C 32905E46 2E36CE3B" +
|
"670C354E 4ABC9804 F1746C08 CA18217C 32905E46 2E36CE3B" +
|
||||||
"E39E772C 180E8603 9B2783A2 EC07A28F B5C55DF0 6F4C52C9" +
|
"E39E772C 180E8603 9B2783A2 EC07A28F B5C55DF0 6F4C52C9" +
|
||||||
"DE2BCBF6 95581718 3995497C EA956AE5 15D22618 98FA0510" +
|
"DE2BCBF6 95581718 3995497C EA956AE5 15D22618 98FA0510" +
|
||||||
"15728E5A 8AACAA68 FFFFFFFF FFFFFFFF";
|
"15728E5A 8AACAA68 FFFFFFFF FFFFFFFF";
|
||||||
|
|
||||||
public static final String P3072 =
|
public static final String P3072 =
|
||||||
"FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1" +
|
"FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1" +
|
||||||
"29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD" +
|
"29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD" +
|
||||||
"EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245" +
|
"EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245" +
|
||||||
"E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED" +
|
"E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED" +
|
||||||
"EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D" +
|
"EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D" +
|
||||||
"C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F" +
|
"C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F" +
|
||||||
"83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D" +
|
"83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D" +
|
||||||
"670C354E 4ABC9804 F1746C08 CA18217C 32905E46 2E36CE3B" +
|
"670C354E 4ABC9804 F1746C08 CA18217C 32905E46 2E36CE3B" +
|
||||||
"E39E772C 180E8603 9B2783A2 EC07A28F B5C55DF0 6F4C52C9" +
|
"E39E772C 180E8603 9B2783A2 EC07A28F B5C55DF0 6F4C52C9" +
|
||||||
"DE2BCBF6 95581718 3995497C EA956AE5 15D22618 98FA0510" +
|
"DE2BCBF6 95581718 3995497C EA956AE5 15D22618 98FA0510" +
|
||||||
"15728E5A 8AAAC42D AD33170D 04507A33 A85521AB DF1CBA64" +
|
"15728E5A 8AAAC42D AD33170D 04507A33 A85521AB DF1CBA64" +
|
||||||
"ECFB8504 58DBEF0A 8AEA7157 5D060C7D B3970F85 A6E1E4C7" +
|
"ECFB8504 58DBEF0A 8AEA7157 5D060C7D B3970F85 A6E1E4C7" +
|
||||||
"ABF5AE8C DB0933D7 1E8C94E0 4A25619D CEE3D226 1AD2EE6B" +
|
"ABF5AE8C DB0933D7 1E8C94E0 4A25619D CEE3D226 1AD2EE6B" +
|
||||||
"F12FFA06 D98A0864 D8760273 3EC86A64 521F2B18 177B200C" +
|
"F12FFA06 D98A0864 D8760273 3EC86A64 521F2B18 177B200C" +
|
||||||
"BBE11757 7A615D6C 770988C0 BAD946E2 08E24FA0 74E5AB31" +
|
"BBE11757 7A615D6C 770988C0 BAD946E2 08E24FA0 74E5AB31" +
|
||||||
"43DB5BFC E0FD108E 4B82D120 A93AD2CA FFFFFFFF FFFFFFFF";
|
"43DB5BFC E0FD108E 4B82D120 A93AD2CA FFFFFFFF FFFFFFFF";
|
||||||
|
|
||||||
public static final String P4096 =
|
public static final String P4096 =
|
||||||
"FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1" +
|
"FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1" +
|
||||||
"29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD" +
|
"29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD" +
|
||||||
"EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245" +
|
"EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245" +
|
||||||
"E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED" +
|
"E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED" +
|
||||||
"EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D" +
|
"EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D" +
|
||||||
"C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F" +
|
"C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F" +
|
||||||
"83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D" +
|
"83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D" +
|
||||||
"670C354E 4ABC9804 F1746C08 CA18217C 32905E46 2E36CE3B" +
|
"670C354E 4ABC9804 F1746C08 CA18217C 32905E46 2E36CE3B" +
|
||||||
"E39E772C 180E8603 9B2783A2 EC07A28F B5C55DF0 6F4C52C9" +
|
"E39E772C 180E8603 9B2783A2 EC07A28F B5C55DF0 6F4C52C9" +
|
||||||
"DE2BCBF6 95581718 3995497C EA956AE5 15D22618 98FA0510" +
|
"DE2BCBF6 95581718 3995497C EA956AE5 15D22618 98FA0510" +
|
||||||
"15728E5A 8AAAC42D AD33170D 04507A33 A85521AB DF1CBA64" +
|
"15728E5A 8AAAC42D AD33170D 04507A33 A85521AB DF1CBA64" +
|
||||||
"ECFB8504 58DBEF0A 8AEA7157 5D060C7D B3970F85 A6E1E4C7" +
|
"ECFB8504 58DBEF0A 8AEA7157 5D060C7D B3970F85 A6E1E4C7" +
|
||||||
"ABF5AE8C DB0933D7 1E8C94E0 4A25619D CEE3D226 1AD2EE6B" +
|
"ABF5AE8C DB0933D7 1E8C94E0 4A25619D CEE3D226 1AD2EE6B" +
|
||||||
"F12FFA06 D98A0864 D8760273 3EC86A64 521F2B18 177B200C" +
|
"F12FFA06 D98A0864 D8760273 3EC86A64 521F2B18 177B200C" +
|
||||||
"BBE11757 7A615D6C 770988C0 BAD946E2 08E24FA0 74E5AB31" +
|
"BBE11757 7A615D6C 770988C0 BAD946E2 08E24FA0 74E5AB31" +
|
||||||
"43DB5BFC E0FD108E 4B82D120 A9210801 1A723C12 A787E6D7" +
|
"43DB5BFC E0FD108E 4B82D120 A9210801 1A723C12 A787E6D7" +
|
||||||
"88719A10 BDBA5B26 99C32718 6AF4E23C 1A946834 B6150BDA" +
|
"88719A10 BDBA5B26 99C32718 6AF4E23C 1A946834 B6150BDA" +
|
||||||
"2583E9CA 2AD44CE8 DBBBC2DB 04DE8EF9 2E8EFC14 1FBECAA6" +
|
"2583E9CA 2AD44CE8 DBBBC2DB 04DE8EF9 2E8EFC14 1FBECAA6" +
|
||||||
"287C5947 4E6BC05D 99B2964F A090C3A2 233BA186 515BE7ED" +
|
"287C5947 4E6BC05D 99B2964F A090C3A2 233BA186 515BE7ED" +
|
||||||
"1F612970 CEE2D7AF B81BDD76 2170481C D0069127 D5B05AA9" +
|
"1F612970 CEE2D7AF B81BDD76 2170481C D0069127 D5B05AA9" +
|
||||||
"93B4EA98 8D8FDDC1 86FFB7DC 90A6C08F 4DF435C9 34063199" +
|
"93B4EA98 8D8FDDC1 86FFB7DC 90A6C08F 4DF435C9 34063199" +
|
||||||
"FFFFFFFF FFFFFFFF";
|
"FFFFFFFF FFFFFFFF";
|
||||||
|
|
||||||
public static final String P6144 =
|
public static final String P6144 =
|
||||||
"FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1" +
|
"FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1" +
|
||||||
"29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD" +
|
"29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD" +
|
||||||
"EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245" +
|
"EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245" +
|
||||||
"E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED" +
|
"E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED" +
|
||||||
"EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D" +
|
"EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D" +
|
||||||
"C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F" +
|
"C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F" +
|
||||||
"83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D" +
|
"83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D" +
|
||||||
"670C354E 4ABC9804 F1746C08 CA18217C 32905E46 2E36CE3B" +
|
"670C354E 4ABC9804 F1746C08 CA18217C 32905E46 2E36CE3B" +
|
||||||
"E39E772C 180E8603 9B2783A2 EC07A28F B5C55DF0 6F4C52C9" +
|
"E39E772C 180E8603 9B2783A2 EC07A28F B5C55DF0 6F4C52C9" +
|
||||||
"DE2BCBF6 95581718 3995497C EA956AE5 15D22618 98FA0510" +
|
"DE2BCBF6 95581718 3995497C EA956AE5 15D22618 98FA0510" +
|
||||||
"15728E5A 8AAAC42D AD33170D 04507A33 A85521AB DF1CBA64" +
|
"15728E5A 8AAAC42D AD33170D 04507A33 A85521AB DF1CBA64" +
|
||||||
"ECFB8504 58DBEF0A 8AEA7157 5D060C7D B3970F85 A6E1E4C7" +
|
"ECFB8504 58DBEF0A 8AEA7157 5D060C7D B3970F85 A6E1E4C7" +
|
||||||
"ABF5AE8C DB0933D7 1E8C94E0 4A25619D CEE3D226 1AD2EE6B" +
|
"ABF5AE8C DB0933D7 1E8C94E0 4A25619D CEE3D226 1AD2EE6B" +
|
||||||
"F12FFA06 D98A0864 D8760273 3EC86A64 521F2B18 177B200C" +
|
"F12FFA06 D98A0864 D8760273 3EC86A64 521F2B18 177B200C" +
|
||||||
"BBE11757 7A615D6C 770988C0 BAD946E2 08E24FA0 74E5AB31" +
|
"BBE11757 7A615D6C 770988C0 BAD946E2 08E24FA0 74E5AB31" +
|
||||||
"43DB5BFC E0FD108E 4B82D120 A9210801 1A723C12 A787E6D7" +
|
"43DB5BFC E0FD108E 4B82D120 A9210801 1A723C12 A787E6D7" +
|
||||||
"88719A10 BDBA5B26 99C32718 6AF4E23C 1A946834 B6150BDA" +
|
"88719A10 BDBA5B26 99C32718 6AF4E23C 1A946834 B6150BDA" +
|
||||||
"2583E9CA 2AD44CE8 DBBBC2DB 04DE8EF9 2E8EFC14 1FBECAA6" +
|
"2583E9CA 2AD44CE8 DBBBC2DB 04DE8EF9 2E8EFC14 1FBECAA6" +
|
||||||
"287C5947 4E6BC05D 99B2964F A090C3A2 233BA186 515BE7ED" +
|
"287C5947 4E6BC05D 99B2964F A090C3A2 233BA186 515BE7ED" +
|
||||||
"1F612970 CEE2D7AF B81BDD76 2170481C D0069127 D5B05AA9" +
|
"1F612970 CEE2D7AF B81BDD76 2170481C D0069127 D5B05AA9" +
|
||||||
"93B4EA98 8D8FDDC1 86FFB7DC 90A6C08F 4DF435C9 34028492" +
|
"93B4EA98 8D8FDDC1 86FFB7DC 90A6C08F 4DF435C9 34028492" +
|
||||||
"36C3FAB4 D27C7026 C1D4DCB2 602646DE C9751E76 3DBA37BD" +
|
"36C3FAB4 D27C7026 C1D4DCB2 602646DE C9751E76 3DBA37BD" +
|
||||||
"F8FF9406 AD9E530E E5DB382F 413001AE B06A53ED 9027D831" +
|
"F8FF9406 AD9E530E E5DB382F 413001AE B06A53ED 9027D831" +
|
||||||
"179727B0 865A8918 DA3EDBEB CF9B14ED 44CE6CBA CED4BB1B" +
|
"179727B0 865A8918 DA3EDBEB CF9B14ED 44CE6CBA CED4BB1B" +
|
||||||
"DB7F1447 E6CC254B 33205151 2BD7AF42 6FB8F401 378CD2BF" +
|
"DB7F1447 E6CC254B 33205151 2BD7AF42 6FB8F401 378CD2BF" +
|
||||||
"5983CA01 C64B92EC F032EA15 D1721D03 F482D7CE 6E74FEF6" +
|
"5983CA01 C64B92EC F032EA15 D1721D03 F482D7CE 6E74FEF6" +
|
||||||
"D55E702F 46980C82 B5A84031 900B1C9E 59E7C97F BEC7E8F3" +
|
"D55E702F 46980C82 B5A84031 900B1C9E 59E7C97F BEC7E8F3" +
|
||||||
"23A97A7E 36CC88BE 0F1D45B7 FF585AC5 4BD407B2 2B4154AA" +
|
"23A97A7E 36CC88BE 0F1D45B7 FF585AC5 4BD407B2 2B4154AA" +
|
||||||
"CC8F6D7E BF48E1D8 14CC5ED2 0F8037E0 A79715EE F29BE328" +
|
"CC8F6D7E BF48E1D8 14CC5ED2 0F8037E0 A79715EE F29BE328" +
|
||||||
"06A1D58B B7C5DA76 F550AA3D 8A1FBFF0 EB19CCB1 A313D55C" +
|
"06A1D58B B7C5DA76 F550AA3D 8A1FBFF0 EB19CCB1 A313D55C" +
|
||||||
"DA56C9EC 2EF29632 387FE8D7 6E3C0468 043E8F66 3F4860EE" +
|
"DA56C9EC 2EF29632 387FE8D7 6E3C0468 043E8F66 3F4860EE" +
|
||||||
"12BF2D5B 0B7474D6 E694F91E 6DCC4024 FFFFFFFF FFFFFFFF";
|
"12BF2D5B 0B7474D6 E694F91E 6DCC4024 FFFFFFFF FFFFFFFF";
|
||||||
|
|
||||||
public static final String P8192 =
|
public static final String P8192 =
|
||||||
"FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1" +
|
"FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1" +
|
||||||
"29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD" +
|
"29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD" +
|
||||||
"EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245" +
|
"EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245" +
|
||||||
"E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED" +
|
"E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED" +
|
||||||
"EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D" +
|
"EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D" +
|
||||||
"C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F" +
|
"C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F" +
|
||||||
"83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D" +
|
"83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D" +
|
||||||
"670C354E 4ABC9804 F1746C08 CA18217C 32905E46 2E36CE3B" +
|
"670C354E 4ABC9804 F1746C08 CA18217C 32905E46 2E36CE3B" +
|
||||||
"E39E772C 180E8603 9B2783A2 EC07A28F B5C55DF0 6F4C52C9" +
|
"E39E772C 180E8603 9B2783A2 EC07A28F B5C55DF0 6F4C52C9" +
|
||||||
"DE2BCBF6 95581718 3995497C EA956AE5 15D22618 98FA0510" +
|
"DE2BCBF6 95581718 3995497C EA956AE5 15D22618 98FA0510" +
|
||||||
"15728E5A 8AAAC42D AD33170D 04507A33 A85521AB DF1CBA64" +
|
"15728E5A 8AAAC42D AD33170D 04507A33 A85521AB DF1CBA64" +
|
||||||
"ECFB8504 58DBEF0A 8AEA7157 5D060C7D B3970F85 A6E1E4C7" +
|
"ECFB8504 58DBEF0A 8AEA7157 5D060C7D B3970F85 A6E1E4C7" +
|
||||||
"ABF5AE8C DB0933D7 1E8C94E0 4A25619D CEE3D226 1AD2EE6B" +
|
"ABF5AE8C DB0933D7 1E8C94E0 4A25619D CEE3D226 1AD2EE6B" +
|
||||||
"F12FFA06 D98A0864 D8760273 3EC86A64 521F2B18 177B200C" +
|
"F12FFA06 D98A0864 D8760273 3EC86A64 521F2B18 177B200C" +
|
||||||
"BBE11757 7A615D6C 770988C0 BAD946E2 08E24FA0 74E5AB31" +
|
"BBE11757 7A615D6C 770988C0 BAD946E2 08E24FA0 74E5AB31" +
|
||||||
"43DB5BFC E0FD108E 4B82D120 A9210801 1A723C12 A787E6D7" +
|
"43DB5BFC E0FD108E 4B82D120 A9210801 1A723C12 A787E6D7" +
|
||||||
"88719A10 BDBA5B26 99C32718 6AF4E23C 1A946834 B6150BDA" +
|
"88719A10 BDBA5B26 99C32718 6AF4E23C 1A946834 B6150BDA" +
|
||||||
"2583E9CA 2AD44CE8 DBBBC2DB 04DE8EF9 2E8EFC14 1FBECAA6" +
|
"2583E9CA 2AD44CE8 DBBBC2DB 04DE8EF9 2E8EFC14 1FBECAA6" +
|
||||||
"287C5947 4E6BC05D 99B2964F A090C3A2 233BA186 515BE7ED" +
|
"287C5947 4E6BC05D 99B2964F A090C3A2 233BA186 515BE7ED" +
|
||||||
"1F612970 CEE2D7AF B81BDD76 2170481C D0069127 D5B05AA9" +
|
"1F612970 CEE2D7AF B81BDD76 2170481C D0069127 D5B05AA9" +
|
||||||
"93B4EA98 8D8FDDC1 86FFB7DC 90A6C08F 4DF435C9 34028492" +
|
"93B4EA98 8D8FDDC1 86FFB7DC 90A6C08F 4DF435C9 34028492" +
|
||||||
"36C3FAB4 D27C7026 C1D4DCB2 602646DE C9751E76 3DBA37BD" +
|
"36C3FAB4 D27C7026 C1D4DCB2 602646DE C9751E76 3DBA37BD" +
|
||||||
"F8FF9406 AD9E530E E5DB382F 413001AE B06A53ED 9027D831" +
|
"F8FF9406 AD9E530E E5DB382F 413001AE B06A53ED 9027D831" +
|
||||||
"179727B0 865A8918 DA3EDBEB CF9B14ED 44CE6CBA CED4BB1B" +
|
"179727B0 865A8918 DA3EDBEB CF9B14ED 44CE6CBA CED4BB1B" +
|
||||||
"DB7F1447 E6CC254B 33205151 2BD7AF42 6FB8F401 378CD2BF" +
|
"DB7F1447 E6CC254B 33205151 2BD7AF42 6FB8F401 378CD2BF" +
|
||||||
"5983CA01 C64B92EC F032EA15 D1721D03 F482D7CE 6E74FEF6" +
|
"5983CA01 C64B92EC F032EA15 D1721D03 F482D7CE 6E74FEF6" +
|
||||||
"D55E702F 46980C82 B5A84031 900B1C9E 59E7C97F BEC7E8F3" +
|
"D55E702F 46980C82 B5A84031 900B1C9E 59E7C97F BEC7E8F3" +
|
||||||
"23A97A7E 36CC88BE 0F1D45B7 FF585AC5 4BD407B2 2B4154AA" +
|
"23A97A7E 36CC88BE 0F1D45B7 FF585AC5 4BD407B2 2B4154AA" +
|
||||||
"CC8F6D7E BF48E1D8 14CC5ED2 0F8037E0 A79715EE F29BE328" +
|
"CC8F6D7E BF48E1D8 14CC5ED2 0F8037E0 A79715EE F29BE328" +
|
||||||
"06A1D58B B7C5DA76 F550AA3D 8A1FBFF0 EB19CCB1 A313D55C" +
|
"06A1D58B B7C5DA76 F550AA3D 8A1FBFF0 EB19CCB1 A313D55C" +
|
||||||
"DA56C9EC 2EF29632 387FE8D7 6E3C0468 043E8F66 3F4860EE" +
|
"DA56C9EC 2EF29632 387FE8D7 6E3C0468 043E8F66 3F4860EE" +
|
||||||
"12BF2D5B 0B7474D6 E694F91E 6DBE1159 74A3926F 12FEE5E4" +
|
"12BF2D5B 0B7474D6 E694F91E 6DBE1159 74A3926F 12FEE5E4" +
|
||||||
"38777CB6 A932DF8C D8BEC4D0 73B931BA 3BC832B6 8D9DD300" +
|
"38777CB6 A932DF8C D8BEC4D0 73B931BA 3BC832B6 8D9DD300" +
|
||||||
"741FA7BF 8AFC47ED 2576F693 6BA42466 3AAB639C 5AE4F568" +
|
"741FA7BF 8AFC47ED 2576F693 6BA42466 3AAB639C 5AE4F568" +
|
||||||
"3423B474 2BF1C978 238F16CB E39D652D E3FDB8BE FC848AD9" +
|
"3423B474 2BF1C978 238F16CB E39D652D E3FDB8BE FC848AD9" +
|
||||||
"22222E04 A4037C07 13EB57A8 1A23F0C7 3473FC64 6CEA306B" +
|
"22222E04 A4037C07 13EB57A8 1A23F0C7 3473FC64 6CEA306B" +
|
||||||
"4BCBC886 2F8385DD FA9D4B7F A2C087E8 79683303 ED5BDD3A" +
|
"4BCBC886 2F8385DD FA9D4B7F A2C087E8 79683303 ED5BDD3A" +
|
||||||
"062B3CF5 B3A278A6 6D2A13F8 3F44F82D DF310EE0 74AB6A36" +
|
"062B3CF5 B3A278A6 6D2A13F8 3F44F82D DF310EE0 74AB6A36" +
|
||||||
"4597E899 A0255DC1 64F31CC5 0846851D F9AB4819 5DED7EA1" +
|
"4597E899 A0255DC1 64F31CC5 0846851D F9AB4819 5DED7EA1" +
|
||||||
"B1D510BD 7EE74D73 FAF36BC3 1ECFA268 359046F4 EB879F92" +
|
"B1D510BD 7EE74D73 FAF36BC3 1ECFA268 359046F4 EB879F92" +
|
||||||
"4009438B 481C6CD7 889A002E D5EE382B C9190DA6 FC026E47" +
|
"4009438B 481C6CD7 889A002E D5EE382B C9190DA6 FC026E47" +
|
||||||
"9558E447 5677E9AA 9E3050E2 765694DF C81F56E8 80B96E71" +
|
"9558E447 5677E9AA 9E3050E2 765694DF C81F56E8 80B96E71" +
|
||||||
"60C980DD 98EDD3DF FFFFFFFF FFFFFFFF";
|
"60C980DD 98EDD3DF FFFFFFFF FFFFFFFF";
|
||||||
|
|
||||||
public static BigInteger getBestPrime(int keySize) {
|
public static BigInteger getBestPrime(int keySize) {
|
||||||
String primeString;
|
String primeString;
|
||||||
|
@ -18,22 +18,20 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.util;
|
package org.sufficientlysecure.keychain.util;
|
||||||
|
|
||||||
import java.util.Hashtable;
|
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
|
||||||
|
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
|
||||||
import com.google.zxing.BarcodeFormat;
|
import com.google.zxing.BarcodeFormat;
|
||||||
import com.google.zxing.EncodeHintType;
|
import com.google.zxing.EncodeHintType;
|
||||||
import com.google.zxing.WriterException;
|
import com.google.zxing.WriterException;
|
||||||
import com.google.zxing.common.BitMatrix;
|
import com.google.zxing.common.BitMatrix;
|
||||||
import com.google.zxing.qrcode.QRCodeWriter;
|
import com.google.zxing.qrcode.QRCodeWriter;
|
||||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||||||
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
|
|
||||||
|
import java.util.Hashtable;
|
||||||
|
|
||||||
public class QrCodeUtils {
|
public class QrCodeUtils {
|
||||||
public final static QRCodeWriter QR_CODE_WRITER = new QRCodeWriter();
|
public static final QRCodeWriter QR_CODE_WRITER = new QRCodeWriter();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate Bitmap with QR Code based on input.
|
* Generate Bitmap with QR Code based on input.
|
||||||
|
Loading…
Reference in New Issue
Block a user