mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-17 14:25:08 -05:00
respect cache in yubikey pin data flow
This commit is contained in:
parent
18844a20bb
commit
007bbdda2b
@ -54,7 +54,7 @@ public class NfcOperationActivity extends BaseNfcActivity {
|
|||||||
mServiceIntent = data.getParcelable(EXTRA_SERVICE_INTENT);
|
mServiceIntent = data.getParcelable(EXTRA_SERVICE_INTENT);
|
||||||
|
|
||||||
// obtain passphrase for this subkey
|
// obtain passphrase for this subkey
|
||||||
obtainYubiKeyPin(RequiredInputParcel.createRequiredPassphrase(mRequiredInput));
|
obtainYubiKeyPin(mRequiredInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -115,7 +115,7 @@ public class NfcOperationActivity extends BaseNfcActivity {
|
|||||||
PassphraseCacheService.clearCachedPassphrase(
|
PassphraseCacheService.clearCachedPassphrase(
|
||||||
this, mRequiredInput.getMasterKeyId(), mRequiredInput.getSubKeyId());
|
this, mRequiredInput.getMasterKeyId(), mRequiredInput.getSubKeyId());
|
||||||
|
|
||||||
obtainYubiKeyPin(RequiredInputParcel.createRequiredPassphrase(mRequiredInput));
|
obtainYubiKeyPin(mRequiredInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,8 @@ import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
|||||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
|
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
|
||||||
|
import org.sufficientlysecure.keychain.service.PassphraseCacheService.KeyNotFoundException;
|
||||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
||||||
import org.sufficientlysecure.keychain.ui.CreateKeyActivity;
|
import org.sufficientlysecure.keychain.ui.CreateKeyActivity;
|
||||||
@ -129,16 +131,29 @@ public abstract class BaseNfcActivity extends BaseActivity {
|
|||||||
|
|
||||||
protected void obtainYubiKeyPin(RequiredInputParcel requiredInput) {
|
protected void obtainYubiKeyPin(RequiredInputParcel requiredInput) {
|
||||||
|
|
||||||
|
// shortcut if we only use the default yubikey pin
|
||||||
Preferences prefs = Preferences.getPreferences(this);
|
Preferences prefs = Preferences.getPreferences(this);
|
||||||
if (prefs.useDefaultYubiKeyPin()) {
|
if (prefs.useDefaultYubiKeyPin()) {
|
||||||
mPin = new Passphrase("123456");
|
mPin = new Passphrase("123456");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Passphrase phrase = PassphraseCacheService.getCachedPassphrase(this,
|
||||||
|
requiredInput.getMasterKeyId(), requiredInput.getSubKeyId());
|
||||||
|
if (phrase != null) {
|
||||||
|
mPin = phrase;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Intent intent = new Intent(this, PassphraseDialogActivity.class);
|
Intent intent = new Intent(this, PassphraseDialogActivity.class);
|
||||||
intent.putExtra(PassphraseDialogActivity.EXTRA_REQUIRED_INPUT,
|
intent.putExtra(PassphraseDialogActivity.EXTRA_REQUIRED_INPUT,
|
||||||
RequiredInputParcel.createRequiredPassphrase(requiredInput));
|
RequiredInputParcel.createRequiredPassphrase(requiredInput));
|
||||||
startActivityForResult(intent, REQUEST_CODE_PASSPHRASE);
|
startActivityForResult(intent, REQUEST_CODE_PASSPHRASE);
|
||||||
|
} catch (KeyNotFoundException e) {
|
||||||
|
throw new AssertionError(
|
||||||
|
"tried to find passphrase for non-existing key. this is a programming error!");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user