mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-25 08:28:50 -05:00
No bouncy castle objects in key view
This commit is contained in:
parent
5359205b50
commit
c4340b2379
@ -31,6 +31,9 @@ public final class Constants {
|
|||||||
// as defined in http://tools.ietf.org/html/rfc3156, section 7
|
// as defined in http://tools.ietf.org/html/rfc3156, section 7
|
||||||
public static final String NFC_MIME = "application/pgp-keys";
|
public static final String NFC_MIME = "application/pgp-keys";
|
||||||
|
|
||||||
|
// used by QR Codes (Guardian Project, Monkeysphere compatiblity)
|
||||||
|
public static final String FINGERPRINT_SCHEME = "openpgp4fpr";
|
||||||
|
|
||||||
// Not BC due to the use of Spongy Castle for Android
|
// Not BC due to the use of Spongy Castle for Android
|
||||||
public static final String SC = BouncyCastleProvider.PROVIDER_NAME;
|
public static final String SC = BouncyCastleProvider.PROVIDER_NAME;
|
||||||
public static final String BOUNCY_CASTLE_PROVIDER_NAME = SC;
|
public static final String BOUNCY_CASTLE_PROVIDER_NAME = SC;
|
||||||
|
@ -346,7 +346,7 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set result of query to specific columns, don't show blob column for external content provider
|
* Set result of query to specific columns, don't show blob column
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -367,7 +367,7 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set result of query to specific columns, don't show blob column for external content provider
|
* Set result of query to specific columns, don't show blob column
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -388,6 +388,7 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
projectionMap.put(KeysColumns.KEY_RING_ROW_ID, KeysColumns.KEY_RING_ROW_ID);
|
projectionMap.put(KeysColumns.KEY_RING_ROW_ID, KeysColumns.KEY_RING_ROW_ID);
|
||||||
projectionMap.put(KeysColumns.KEY_DATA, KeysColumns.KEY_DATA);
|
projectionMap.put(KeysColumns.KEY_DATA, KeysColumns.KEY_DATA);
|
||||||
projectionMap.put(KeysColumns.RANK, KeysColumns.RANK);
|
projectionMap.put(KeysColumns.RANK, KeysColumns.RANK);
|
||||||
|
projectionMap.put(KeysColumns.FINGERPRINT, KeysColumns.FINGERPRINT);
|
||||||
|
|
||||||
return projectionMap;
|
return projectionMap;
|
||||||
}
|
}
|
||||||
|
@ -488,7 +488,7 @@ public class ProviderHelper {
|
|||||||
String[] projection = new String[]{KeyRings.MASTER_KEY_ID};
|
String[] projection = new String[]{KeyRings.MASTER_KEY_ID};
|
||||||
Cursor cursor = context.getContentResolver().query(queryUri, projection, null, null, null);
|
Cursor cursor = context.getContentResolver().query(queryUri, projection, null, null, null);
|
||||||
|
|
||||||
long masterKeyId = -1;
|
long masterKeyId = 0;
|
||||||
try {
|
try {
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
int masterKeyIdCol = cursor.getColumnIndexOrThrow(KeyRings.MASTER_KEY_ID);
|
int masterKeyIdCol = cursor.getColumnIndexOrThrow(KeyRings.MASTER_KEY_ID);
|
||||||
|
@ -73,8 +73,6 @@ public class ImportKeysActivity extends DrawerActivity implements OnNavigationLi
|
|||||||
// only used by ACTION_IMPORT_KEY_FROM_KEYSERVER
|
// only used by ACTION_IMPORT_KEY_FROM_KEYSERVER
|
||||||
public static final String EXTRA_QUERY = "query";
|
public static final String EXTRA_QUERY = "query";
|
||||||
|
|
||||||
public static final String FINGERPRINT_SCHEME = "openpgp4fpr";
|
|
||||||
|
|
||||||
protected boolean mDeleteAfterImport = false;
|
protected boolean mDeleteAfterImport = false;
|
||||||
|
|
||||||
// view
|
// view
|
||||||
@ -135,7 +133,7 @@ public class ImportKeysActivity extends DrawerActivity implements OnNavigationLi
|
|||||||
/**
|
/**
|
||||||
* Scanning a fingerprint directly with Barcode Scanner
|
* Scanning a fingerprint directly with Barcode Scanner
|
||||||
*/
|
*/
|
||||||
if (scheme != null && scheme.toLowerCase(Locale.ENGLISH).equals(FINGERPRINT_SCHEME)) {
|
if (scheme != null && scheme.toLowerCase(Locale.ENGLISH).equals(Constants.FINGERPRINT_SCHEME)) {
|
||||||
getSupportActionBar().setSelectedNavigationItem(0);
|
getSupportActionBar().setSelectedNavigationItem(0);
|
||||||
loadFragment(ImportKeysQrCodeFragment.class, null, mNavigationStrings[0]);
|
loadFragment(ImportKeysQrCodeFragment.class, null, mNavigationStrings[0]);
|
||||||
loadFromFingerprintUri(dataUri);
|
loadFromFingerprintUri(dataUri);
|
||||||
|
@ -102,7 +102,7 @@ public class ImportKeysQrCodeFragment extends Fragment {
|
|||||||
Log.d(Constants.TAG, "scanResult content: " + scanResult.getContents());
|
Log.d(Constants.TAG, "scanResult content: " + scanResult.getContents());
|
||||||
|
|
||||||
// look if it's fingerprint only
|
// look if it's fingerprint only
|
||||||
if (scanResult.getContents().toLowerCase(Locale.ENGLISH).startsWith(ImportKeysActivity.FINGERPRINT_SCHEME)) {
|
if (scanResult.getContents().toLowerCase(Locale.ENGLISH).startsWith(Constants.FINGERPRINT_SCHEME)) {
|
||||||
importFingerprint(Uri.parse(scanResult.getContents()));
|
importFingerprint(Uri.parse(scanResult.getContents()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,6 @@ package org.sufficientlysecure.keychain.ui;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import org.spongycastle.openpgp.PGPPublicKey;
|
|
||||||
import org.spongycastle.openpgp.PGPPublicKeyRing;
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.Id;
|
import org.sufficientlysecure.keychain.Id;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
@ -198,12 +196,9 @@ public class ViewKeyActivity extends SherlockFragmentActivity implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
// TODO: don't get object here!!! solve this differently!
|
long keyId = ProviderHelper.getMasterKeyId(ViewKeyActivity.this, mDataUri);
|
||||||
PGPPublicKeyRing ring = (PGPPublicKeyRing) ProviderHelper.getPGPKeyRing(
|
|
||||||
ViewKeyActivity.this, mDataUri);
|
|
||||||
PGPPublicKey publicKey = ring.getPublicKey();
|
|
||||||
|
|
||||||
long[] encryptionKeyIds = new long[]{publicKey.getKeyID()};
|
long[] encryptionKeyIds = new long[]{keyId};
|
||||||
Intent intent = new Intent(ViewKeyActivity.this, EncryptActivity.class);
|
Intent intent = new Intent(ViewKeyActivity.this, EncryptActivity.class);
|
||||||
intent.setAction(EncryptActivity.ACTION_ENCRYPT);
|
intent.setAction(EncryptActivity.ACTION_ENCRYPT);
|
||||||
intent.putExtra(EncryptActivity.EXTRA_ENCRYPTION_KEY_IDS, encryptionKeyIds);
|
intent.putExtra(EncryptActivity.EXTRA_ENCRYPTION_KEY_IDS, encryptionKeyIds);
|
||||||
@ -248,7 +243,7 @@ public class ViewKeyActivity extends SherlockFragmentActivity implements
|
|||||||
|
|
||||||
static final String[] KEYS_PROJECTION = new String[]{Keys._ID, Keys.KEY_ID,
|
static final String[] KEYS_PROJECTION = new String[]{Keys._ID, Keys.KEY_ID,
|
||||||
Keys.IS_MASTER_KEY, Keys.ALGORITHM, Keys.KEY_SIZE, Keys.CAN_CERTIFY, Keys.CAN_SIGN,
|
Keys.IS_MASTER_KEY, Keys.ALGORITHM, Keys.KEY_SIZE, Keys.CAN_CERTIFY, Keys.CAN_SIGN,
|
||||||
Keys.CAN_ENCRYPT, Keys.CREATION, Keys.EXPIRY};
|
Keys.CAN_ENCRYPT, Keys.CREATION, Keys.EXPIRY, Keys.FINGERPRINT};
|
||||||
static final String KEYS_SORT_ORDER = Keys.RANK + " ASC";
|
static final String KEYS_SORT_ORDER = Keys.RANK + " ASC";
|
||||||
static final int KEYS_INDEX_ID = 0;
|
static final int KEYS_INDEX_ID = 0;
|
||||||
static final int KEYS_INDEX_KEY_ID = 1;
|
static final int KEYS_INDEX_KEY_ID = 1;
|
||||||
@ -260,6 +255,7 @@ public class ViewKeyActivity extends SherlockFragmentActivity implements
|
|||||||
static final int KEYS_INDEX_CAN_ENCRYPT = 7;
|
static final int KEYS_INDEX_CAN_ENCRYPT = 7;
|
||||||
static final int KEYS_INDEX_CREATION = 8;
|
static final int KEYS_INDEX_CREATION = 8;
|
||||||
static final int KEYS_INDEX_EXPIRY = 9;
|
static final int KEYS_INDEX_EXPIRY = 9;
|
||||||
|
static final int KEYS_INDEX_FINGERPRINT = 10;
|
||||||
|
|
||||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
@ -348,13 +344,15 @@ public class ViewKeyActivity extends SherlockFragmentActivity implements
|
|||||||
data.getInt(KEYS_INDEX_ALGORITHM), data.getInt(KEYS_INDEX_KEY_SIZE));
|
data.getInt(KEYS_INDEX_ALGORITHM), data.getInt(KEYS_INDEX_KEY_SIZE));
|
||||||
mAlgorithm.setText(algorithmStr);
|
mAlgorithm.setText(algorithmStr);
|
||||||
|
|
||||||
// TODO: Can this be done better? fingerprint in db?
|
byte[] fingerprintBlob = data.getBlob(KEYS_INDEX_FINGERPRINT);
|
||||||
String fingerprint = PgpKeyHelper.getFingerPrint(this, keyId);
|
if (fingerprintBlob == null) {
|
||||||
|
// FALLBACK for old databases
|
||||||
|
fingerprintBlob = ProviderHelper.getFingerprint(this, mDataUri);
|
||||||
|
}
|
||||||
|
String fingerprint = PgpKeyHelper.convertFingerprintToHex(fingerprintBlob, true);
|
||||||
fingerprint = fingerprint.replace(" ", "\n");
|
fingerprint = fingerprint.replace(" ", "\n");
|
||||||
mFingerprint.setText(fingerprint);
|
|
||||||
|
|
||||||
// TODO: get image with getUserAttributes() on key and then
|
mFingerprint.setText(fingerprint);
|
||||||
// PGPUserAttributeSubpacketVector
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mKeysAdapter.swapCursor(data);
|
mKeysAdapter.swapCursor(data);
|
||||||
@ -392,13 +390,8 @@ public class ViewKeyActivity extends SherlockFragmentActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateFromKeyserver(Uri dataUri) {
|
private void updateFromKeyserver(Uri dataUri) {
|
||||||
long updateKeyId = 0;
|
long updateKeyId = ProviderHelper.getMasterKeyId(ViewKeyActivity.this, mDataUri);
|
||||||
PGPPublicKeyRing updateRing = (PGPPublicKeyRing) ProviderHelper
|
|
||||||
.getPGPKeyRing(this, dataUri);
|
|
||||||
|
|
||||||
if (updateRing != null) {
|
|
||||||
updateKeyId = PgpKeyHelper.getMasterKey(updateRing).getKeyID();
|
|
||||||
}
|
|
||||||
if (updateKeyId == 0) {
|
if (updateKeyId == 0) {
|
||||||
Log.e(Constants.TAG, "this shouldn't happen. KeyId == 0!");
|
Log.e(Constants.TAG, "this shouldn't happen. KeyId == 0!");
|
||||||
return;
|
return;
|
||||||
@ -421,14 +414,10 @@ public class ViewKeyActivity extends SherlockFragmentActivity implements
|
|||||||
private void shareKey(Uri dataUri, boolean fingerprintOnly) {
|
private void shareKey(Uri dataUri, boolean fingerprintOnly) {
|
||||||
String content = null;
|
String content = null;
|
||||||
if (fingerprintOnly) {
|
if (fingerprintOnly) {
|
||||||
long masterKeyId = ProviderHelper.getMasterKeyId(this, dataUri);
|
byte[] fingerprintBlob = ProviderHelper.getFingerprint(this, dataUri);
|
||||||
|
String fingerprint = PgpKeyHelper.convertFingerprintToHex(fingerprintBlob, false);
|
||||||
|
|
||||||
// TODO: dublicated in ShareQrCodeDialog
|
content = Constants.FINGERPRINT_SCHEME + fingerprint;
|
||||||
content = "openpgp4fpr:";
|
|
||||||
|
|
||||||
String fingerprint = PgpKeyHelper.convertKeyToHex(masterKeyId);
|
|
||||||
|
|
||||||
content = content + fingerprint;
|
|
||||||
} else {
|
} else {
|
||||||
// get public keyring as ascii armored string
|
// get public keyring as ascii armored string
|
||||||
long masterKeyId = ProviderHelper.getMasterKeyId(this, dataUri);
|
long masterKeyId = ProviderHelper.getMasterKeyId(this, dataUri);
|
||||||
|
@ -90,13 +90,11 @@ public class ShareQrCodeDialogFragment extends SherlockDialogFragment {
|
|||||||
|
|
||||||
String content = null;
|
String content = null;
|
||||||
if (mFingerprintOnly) {
|
if (mFingerprintOnly) {
|
||||||
content = "openpgp4fpr:";
|
|
||||||
|
|
||||||
byte[] fingerprintBlob = ProviderHelper.getFingerprint(getActivity(), dataUri);
|
byte[] fingerprintBlob = ProviderHelper.getFingerprint(getActivity(), dataUri);
|
||||||
String fingerprint = PgpKeyHelper.convertFingerprintToHex(fingerprintBlob, false);
|
String fingerprint = PgpKeyHelper.convertFingerprintToHex(fingerprintBlob, false);
|
||||||
|
|
||||||
mText.setText(getString(R.string.share_qr_code_dialog_fingerprint_text) + " " + fingerprint);
|
mText.setText(getString(R.string.share_qr_code_dialog_fingerprint_text) + " " + fingerprint);
|
||||||
content = content + fingerprint;
|
content = Constants.FINGERPRINT_SCHEME + fingerprint;
|
||||||
|
|
||||||
Log.d(Constants.TAG, "content: " + content);
|
Log.d(Constants.TAG, "content: " + content);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user