From 525788359c6821a958ee7306ef3aa34d7b211a6f Mon Sep 17 00:00:00 2001 From: Alex Fong Date: Tue, 15 Mar 2016 10:24:28 +0800 Subject: (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. --- .../keychain/service/PassphraseChangeParcel.java | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseChangeParcel.java (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseChangeParcel.java') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseChangeParcel.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseChangeParcel.java new file mode 100644 index 000000000..8b08aa115 --- /dev/null +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseChangeParcel.java @@ -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 CREATOR = new Creator() { + 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; + } +} -- cgit v1.2.3