mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-30 12:32:17 -05:00
Bugfixes and changes based on feedback
This commit is contained in:
parent
28b9068ae0
commit
de2006a61f
@ -83,7 +83,7 @@ public class EditKeyOperation extends BaseOperation {
|
|||||||
CanonicalizedSecretKeyRing secRing =
|
CanonicalizedSecretKeyRing secRing =
|
||||||
mProviderHelper.getCanonicalizedSecretKeyRing(saveParcel.mMasterKeyId);
|
mProviderHelper.getCanonicalizedSecretKeyRing(saveParcel.mMasterKeyId);
|
||||||
|
|
||||||
modifyResult = keyOperations.modifySecretKeyRing(secRing, cryptoInput, saveParcel, log);
|
modifyResult = keyOperations.modifySecretKeyRing(secRing, cryptoInput, saveParcel, log, 2);
|
||||||
if (modifyResult.isPending()) {
|
if (modifyResult.isPending()) {
|
||||||
return modifyResult;
|
return modifyResult;
|
||||||
}
|
}
|
||||||
|
@ -495,6 +495,9 @@ public abstract class OperationResult implements Parcelable {
|
|||||||
MSG_MF_ERROR_SIG (LogLevel.ERROR, R.string.msg_mf_error_sig),
|
MSG_MF_ERROR_SIG (LogLevel.ERROR, R.string.msg_mf_error_sig),
|
||||||
MSG_MF_ERROR_SUBKEY_MISSING(LogLevel.ERROR, R.string.msg_mf_error_subkey_missing),
|
MSG_MF_ERROR_SUBKEY_MISSING(LogLevel.ERROR, R.string.msg_mf_error_subkey_missing),
|
||||||
MSG_MF_ERROR_CONFLICTING_NFC_COMMANDS(LogLevel.ERROR, R.string.msg_mf_error_conflicting_nfc_commands),
|
MSG_MF_ERROR_CONFLICTING_NFC_COMMANDS(LogLevel.ERROR, R.string.msg_mf_error_conflicting_nfc_commands),
|
||||||
|
MSG_MF_ERROR_BAD_NFC_ALGO(LogLevel.ERROR, R.string.edit_key_error_bad_nfc_algo),
|
||||||
|
MSG_MF_ERROR_BAD_NFC_SIZE(LogLevel.ERROR, R.string.edit_key_error_bad_nfc_size),
|
||||||
|
MSG_MF_ERROR_BAD_NFC_STRIPPED(LogLevel.ERROR, R.string.edit_key_error_bad_nfc_stripped),
|
||||||
MSG_MF_MASTER (LogLevel.DEBUG, R.string.msg_mf_master),
|
MSG_MF_MASTER (LogLevel.DEBUG, R.string.msg_mf_master),
|
||||||
MSG_MF_NOTATION_PIN (LogLevel.DEBUG, R.string.msg_mf_notation_pin),
|
MSG_MF_NOTATION_PIN (LogLevel.DEBUG, R.string.msg_mf_notation_pin),
|
||||||
MSG_MF_NOTATION_EMPTY (LogLevel.DEBUG, R.string.msg_mf_notation_empty),
|
MSG_MF_NOTATION_EMPTY (LogLevel.DEBUG, R.string.msg_mf_notation_empty),
|
||||||
@ -739,11 +742,6 @@ public abstract class OperationResult implements Parcelable {
|
|||||||
MSG_EXPORT_LOG_EXPORT_ERROR_FOPEN(LogLevel.ERROR,R.string.msg_export_log_error_fopen),
|
MSG_EXPORT_LOG_EXPORT_ERROR_FOPEN(LogLevel.ERROR,R.string.msg_export_log_error_fopen),
|
||||||
MSG_EXPORT_LOG_EXPORT_ERROR_WRITING(LogLevel.ERROR,R.string.msg_export_log_error_writing),
|
MSG_EXPORT_LOG_EXPORT_ERROR_WRITING(LogLevel.ERROR,R.string.msg_export_log_error_writing),
|
||||||
MSG_EXPORT_LOG_EXPORT_SUCCESS (LogLevel.OK, R.string.msg_export_log_success),
|
MSG_EXPORT_LOG_EXPORT_SUCCESS (LogLevel.OK, R.string.msg_export_log_success),
|
||||||
|
|
||||||
// NFC keytocard
|
|
||||||
MSG_K2C_ERROR_BAD_ALGO(LogLevel.ERROR, R.string.edit_key_error_bad_nfc_algo),
|
|
||||||
MSG_K2C_ERROR_BAD_SIZE(LogLevel.ERROR, R.string.edit_key_error_bad_nfc_size),
|
|
||||||
MSG_K2C_ERROR_BAD_STRIPPED(LogLevel.ERROR, R.string.edit_key_error_bad_nfc_stripped),
|
|
||||||
;
|
;
|
||||||
|
|
||||||
public final int mMsgId;
|
public final int mMsgId;
|
||||||
|
@ -329,7 +329,7 @@ public class PgpKeyOperation {
|
|||||||
|
|
||||||
subProgressPush(50, 100);
|
subProgressPush(50, 100);
|
||||||
CryptoInputParcel cryptoInput = new CryptoInputParcel(new Date(), new Passphrase(""));
|
CryptoInputParcel cryptoInput = new CryptoInputParcel(new Date(), new Passphrase(""));
|
||||||
return internal(sKR, masterSecretKey, add.mFlags, add.mExpiry, cryptoInput, saveParcel, log);
|
return internal(sKR, masterSecretKey, add.mFlags, add.mExpiry, cryptoInput, saveParcel, log, indent);
|
||||||
|
|
||||||
} catch (PGPException e) {
|
} catch (PGPException e) {
|
||||||
log.add(LogType.MSG_CR_ERROR_INTERNAL_PGP, indent);
|
log.add(LogType.MSG_CR_ERROR_INTERNAL_PGP, indent);
|
||||||
@ -363,15 +363,14 @@ public class PgpKeyOperation {
|
|||||||
public PgpEditKeyResult modifySecretKeyRing(CanonicalizedSecretKeyRing wsKR,
|
public PgpEditKeyResult modifySecretKeyRing(CanonicalizedSecretKeyRing wsKR,
|
||||||
CryptoInputParcel cryptoInput,
|
CryptoInputParcel cryptoInput,
|
||||||
SaveKeyringParcel saveParcel) {
|
SaveKeyringParcel saveParcel) {
|
||||||
return modifySecretKeyRing(wsKR, cryptoInput, saveParcel, new OperationLog());
|
return modifySecretKeyRing(wsKR, cryptoInput, saveParcel, new OperationLog(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PgpEditKeyResult modifySecretKeyRing(CanonicalizedSecretKeyRing wsKR,
|
public PgpEditKeyResult modifySecretKeyRing(CanonicalizedSecretKeyRing wsKR,
|
||||||
CryptoInputParcel cryptoInput,
|
CryptoInputParcel cryptoInput,
|
||||||
SaveKeyringParcel saveParcel,
|
SaveKeyringParcel saveParcel,
|
||||||
OperationLog log) {
|
OperationLog log,
|
||||||
|
int indent) {
|
||||||
int indent = 0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 1. Unlock private key
|
* 1. Unlock private key
|
||||||
@ -429,7 +428,7 @@ public class PgpKeyOperation {
|
|||||||
|
|
||||||
if (isDummy(masterSecretKey) || saveParcel.isRestrictedOnly()) {
|
if (isDummy(masterSecretKey) || saveParcel.isRestrictedOnly()) {
|
||||||
log.add(LogType.MSG_MF_RESTRICTED_MODE, indent);
|
log.add(LogType.MSG_MF_RESTRICTED_MODE, indent);
|
||||||
return internalRestricted(sKR, saveParcel, log);
|
return internalRestricted(sKR, saveParcel, log, indent + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do we require a passphrase? If so, pass it along
|
// Do we require a passphrase? If so, pass it along
|
||||||
@ -447,7 +446,7 @@ public class PgpKeyOperation {
|
|||||||
Date expiryTime = wsKR.getPublicKey().getExpiryTime();
|
Date expiryTime = wsKR.getPublicKey().getExpiryTime();
|
||||||
long masterKeyExpiry = expiryTime != null ? expiryTime.getTime() / 1000 : 0L;
|
long masterKeyExpiry = expiryTime != null ? expiryTime.getTime() / 1000 : 0L;
|
||||||
|
|
||||||
return internal(sKR, masterSecretKey, masterKeyFlags, masterKeyExpiry, cryptoInput, saveParcel, log);
|
return internal(sKR, masterSecretKey, masterKeyFlags, masterKeyExpiry, cryptoInput, saveParcel, log, indent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -455,9 +454,8 @@ public class PgpKeyOperation {
|
|||||||
int masterKeyFlags, long masterKeyExpiry,
|
int masterKeyFlags, long masterKeyExpiry,
|
||||||
CryptoInputParcel cryptoInput,
|
CryptoInputParcel cryptoInput,
|
||||||
SaveKeyringParcel saveParcel,
|
SaveKeyringParcel saveParcel,
|
||||||
OperationLog log) {
|
OperationLog log,
|
||||||
|
int indent) {
|
||||||
int indent = 1;
|
|
||||||
|
|
||||||
NfcSignOperationsBuilder nfcSignOps = new NfcSignOperationsBuilder(
|
NfcSignOperationsBuilder nfcSignOps = new NfcSignOperationsBuilder(
|
||||||
cryptoInput.getSignatureTime(), masterSecretKey.getKeyID(),
|
cryptoInput.getSignatureTime(), masterSecretKey.getKeyID(),
|
||||||
@ -1048,9 +1046,7 @@ public class PgpKeyOperation {
|
|||||||
* otherwise.
|
* otherwise.
|
||||||
*/
|
*/
|
||||||
private PgpEditKeyResult internalRestricted(PGPSecretKeyRing sKR, SaveKeyringParcel saveParcel,
|
private PgpEditKeyResult internalRestricted(PGPSecretKeyRing sKR, SaveKeyringParcel saveParcel,
|
||||||
OperationLog log) {
|
OperationLog log, int indent) {
|
||||||
|
|
||||||
int indent = 1;
|
|
||||||
|
|
||||||
progress(R.string.progress_modify, 0);
|
progress(R.string.progress_modify, 0);
|
||||||
|
|
||||||
@ -1543,20 +1539,20 @@ public class PgpKeyOperation {
|
|||||||
if (algorithm != PublicKeyAlgorithmTags.RSA_ENCRYPT &&
|
if (algorithm != PublicKeyAlgorithmTags.RSA_ENCRYPT &&
|
||||||
algorithm != PublicKeyAlgorithmTags.RSA_SIGN &&
|
algorithm != PublicKeyAlgorithmTags.RSA_SIGN &&
|
||||||
algorithm != PublicKeyAlgorithmTags.RSA_GENERAL) {
|
algorithm != PublicKeyAlgorithmTags.RSA_GENERAL) {
|
||||||
log.add(OperationResult.LogType.MSG_K2C_ERROR_BAD_ALGO, indent + 1);
|
log.add(LogType.MSG_MF_ERROR_BAD_NFC_ALGO, indent + 1);
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Key size must be 2048
|
// Key size must be 2048
|
||||||
int keySize = publicKey.getBitStrength();
|
int keySize = publicKey.getBitStrength();
|
||||||
if (keySize != 2048) {
|
if (keySize != 2048) {
|
||||||
log.add(OperationResult.LogType.MSG_K2C_ERROR_BAD_SIZE, indent + 1);
|
log.add(LogType.MSG_MF_ERROR_BAD_NFC_SIZE, indent + 1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Secret key parts must be available
|
// Secret key parts must be available
|
||||||
if (isDivertToCard(key) || isDummy(key)) {
|
if (isDivertToCard(key) || isDummy(key)) {
|
||||||
log.add(OperationResult.LogType.MSG_K2C_ERROR_BAD_STRIPPED, indent + 1);
|
log.add(LogType.MSG_MF_ERROR_BAD_NFC_STRIPPED, indent + 1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,6 @@ import android.view.View.OnClickListener;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
@ -43,7 +42,7 @@ import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround;
|
|||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
||||||
import org.sufficientlysecure.keychain.operations.results.SingletonResult;
|
import org.sufficientlysecure.keychain.operations.results.SingletonResult;
|
||||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey;
|
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
|
||||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||||
@ -420,9 +419,8 @@ public class EditKeyFragment extends CryptoOperationFragment implements
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EditSubkeyDialogFragment.MESSAGE_STRIP: {
|
case EditSubkeyDialogFragment.MESSAGE_STRIP: {
|
||||||
CanonicalizedSecretKey.SecretKeyType secretKeyType =
|
SecretKeyType secretKeyType = mSubkeysAdapter.getSecretKeyType(position);
|
||||||
mSubkeysAdapter.getSecretKeyType(position);
|
if (secretKeyType == SecretKeyType.GNU_DUMMY) {
|
||||||
if (secretKeyType == CanonicalizedSecretKey.SecretKeyType.GNU_DUMMY) {
|
|
||||||
// Key is already stripped; this is a no-op.
|
// Key is already stripped; this is a no-op.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -441,15 +439,27 @@ public class EditKeyFragment extends CryptoOperationFragment implements
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EditSubkeyDialogFragment.MESSAGE_KEYTOCARD: {
|
case EditSubkeyDialogFragment.MESSAGE_KEYTOCARD: {
|
||||||
CanonicalizedSecretKey.SecretKeyType secretKeyType =
|
Activity activity = EditKeyFragment.this.getActivity();
|
||||||
mSubkeysAdapter.getSecretKeyType(position);
|
SecretKeyType secretKeyType = mSubkeysAdapter.getSecretKeyType(position);
|
||||||
if (secretKeyType == CanonicalizedSecretKey.SecretKeyType.DIVERT_TO_CARD ||
|
if (secretKeyType == SecretKeyType.DIVERT_TO_CARD ||
|
||||||
secretKeyType == CanonicalizedSecretKey.SecretKeyType.GNU_DUMMY) {
|
secretKeyType == SecretKeyType.GNU_DUMMY) {
|
||||||
Toast.makeText(EditKeyFragment.this.getActivity(),
|
Notify.create(activity, R.string.edit_key_error_bad_nfc_stripped, Notify.Style.ERROR)
|
||||||
R.string.edit_key_error_bad_nfc_stripped, Toast.LENGTH_SHORT)
|
.show((ViewGroup) activity.findViewById(R.id.import_snackbar));
|
||||||
.show();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
int algorithm = mSubkeysAdapter.getAlgorithm(position);
|
||||||
|
// these are the PGP constants for RSA_GENERAL, RSA_ENCRYPT and RSA_SIGN
|
||||||
|
if (algorithm != 1 && algorithm != 2 && algorithm != 3) {
|
||||||
|
Notify.create(activity, R.string.edit_key_error_bad_nfc_algo, Notify.Style.ERROR)
|
||||||
|
.show((ViewGroup) activity.findViewById(R.id.import_snackbar));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mSubkeysAdapter.getKeySize(position) != 2048) {
|
||||||
|
Notify.create(activity, R.string.edit_key_error_bad_nfc_size, Notify.Style.ERROR)
|
||||||
|
.show((ViewGroup) activity.findViewById(R.id.import_snackbar));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
SubkeyChange change;
|
SubkeyChange change;
|
||||||
change = mSaveKeyringParcel.getSubkeyChange(keyId);
|
change = mSaveKeyringParcel.getSubkeyChange(keyId);
|
||||||
|
@ -104,7 +104,6 @@ public class NfcOperationActivity extends BaseNfcActivity {
|
|||||||
throw new IOException("Couldn't find subkey for key to card operation.");
|
throw new IOException("Couldn't find subkey for key to card operation.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: we're abusing mInputHashes to hold the subkey IDs we need to export.
|
|
||||||
for (int i = 0; i < mRequiredInput.mInputHashes.length; i++) {
|
for (int i = 0; i < mRequiredInput.mInputHashes.length; i++) {
|
||||||
byte[] subkeyBytes = mRequiredInput.mInputHashes[i];
|
byte[] subkeyBytes = mRequiredInput.mInputHashes[i];
|
||||||
ByteBuffer buf = ByteBuffer.wrap(subkeyBytes);
|
ByteBuffer buf = ByteBuffer.wrap(subkeyBytes);
|
||||||
|
Loading…
Reference in New Issue
Block a user