mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-23 17:22:16 -05:00
yubikey: don't assume signing key is masterKeyId in ViewKeyActivity
Conflicts: OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java
This commit is contained in:
parent
022fde29ae
commit
a81474b7a5
@ -193,13 +193,19 @@ public class CreateKeyYubiKeyImportFragment extends Fragment implements NfcListe
|
|||||||
ImportKeyResult result =
|
ImportKeyResult result =
|
||||||
returnData.getParcelable(DecryptVerifyResult.EXTRA_RESULT);
|
returnData.getParcelable(DecryptVerifyResult.EXTRA_RESULT);
|
||||||
|
|
||||||
if (!result.success()) {
|
long[] masterKeyIds = result.getImportedMasterKeyIds();
|
||||||
|
|
||||||
|
// TODO handle masterKeyIds.length != 1...? sorta outlandish scenario
|
||||||
|
|
||||||
|
if (!result.success() || masterKeyIds.length == 0) {
|
||||||
result.createNotify(getActivity()).show();
|
result.createNotify(getActivity()).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Intent intent = new Intent(getActivity(), ViewKeyActivity.class);
|
Intent intent = new Intent(getActivity(), ViewKeyActivity.class);
|
||||||
intent.setData(KeyRings.buildGenericKeyRingUri(mNfcMasterKeyId));
|
// use the imported masterKeyId, not the one from the yubikey, because
|
||||||
|
// that one might* just have been a subkey of the imported key
|
||||||
|
intent.setData(KeyRings.buildGenericKeyRingUri(masterKeyIds[0]));
|
||||||
intent.putExtra(ViewKeyActivity.EXTRA_DISPLAY_RESULT, result);
|
intent.putExtra(ViewKeyActivity.EXTRA_DISPLAY_RESULT, result);
|
||||||
intent.putExtra(ViewKeyActivity.EXTRA_NFC_AID, mNfcAid);
|
intent.putExtra(ViewKeyActivity.EXTRA_NFC_AID, mNfcAid);
|
||||||
intent.putExtra(ViewKeyActivity.EXTRA_NFC_USER_ID, mNfcUserId);
|
intent.putExtra(ViewKeyActivity.EXTRA_NFC_USER_ID, mNfcUserId);
|
||||||
|
@ -535,49 +535,54 @@ public class ViewKeyActivity extends BaseNfcActivity implements
|
|||||||
final String nfcUserId = nfcGetUserId();
|
final String nfcUserId = nfcGetUserId();
|
||||||
final byte[] nfcAid = nfcGetAid();
|
final byte[] nfcAid = nfcGetAid();
|
||||||
|
|
||||||
String fp = KeyFormattingUtils.convertFingerprintToHex(nfcFingerprints);
|
long yubiKeyId = KeyFormattingUtils.getKeyIdFromFingerprint(nfcFingerprints);
|
||||||
final long masterKeyId = KeyFormattingUtils.getKeyIdFromFingerprint(nfcFingerprints);
|
|
||||||
|
|
||||||
if (!mFingerprint.equals(fp)) {
|
try {
|
||||||
try {
|
|
||||||
CachedPublicKeyRing ring = mProviderHelper.getCachedPublicKeyRing(masterKeyId);
|
|
||||||
ring.getMasterKeyId();
|
|
||||||
|
|
||||||
Notify.create(this, R.string.snack_yubi_other, Notify.LENGTH_LONG,
|
// if the yubikey matches a subkey in any key
|
||||||
Style.WARN, new ActionListener() {
|
CachedPublicKeyRing ring = mProviderHelper.getCachedPublicKeyRing(
|
||||||
@Override
|
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(yubiKeyId));
|
||||||
public void onAction() {
|
byte[] candidateFp = ring.getFingerprint();
|
||||||
Intent intent = new Intent(
|
|
||||||
ViewKeyActivity.this, ViewKeyActivity.class);
|
|
||||||
intent.setData(KeyRings.buildGenericKeyRingUri(masterKeyId));
|
|
||||||
intent.putExtra(ViewKeyActivity.EXTRA_NFC_AID, nfcAid);
|
|
||||||
intent.putExtra(ViewKeyActivity.EXTRA_NFC_USER_ID, nfcUserId);
|
|
||||||
intent.putExtra(ViewKeyActivity.EXTRA_NFC_FINGERPRINTS, nfcFingerprints);
|
|
||||||
startActivity(intent);
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
}, R.string.snack_yubikey_view).show();
|
|
||||||
return;
|
|
||||||
|
|
||||||
} catch (PgpKeyNotFoundException e) {
|
// if the master key of that key matches this one, just show the yubikey dialog
|
||||||
Notify.create(this, R.string.snack_yubi_other, Notify.LENGTH_LONG,
|
if (KeyFormattingUtils.convertFingerprintToHex(candidateFp).equals(mFingerprint)) {
|
||||||
Style.WARN, new ActionListener() {
|
showYubiKeyFragment(nfcFingerprints, nfcUserId, nfcAid);
|
||||||
@Override
|
|
||||||
public void onAction() {
|
|
||||||
Intent intent = new Intent(
|
|
||||||
ViewKeyActivity.this, CreateKeyActivity.class);
|
|
||||||
intent.putExtra(ViewKeyActivity.EXTRA_NFC_AID, nfcAid);
|
|
||||||
intent.putExtra(ViewKeyActivity.EXTRA_NFC_USER_ID, nfcUserId);
|
|
||||||
intent.putExtra(ViewKeyActivity.EXTRA_NFC_FINGERPRINTS, nfcFingerprints);
|
|
||||||
startActivity(intent);
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
}, R.string.snack_yubikey_import).show();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
showYubiKeyFragment(nfcFingerprints, nfcUserId, nfcAid);
|
// otherwise, offer to go to that key
|
||||||
|
final long masterKeyId = KeyFormattingUtils.getKeyIdFromFingerprint(candidateFp);
|
||||||
|
Notify.create(this, R.string.snack_yubi_other, Notify.LENGTH_LONG,
|
||||||
|
Style.WARN, new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void onAction() {
|
||||||
|
Intent intent = new Intent(
|
||||||
|
ViewKeyActivity.this, ViewKeyActivity.class);
|
||||||
|
intent.setData(KeyRings.buildGenericKeyRingUri(masterKeyId));
|
||||||
|
intent.putExtra(ViewKeyActivity.EXTRA_NFC_AID, nfcAid);
|
||||||
|
intent.putExtra(ViewKeyActivity.EXTRA_NFC_USER_ID, nfcUserId);
|
||||||
|
intent.putExtra(ViewKeyActivity.EXTRA_NFC_FINGERPRINTS, nfcFingerprints);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}, R.string.snack_yubikey_view).show();
|
||||||
|
|
||||||
|
// and if it's not found, offer import
|
||||||
|
} catch (PgpKeyNotFoundException e) {
|
||||||
|
Notify.create(this, R.string.snack_yubi_other, Notify.LENGTH_LONG,
|
||||||
|
Style.WARN, new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void onAction() {
|
||||||
|
Intent intent = new Intent(
|
||||||
|
ViewKeyActivity.this, CreateKeyActivity.class);
|
||||||
|
intent.putExtra(ViewKeyActivity.EXTRA_NFC_AID, nfcAid);
|
||||||
|
intent.putExtra(ViewKeyActivity.EXTRA_NFC_USER_ID, nfcUserId);
|
||||||
|
intent.putExtra(ViewKeyActivity.EXTRA_NFC_FINGERPRINTS, nfcFingerprints);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}, R.string.snack_yubikey_import).show();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -794,6 +799,7 @@ public class ViewKeyActivity extends BaseNfcActivity implements
|
|||||||
// old cursor once we return.)
|
// old cursor once we return.)
|
||||||
switch (loader.getId()) {
|
switch (loader.getId()) {
|
||||||
case LOADER_ID_UNIFIED: {
|
case LOADER_ID_UNIFIED: {
|
||||||
|
|
||||||
if (data.moveToFirst()) {
|
if (data.moveToFirst()) {
|
||||||
// get name, email, and comment from USER_ID
|
// get name, email, and comment from USER_ID
|
||||||
KeyRing.UserId mainUserId = KeyRing.splitUserId(data.getString(INDEX_USER_ID));
|
KeyRing.UserId mainUserId = KeyRing.splitUserId(data.getString(INDEX_USER_ID));
|
||||||
|
Loading…
Reference in New Issue
Block a user