prevented passphrase caching on revocation
This commit is contained in:
@@ -31,6 +31,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||
import org.sufficientlysecure.keychain.service.DeleteKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.RevokeKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper;
|
||||
import org.sufficientlysecure.keychain.ui.dialog.CustomAlertDialogBuilder;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
@@ -111,7 +112,7 @@ public class DeleteKeyDialogActivity extends FragmentActivity {
|
||||
}
|
||||
|
||||
private void startRevocationOperation() {
|
||||
mRevokeOpHelper.cryptoOperation();
|
||||
mRevokeOpHelper.cryptoOperation(new CryptoInputParcel(false));
|
||||
}
|
||||
|
||||
private void startDeletionOperation() {
|
||||
|
||||
@@ -72,11 +72,14 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
||||
|
||||
public static final String EXTRA_REQUIRED_INPUT = "required_input";
|
||||
public static final String EXTRA_SUBKEY_ID = "secret_key_id";
|
||||
public static final String EXTRA_CRYPTO_INPUT = "crypto_input";
|
||||
|
||||
// special extra for OpenPgpService
|
||||
public static final String EXTRA_SERVICE_INTENT = "data";
|
||||
private long mSubKeyId;
|
||||
|
||||
private CryptoInputParcel mCryptoInputParcel;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -90,6 +93,8 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
||||
);
|
||||
}
|
||||
|
||||
mCryptoInputParcel = getIntent().getParcelableExtra(EXTRA_CRYPTO_INPUT);
|
||||
|
||||
// this activity itself has no content view (see manifest)
|
||||
|
||||
if (getIntent().hasExtra(EXTRA_SUBKEY_ID)) {
|
||||
@@ -330,11 +335,16 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
||||
public void onClick(View v) {
|
||||
final Passphrase passphrase = new Passphrase(mPassphraseEditText);
|
||||
|
||||
CryptoInputParcel cryptoInputParcel =
|
||||
((PassphraseDialogActivity) getActivity()).mCryptoInputParcel;
|
||||
|
||||
// Early breakout if we are dealing with a symmetric key
|
||||
if (mSecretRing == null) {
|
||||
PassphraseCacheService.addCachedPassphrase(getActivity(),
|
||||
Constants.key.symmetric, Constants.key.symmetric, passphrase,
|
||||
getString(R.string.passp_cache_notif_pwd));
|
||||
if (cryptoInputParcel.mCachePassphrase) {
|
||||
PassphraseCacheService.addCachedPassphrase(getActivity(),
|
||||
Constants.key.symmetric, Constants.key.symmetric, passphrase,
|
||||
getString(R.string.passp_cache_notif_pwd));
|
||||
}
|
||||
|
||||
finishCaching(passphrase);
|
||||
return;
|
||||
@@ -387,15 +397,24 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
||||
return;
|
||||
}
|
||||
|
||||
// cache the new passphrase
|
||||
Log.d(Constants.TAG, "Everything okay! Caching entered passphrase");
|
||||
// cache the new passphrase as specified in CryptoInputParcel
|
||||
Log.d(Constants.TAG, "Everything okay!");
|
||||
|
||||
try {
|
||||
PassphraseCacheService.addCachedPassphrase(getActivity(),
|
||||
mSecretRing.getMasterKeyId(), mSubKeyId, passphrase,
|
||||
mSecretRing.getPrimaryUserIdWithFallback());
|
||||
} catch (PgpKeyNotFoundException e) {
|
||||
Log.e(Constants.TAG, "adding of a passphrase failed", e);
|
||||
CryptoInputParcel cryptoInputParcel
|
||||
= ((PassphraseDialogActivity) getActivity()).mCryptoInputParcel;
|
||||
|
||||
if (cryptoInputParcel.mCachePassphrase) {
|
||||
Log.d(Constants.TAG, "Caching entered passphrase");
|
||||
|
||||
try {
|
||||
PassphraseCacheService.addCachedPassphrase(getActivity(),
|
||||
mSecretRing.getMasterKeyId(), mSubKeyId, passphrase,
|
||||
mSecretRing.getPrimaryUserIdWithFallback());
|
||||
} catch (PgpKeyNotFoundException e) {
|
||||
Log.e(Constants.TAG, "adding of a passphrase failed", e);
|
||||
}
|
||||
} else {
|
||||
Log.d(Constants.TAG, "Not caching entered passphrase!");
|
||||
}
|
||||
|
||||
finishCaching(passphrase);
|
||||
@@ -411,9 +430,12 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
||||
return;
|
||||
}
|
||||
|
||||
CryptoInputParcel inputParcel = new CryptoInputParcel(null, passphrase);
|
||||
CryptoInputParcel inputParcel =
|
||||
((PassphraseDialogActivity) getActivity()).mCryptoInputParcel;
|
||||
inputParcel.mPassphrase = passphrase;
|
||||
if (mServiceIntent != null) {
|
||||
CryptoInputParcelCacheService.addCryptoInputParcel(getActivity(), mServiceIntent, inputParcel);
|
||||
CryptoInputParcelCacheService.addCryptoInputParcel(getActivity(), mServiceIntent,
|
||||
inputParcel);
|
||||
getActivity().setResult(RESULT_OK, mServiceIntent);
|
||||
} else {
|
||||
// also return passphrase back to activity
|
||||
|
||||
@@ -118,7 +118,7 @@ public class CryptoOperationHelper<T extends Parcelable, S extends OperationResu
|
||||
Activity activity = mUseFragment ? mFragment.getActivity() : mActivity;
|
||||
|
||||
switch (requiredInput.mType) {
|
||||
// TODO: Verify that all started activities add to cryptoInputParcel if necessary (like OrbotRequiredDialogActivity)
|
||||
// TODO: make NfcOperationActivity add to cryptoInputParcel
|
||||
// always use CryptoOperationHelper.startActivityForResult!
|
||||
case NFC_MOVE_KEY_TO_CARD:
|
||||
case NFC_DECRYPT:
|
||||
@@ -133,6 +133,7 @@ public class CryptoOperationHelper<T extends Parcelable, S extends OperationResu
|
||||
case PASSPHRASE_SYMMETRIC: {
|
||||
Intent intent = new Intent(activity, PassphraseDialogActivity.class);
|
||||
intent.putExtra(PassphraseDialogActivity.EXTRA_REQUIRED_INPUT, requiredInput);
|
||||
intent.putExtra(PassphraseDialogActivity.EXTRA_CRYPTO_INPUT, cryptoInputParcel);
|
||||
startActivityForResult(intent, REQUEST_CODE_PASSPHRASE);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user