(WIP) Change password when key is stripped #1692
Approach: Find the first unstripped secret key and use it for passphrase verification All unstripped keys will have their passphrase changed to new passphrase, if possible. Current Progress: Changing the passphrase of keys works fine. Refactoring to combine "modifySecretKeyring" and newly added method, "modifyKeyRingPassword" may be possible if given the go-ahead.
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package org.sufficientlysecure.keychain.service;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||
|
||||
public class ChangeUnlockParcel implements Parcelable {
|
||||
|
||||
// The new passphrase to use
|
||||
public final Passphrase mNewPassphrase;
|
||||
|
||||
public ChangeUnlockParcel(Passphrase newPassphrase) {
|
||||
if (newPassphrase == null) {
|
||||
throw new AssertionError("newPassphrase must be non-null. THIS IS A BUG!");
|
||||
}
|
||||
mNewPassphrase = newPassphrase;
|
||||
}
|
||||
|
||||
public ChangeUnlockParcel(Parcel source) {
|
||||
mNewPassphrase = source.readParcelable(Passphrase.class.getClassLoader());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel destination, int flags) {
|
||||
destination.writeParcelable(mNewPassphrase, flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static final Creator<ChangeUnlockParcel> CREATOR = new Creator<ChangeUnlockParcel>() {
|
||||
public ChangeUnlockParcel createFromParcel(final Parcel source) {
|
||||
return new ChangeUnlockParcel(source);
|
||||
}
|
||||
|
||||
public ChangeUnlockParcel[] newArray(final int size) {
|
||||
return new ChangeUnlockParcel[size];
|
||||
}
|
||||
};
|
||||
|
||||
public String toString() {
|
||||
return "passphrase (" + mNewPassphrase + ")";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -38,6 +38,7 @@ import org.sufficientlysecure.keychain.operations.BackupOperation;
|
||||
import org.sufficientlysecure.keychain.operations.ImportOperation;
|
||||
import org.sufficientlysecure.keychain.operations.KeybaseVerificationOperation;
|
||||
import org.sufficientlysecure.keychain.operations.InputDataOperation;
|
||||
import org.sufficientlysecure.keychain.operations.PassphraseChangeOperation;
|
||||
import org.sufficientlysecure.keychain.operations.PromoteKeyOperation;
|
||||
import org.sufficientlysecure.keychain.operations.RevokeOperation;
|
||||
import org.sufficientlysecure.keychain.operations.SignEncryptOperation;
|
||||
@@ -116,6 +117,8 @@ public class KeychainService extends Service implements Progressable {
|
||||
op = new PgpDecryptVerifyOperation(outerThis, new ProviderHelper(outerThis), outerThis);
|
||||
} else if (inputParcel instanceof SaveKeyringParcel) {
|
||||
op = new EditKeyOperation(outerThis, new ProviderHelper(outerThis), outerThis, mActionCanceled);
|
||||
} else if (inputParcel instanceof PassphraseChangeParcel) {
|
||||
op = new PassphraseChangeOperation(outerThis, new ProviderHelper(outerThis), outerThis);
|
||||
} else if (inputParcel instanceof RevokeKeyringParcel) {
|
||||
op = new RevokeOperation(outerThis, new ProviderHelper(outerThis), outerThis);
|
||||
} else if (inputParcel instanceof CertifyActionsParcel) {
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package org.sufficientlysecure.keychain.service;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
public class PassphraseChangeParcel implements Parcelable {
|
||||
|
||||
// the master key id to be edited.
|
||||
public Long mMasterKeyId;
|
||||
// the first sub key id that is not stripped.
|
||||
public Long mValidSubkeyId;
|
||||
// the key fingerprint, for safety.
|
||||
public byte[] mFingerprint;
|
||||
|
||||
public ChangeUnlockParcel mNewUnlock;
|
||||
|
||||
|
||||
public PassphraseChangeParcel(long masterKeyId, byte[] fingerprint) {
|
||||
mMasterKeyId = masterKeyId;
|
||||
mFingerprint = fingerprint;
|
||||
}
|
||||
|
||||
public PassphraseChangeParcel(Parcel source) {
|
||||
mValidSubkeyId = source.readInt() != 0 ? source.readLong() : null;
|
||||
mMasterKeyId = source.readLong();
|
||||
mFingerprint = source.createByteArray();
|
||||
|
||||
mNewUnlock = source.readParcelable(getClass().getClassLoader());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel destination, int flags) {
|
||||
destination.writeInt(mValidSubkeyId == null ? 0 : 1);
|
||||
if (mValidSubkeyId != null) {
|
||||
destination.writeLong(mValidSubkeyId);
|
||||
}
|
||||
destination.writeLong(mMasterKeyId);
|
||||
destination.writeByteArray(mFingerprint);
|
||||
destination.writeParcelable(mNewUnlock, flags);
|
||||
}
|
||||
|
||||
public static final Creator<PassphraseChangeParcel> CREATOR = new Creator<PassphraseChangeParcel>() {
|
||||
public PassphraseChangeParcel createFromParcel(final Parcel source) {
|
||||
return new PassphraseChangeParcel(source);
|
||||
}
|
||||
|
||||
public PassphraseChangeParcel[] newArray(final int size) {
|
||||
return new PassphraseChangeParcel[size];
|
||||
}
|
||||
};
|
||||
|
||||
public String toString() {
|
||||
String out = "mMasterKeyId: " + mMasterKeyId + "\n";
|
||||
out += "mNewUnlock: " + mNewUnlock + "\n";
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -344,54 +344,6 @@ public class SaveKeyringParcel implements Parcelable {
|
||||
// BRAINPOOL_P256, BRAINPOOL_P384, BRAINPOOL_P512
|
||||
}
|
||||
|
||||
/** This subclass contains information on how the passphrase should be changed.
|
||||
*
|
||||
* If no changes are to be made, this class should NOT be used!
|
||||
*
|
||||
* At this point, there must be *exactly one* non-null value here, which specifies the type
|
||||
* of unlocking mechanism to use.
|
||||
*
|
||||
*/
|
||||
public static class ChangeUnlockParcel implements Parcelable {
|
||||
|
||||
// The new passphrase to use
|
||||
public final Passphrase mNewPassphrase;
|
||||
|
||||
public ChangeUnlockParcel(Passphrase newPassphrase) {
|
||||
if (newPassphrase == null) {
|
||||
throw new AssertionError("newPassphrase must be non-null. THIS IS A BUG!");
|
||||
}
|
||||
mNewPassphrase = newPassphrase;
|
||||
}
|
||||
|
||||
public ChangeUnlockParcel(Parcel source) {
|
||||
mNewPassphrase = source.readParcelable(Passphrase.class.getClassLoader());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel destination, int flags) {
|
||||
destination.writeParcelable(mNewPassphrase, flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static final Creator<ChangeUnlockParcel> CREATOR = new Creator<ChangeUnlockParcel>() {
|
||||
public ChangeUnlockParcel createFromParcel(final Parcel source) {
|
||||
return new ChangeUnlockParcel(source);
|
||||
}
|
||||
|
||||
public ChangeUnlockParcel[] newArray(final int size) {
|
||||
return new ChangeUnlockParcel[size];
|
||||
}
|
||||
};
|
||||
|
||||
public String toString() {
|
||||
return "passphrase (" + mNewPassphrase + ")";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user