Refactoring: Removed PassphraseChangeParcel and placed its functionality into ChangeUnlockParcel.
This commit is contained in:
@@ -13,25 +13,24 @@ import org.sufficientlysecure.keychain.pgp.PgpKeyOperation;
|
|||||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
import org.sufficientlysecure.keychain.service.PassphraseChangeParcel;
|
import org.sufficientlysecure.keychain.service.ChangeUnlockParcel;
|
||||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||||
import org.sufficientlysecure.keychain.util.ProgressScaler;
|
import org.sufficientlysecure.keychain.util.ProgressScaler;
|
||||||
|
|
||||||
|
|
||||||
public class PassphraseChangeOperation extends BaseOperation<PassphraseChangeParcel> {
|
public class ChangeUnlockOperation extends BaseOperation<ChangeUnlockParcel> {
|
||||||
|
|
||||||
|
public ChangeUnlockOperation(Context context, ProviderHelper providerHelper, Progressable progressable) {
|
||||||
public PassphraseChangeOperation(Context context, ProviderHelper providerHelper, Progressable progressable) {
|
|
||||||
super(context, providerHelper, progressable);
|
super(context, providerHelper, progressable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public OperationResult execute(PassphraseChangeParcel passphraseParcel, CryptoInputParcel cryptoInput) {
|
public OperationResult execute(ChangeUnlockParcel unlockParcel, CryptoInputParcel cryptoInput) {
|
||||||
OperationResult.OperationLog log = new OperationResult.OperationLog();
|
OperationResult.OperationLog log = new OperationResult.OperationLog();
|
||||||
log.add(OperationResult.LogType.MSG_ED, 0);
|
log.add(OperationResult.LogType.MSG_ED, 0);
|
||||||
|
|
||||||
if (passphraseParcel == null || passphraseParcel.mMasterKeyId == null) {
|
if (unlockParcel == null || unlockParcel.mMasterKeyId == null) {
|
||||||
log.add(OperationResult.LogType.MSG_ED_ERROR_NO_PARCEL, 1);
|
log.add(OperationResult.LogType.MSG_ED_ERROR_NO_PARCEL, 1);
|
||||||
return new EditKeyResult(EditKeyResult.RESULT_ERROR, log, null);
|
return new EditKeyResult(EditKeyResult.RESULT_ERROR, log, null);
|
||||||
}
|
}
|
||||||
@@ -44,11 +43,11 @@ public class PassphraseChangeOperation extends BaseOperation<PassphraseChangePar
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
log.add(OperationResult.LogType.MSG_ED_FETCHING, 1,
|
log.add(OperationResult.LogType.MSG_ED_FETCHING, 1,
|
||||||
KeyFormattingUtils.convertKeyIdToHex(passphraseParcel.mMasterKeyId));
|
KeyFormattingUtils.convertKeyIdToHex(unlockParcel.mMasterKeyId));
|
||||||
|
|
||||||
CanonicalizedSecretKeyRing secRing =
|
CanonicalizedSecretKeyRing secRing =
|
||||||
mProviderHelper.getCanonicalizedSecretKeyRing(passphraseParcel.mMasterKeyId);
|
mProviderHelper.getCanonicalizedSecretKeyRing(unlockParcel.mMasterKeyId);
|
||||||
modifyResult = keyOperations.modifyKeyRingPassphrase(secRing, cryptoInput, passphraseParcel);
|
modifyResult = keyOperations.modifyKeyRingPassphrase(secRing, cryptoInput, unlockParcel);
|
||||||
|
|
||||||
if (modifyResult.isPending()) {
|
if (modifyResult.isPending()) {
|
||||||
// obtain original passphrase from user
|
// obtain original passphrase from user
|
||||||
@@ -73,7 +73,6 @@ import org.sufficientlysecure.keychain.operations.results.OperationResult.LogTyp
|
|||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
||||||
import org.sufficientlysecure.keychain.operations.results.PgpEditKeyResult;
|
import org.sufficientlysecure.keychain.operations.results.PgpEditKeyResult;
|
||||||
import org.sufficientlysecure.keychain.service.ChangeUnlockParcel;
|
import org.sufficientlysecure.keychain.service.ChangeUnlockParcel;
|
||||||
import org.sufficientlysecure.keychain.service.PassphraseChangeParcel;
|
|
||||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Algorithm;
|
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Algorithm;
|
||||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Curve;
|
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Curve;
|
||||||
@@ -347,86 +346,6 @@ public class PgpKeyOperation {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public PgpEditKeyResult modifyKeyRingPassphrase(CanonicalizedSecretKeyRing wsKR,
|
|
||||||
CryptoInputParcel cryptoInput,
|
|
||||||
PassphraseChangeParcel passphraseParcel) {
|
|
||||||
|
|
||||||
OperationLog log = new OperationLog();
|
|
||||||
int indent = 0;
|
|
||||||
|
|
||||||
if (passphraseParcel.mMasterKeyId == null || passphraseParcel.mMasterKeyId != wsKR.getMasterKeyId()) {
|
|
||||||
log.add(LogType.MSG_MF_ERROR_KEYID, indent);
|
|
||||||
return new PgpEditKeyResult(PgpEditKeyResult.RESULT_ERROR, log, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
log.add(LogType.MSG_MF, indent,
|
|
||||||
KeyFormattingUtils.convertKeyIdToHex(wsKR.getMasterKeyId()));
|
|
||||||
indent += 1;
|
|
||||||
progress(R.string.progress_building_key, 0);
|
|
||||||
|
|
||||||
// We work on bouncycastle object level here
|
|
||||||
PGPSecretKeyRing sKR = wsKR.getRing();
|
|
||||||
PGPSecretKey masterSecretKey = sKR.getSecretKey();
|
|
||||||
PGPPublicKey masterPublicKey = masterSecretKey.getPublicKey();
|
|
||||||
// Make sure the fingerprint matches
|
|
||||||
if (passphraseParcel.mFingerprint == null || !Arrays.equals(passphraseParcel.mFingerprint,
|
|
||||||
masterSecretKey.getPublicKey().getFingerprint())) {
|
|
||||||
log.add(LogType.MSG_MF_ERROR_FINGERPRINT, indent);
|
|
||||||
return new PgpEditKeyResult(PgpEditKeyResult.RESULT_ERROR, log, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (passphraseParcel.mValidSubkeyId == null) {
|
|
||||||
PGPSecretKey nonDummy = firstNonDummySecretKeyID(sKR);
|
|
||||||
if(nonDummy== null) {
|
|
||||||
log.add(OperationResult.LogType.MSG_MF_ERROR_ALL_KEYS_STRIPPED, 0);
|
|
||||||
return new PgpEditKeyResult(PgpEditKeyResult.RESULT_ERROR, log, null);
|
|
||||||
} else {
|
|
||||||
passphraseParcel.mValidSubkeyId = nonDummy.getKeyID();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!cryptoInput.hasPassphrase()) {
|
|
||||||
log.add(LogType.MSG_MF_REQUIRE_PASSPHRASE, indent);
|
|
||||||
|
|
||||||
return new PgpEditKeyResult(log, RequiredInputParcel.createRequiredSignPassphrase(
|
|
||||||
masterSecretKey.getKeyID(), passphraseParcel.mValidSubkeyId,
|
|
||||||
cryptoInput.getSignatureTime()), cryptoInput);
|
|
||||||
} else {
|
|
||||||
progress(R.string.progress_modify_passphrase, 70);
|
|
||||||
log.add(LogType.MSG_MF_PASSPHRASE, indent);
|
|
||||||
indent += 1;
|
|
||||||
|
|
||||||
try {
|
|
||||||
sKR = applyNewPassphrase(sKR, masterPublicKey, cryptoInput.getPassphrase(),
|
|
||||||
passphraseParcel.mNewUnlock.mNewPassphrase, log, indent);
|
|
||||||
if (sKR == null) {
|
|
||||||
// The error has been logged above, just return a bad state
|
|
||||||
return new PgpEditKeyResult(PgpEditKeyResult.RESULT_ERROR, log, null);
|
|
||||||
}
|
|
||||||
} catch (PGPException e) {
|
|
||||||
throw new UnsupportedOperationException("Failed to build encryptor/decryptor!");
|
|
||||||
}
|
|
||||||
|
|
||||||
indent -= 1;
|
|
||||||
progress(R.string.progress_done, 100);
|
|
||||||
log.add(LogType.MSG_MF_SUCCESS, indent);
|
|
||||||
return new PgpEditKeyResult(OperationResult.RESULT_OK, log, new UncachedKeyRing(sKR));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static PGPSecretKey firstNonDummySecretKeyID(PGPSecretKeyRing secRing) {
|
|
||||||
Iterator<PGPSecretKey> secretKeyIterator = secRing.getSecretKeys();
|
|
||||||
|
|
||||||
while(secretKeyIterator.hasNext()) {
|
|
||||||
PGPSecretKey secretKey = secretKeyIterator.next();
|
|
||||||
if(!isDummy(secretKey)){
|
|
||||||
return secretKey;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** This method introduces a list of modifications specified by a SaveKeyringParcel to a
|
/** This method introduces a list of modifications specified by a SaveKeyringParcel to a
|
||||||
* WrappedSecretKeyRing.
|
* WrappedSecretKeyRing.
|
||||||
*
|
*
|
||||||
@@ -1135,13 +1054,13 @@ public class PgpKeyOperation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 6. If requested, change passphrase
|
// 6. If requested, change passphrase
|
||||||
if (saveParcel.mNewUnlock != null) {
|
if (saveParcel.getChangeUnlockParcel() != null) {
|
||||||
progress(R.string.progress_modify_passphrase, 90);
|
progress(R.string.progress_modify_passphrase, 90);
|
||||||
log.add(LogType.MSG_MF_PASSPHRASE, indent);
|
log.add(LogType.MSG_MF_PASSPHRASE, indent);
|
||||||
indent += 1;
|
indent += 1;
|
||||||
|
|
||||||
sKR = applyNewPassphrase(sKR, masterPublicKey, cryptoInput.getPassphrase(),
|
sKR = applyNewPassphrase(sKR, masterPublicKey, cryptoInput.getPassphrase(),
|
||||||
saveParcel.mNewUnlock.mNewPassphrase, log, indent);
|
saveParcel.getChangeUnlockParcel().mNewPassphrase, log, indent);
|
||||||
if (sKR == null) {
|
if (sKR == null) {
|
||||||
// The error has been logged above, just return a bad state
|
// The error has been logged above, just return a bad state
|
||||||
return new PgpEditKeyResult(PgpEditKeyResult.RESULT_ERROR, log, null);
|
return new PgpEditKeyResult(PgpEditKeyResult.RESULT_ERROR, log, null);
|
||||||
@@ -1274,7 +1193,81 @@ public class PgpKeyOperation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public PgpEditKeyResult modifyKeyRingPassphrase(CanonicalizedSecretKeyRing wsKR,
|
||||||
|
CryptoInputParcel cryptoInput,
|
||||||
|
ChangeUnlockParcel changeUnlockParcel) {
|
||||||
|
|
||||||
|
OperationLog log = new OperationLog();
|
||||||
|
int indent = 0;
|
||||||
|
|
||||||
|
if (changeUnlockParcel.mMasterKeyId == null || changeUnlockParcel.mMasterKeyId != wsKR.getMasterKeyId()) {
|
||||||
|
log.add(LogType.MSG_MF_ERROR_KEYID, indent);
|
||||||
|
return new PgpEditKeyResult(PgpEditKeyResult.RESULT_ERROR, log, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
log.add(LogType.MSG_MF, indent,
|
||||||
|
KeyFormattingUtils.convertKeyIdToHex(wsKR.getMasterKeyId()));
|
||||||
|
indent += 1;
|
||||||
|
progress(R.string.progress_building_key, 0);
|
||||||
|
|
||||||
|
// We work on bouncycastle object level here
|
||||||
|
PGPSecretKeyRing sKR = wsKR.getRing();
|
||||||
|
PGPSecretKey masterSecretKey = sKR.getSecretKey();
|
||||||
|
PGPPublicKey masterPublicKey = masterSecretKey.getPublicKey();
|
||||||
|
// Make sure the fingerprint matches
|
||||||
|
if (changeUnlockParcel.mFingerprint == null || !Arrays.equals(changeUnlockParcel.mFingerprint,
|
||||||
|
masterSecretKey.getPublicKey().getFingerprint())) {
|
||||||
|
log.add(LogType.MSG_MF_ERROR_FINGERPRINT, indent);
|
||||||
|
return new PgpEditKeyResult(PgpEditKeyResult.RESULT_ERROR, log, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the first unstripped secret key
|
||||||
|
PGPSecretKey nonDummy = firstNonDummySecretKeyID(sKR);
|
||||||
|
if(nonDummy == null) {
|
||||||
|
log.add(OperationResult.LogType.MSG_MF_ERROR_ALL_KEYS_STRIPPED, indent);
|
||||||
|
return new PgpEditKeyResult(PgpEditKeyResult.RESULT_ERROR, log, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!cryptoInput.hasPassphrase()) {
|
||||||
|
log.add(LogType.MSG_MF_REQUIRE_PASSPHRASE, indent);
|
||||||
|
|
||||||
|
return new PgpEditKeyResult(log, RequiredInputParcel.createRequiredSignPassphrase(
|
||||||
|
masterSecretKey.getKeyID(), nonDummy.getKeyID(),
|
||||||
|
cryptoInput.getSignatureTime()), cryptoInput);
|
||||||
|
} else {
|
||||||
|
progress(R.string.progress_modify_passphrase, 50);
|
||||||
|
log.add(LogType.MSG_MF_PASSPHRASE, indent);
|
||||||
|
indent += 1;
|
||||||
|
|
||||||
|
try {
|
||||||
|
sKR = applyNewPassphrase(sKR, masterPublicKey, cryptoInput.getPassphrase(),
|
||||||
|
changeUnlockParcel.mNewPassphrase, log, indent);
|
||||||
|
if (sKR == null) {
|
||||||
|
// The error has been logged above, just return a bad state
|
||||||
|
return new PgpEditKeyResult(PgpEditKeyResult.RESULT_ERROR, log, null);
|
||||||
|
}
|
||||||
|
} catch (PGPException e) {
|
||||||
|
throw new UnsupportedOperationException("Failed to build encryptor/decryptor!");
|
||||||
|
}
|
||||||
|
|
||||||
|
indent -= 1;
|
||||||
|
progress(R.string.progress_done, 100);
|
||||||
|
log.add(LogType.MSG_MF_SUCCESS, indent);
|
||||||
|
return new PgpEditKeyResult(OperationResult.RESULT_OK, log, new UncachedKeyRing(sKR));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static PGPSecretKey firstNonDummySecretKeyID(PGPSecretKeyRing secRing) {
|
||||||
|
Iterator<PGPSecretKey> secretKeyIterator = secRing.getSecretKeys();
|
||||||
|
|
||||||
|
while(secretKeyIterator.hasNext()) {
|
||||||
|
PGPSecretKey secretKey = secretKeyIterator.next();
|
||||||
|
if(!isDummy(secretKey)){
|
||||||
|
return secretKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/** This method returns true iff the provided keyring has a local direct key signature
|
/** This method returns true iff the provided keyring has a local direct key signature
|
||||||
* with notation data.
|
* with notation data.
|
||||||
@@ -1323,7 +1316,6 @@ public class PgpKeyOperation {
|
|||||||
} catch (PGPException e) {
|
} catch (PGPException e) {
|
||||||
|
|
||||||
// if this is the master key, error!
|
// if this is the master key, error!
|
||||||
// skipped when changing key passphrase
|
|
||||||
if (sKey.getKeyID() == masterPublicKey.getKeyID() && !isDummy(sKey)) {
|
if (sKey.getKeyID() == masterPublicKey.getKeyID() && !isDummy(sKey)) {
|
||||||
log.add(LogType.MSG_MF_ERROR_PASSPHRASE_MASTER, indent+1);
|
log.add(LogType.MSG_MF_ERROR_PASSPHRASE_MASTER, indent+1);
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||||
|
* Copyright (C) 2014 Vincent Breitmoser <v.breitmoser@mugenguild.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.sufficientlysecure.keychain.service;
|
package org.sufficientlysecure.keychain.service;
|
||||||
|
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
@@ -7,22 +26,36 @@ import org.sufficientlysecure.keychain.util.Passphrase;
|
|||||||
|
|
||||||
public class ChangeUnlockParcel implements Parcelable {
|
public class ChangeUnlockParcel implements Parcelable {
|
||||||
|
|
||||||
|
// the master key id of keyring.
|
||||||
|
public Long mMasterKeyId;
|
||||||
|
// the key fingerprint, for safety.
|
||||||
|
public byte[] mFingerprint;
|
||||||
// The new passphrase to use
|
// The new passphrase to use
|
||||||
public final Passphrase mNewPassphrase;
|
public final Passphrase mNewPassphrase;
|
||||||
|
|
||||||
public ChangeUnlockParcel(Passphrase newPassphrase) {
|
public ChangeUnlockParcel(Long masterKeyId, byte[] fingerprint, Passphrase newPassphrase) {
|
||||||
if (newPassphrase == null) {
|
if (newPassphrase == null) {
|
||||||
throw new AssertionError("newPassphrase must be non-null. THIS IS A BUG!");
|
throw new AssertionError("newPassphrase must be non-null. THIS IS A BUG!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mMasterKeyId = masterKeyId;
|
||||||
|
mFingerprint = fingerprint;
|
||||||
mNewPassphrase = newPassphrase;
|
mNewPassphrase = newPassphrase;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChangeUnlockParcel(Parcel source) {
|
public ChangeUnlockParcel(Parcel source) {
|
||||||
|
mMasterKeyId = source.readInt() != 0 ? source.readLong() : null;
|
||||||
|
mFingerprint = source.createByteArray();
|
||||||
mNewPassphrase = source.readParcelable(Passphrase.class.getClassLoader());
|
mNewPassphrase = source.readParcelable(Passphrase.class.getClassLoader());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel destination, int flags) {
|
public void writeToParcel(Parcel destination, int flags) {
|
||||||
|
destination.writeInt(mMasterKeyId == null ? 0 : 1);
|
||||||
|
if (mMasterKeyId != null) {
|
||||||
|
destination.writeLong(mMasterKeyId);
|
||||||
|
}
|
||||||
|
destination.writeByteArray(mFingerprint);
|
||||||
destination.writeParcelable(mNewPassphrase, flags);
|
destination.writeParcelable(mNewPassphrase, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,7 +75,10 @@ public class ChangeUnlockParcel implements Parcelable {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "passphrase (" + mNewPassphrase + ")";
|
String out = "mMasterKeyId: " + mMasterKeyId + "\n";
|
||||||
|
out += "passphrase (" + mNewPassphrase + ")";
|
||||||
|
|
||||||
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ import org.sufficientlysecure.keychain.operations.BackupOperation;
|
|||||||
import org.sufficientlysecure.keychain.operations.ImportOperation;
|
import org.sufficientlysecure.keychain.operations.ImportOperation;
|
||||||
import org.sufficientlysecure.keychain.operations.KeybaseVerificationOperation;
|
import org.sufficientlysecure.keychain.operations.KeybaseVerificationOperation;
|
||||||
import org.sufficientlysecure.keychain.operations.InputDataOperation;
|
import org.sufficientlysecure.keychain.operations.InputDataOperation;
|
||||||
import org.sufficientlysecure.keychain.operations.PassphraseChangeOperation;
|
import org.sufficientlysecure.keychain.operations.ChangeUnlockOperation;
|
||||||
import org.sufficientlysecure.keychain.operations.PromoteKeyOperation;
|
import org.sufficientlysecure.keychain.operations.PromoteKeyOperation;
|
||||||
import org.sufficientlysecure.keychain.operations.RevokeOperation;
|
import org.sufficientlysecure.keychain.operations.RevokeOperation;
|
||||||
import org.sufficientlysecure.keychain.operations.SignEncryptOperation;
|
import org.sufficientlysecure.keychain.operations.SignEncryptOperation;
|
||||||
@@ -117,8 +117,8 @@ public class KeychainService extends Service implements Progressable {
|
|||||||
op = new PgpDecryptVerifyOperation(outerThis, new ProviderHelper(outerThis), outerThis);
|
op = new PgpDecryptVerifyOperation(outerThis, new ProviderHelper(outerThis), outerThis);
|
||||||
} else if (inputParcel instanceof SaveKeyringParcel) {
|
} else if (inputParcel instanceof SaveKeyringParcel) {
|
||||||
op = new EditKeyOperation(outerThis, new ProviderHelper(outerThis), outerThis, mActionCanceled);
|
op = new EditKeyOperation(outerThis, new ProviderHelper(outerThis), outerThis, mActionCanceled);
|
||||||
} else if (inputParcel instanceof PassphraseChangeParcel) {
|
} else if (inputParcel instanceof ChangeUnlockParcel) {
|
||||||
op = new PassphraseChangeOperation(outerThis, new ProviderHelper(outerThis), outerThis);
|
op = new ChangeUnlockOperation(outerThis, new ProviderHelper(outerThis), outerThis);
|
||||||
} else if (inputParcel instanceof RevokeKeyringParcel) {
|
} else if (inputParcel instanceof RevokeKeyringParcel) {
|
||||||
op = new RevokeOperation(outerThis, new ProviderHelper(outerThis), outerThis);
|
op = new RevokeOperation(outerThis, new ProviderHelper(outerThis), outerThis);
|
||||||
} else if (inputParcel instanceof CertifyActionsParcel) {
|
} else if (inputParcel instanceof CertifyActionsParcel) {
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -49,8 +49,6 @@ public class SaveKeyringParcel implements Parcelable {
|
|||||||
// the key fingerprint, for safety. MUST be null for a new key.
|
// the key fingerprint, for safety. MUST be null for a new key.
|
||||||
public byte[] mFingerprint;
|
public byte[] mFingerprint;
|
||||||
|
|
||||||
public ChangeUnlockParcel mNewUnlock;
|
|
||||||
|
|
||||||
public ArrayList<String> mAddUserIds;
|
public ArrayList<String> mAddUserIds;
|
||||||
public ArrayList<WrappedUserAttribute> mAddUserAttribute;
|
public ArrayList<WrappedUserAttribute> mAddUserAttribute;
|
||||||
public ArrayList<SubkeyAdd> mAddSubKeys;
|
public ArrayList<SubkeyAdd> mAddSubKeys;
|
||||||
@@ -70,6 +68,9 @@ public class SaveKeyringParcel implements Parcelable {
|
|||||||
private boolean mUploadAtomic;
|
private boolean mUploadAtomic;
|
||||||
private String mKeyserver;
|
private String mKeyserver;
|
||||||
|
|
||||||
|
// private because we have to set other details like key id
|
||||||
|
private ChangeUnlockParcel mNewUnlock;
|
||||||
|
|
||||||
public SaveKeyringParcel() {
|
public SaveKeyringParcel() {
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
@@ -102,6 +103,14 @@ public class SaveKeyringParcel implements Parcelable {
|
|||||||
mKeyserver = keysever;
|
mKeyserver = keysever;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setNewUnlock(Passphrase passphrase) {
|
||||||
|
mNewUnlock = new ChangeUnlockParcel(mMasterKeyId, mFingerprint, passphrase);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChangeUnlockParcel getChangeUnlockParcel() {
|
||||||
|
return mNewUnlock;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isUpload() {
|
public boolean isUpload() {
|
||||||
return mUpload;
|
return mUpload;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ public class CreateKeyFinalFragment extends Fragment {
|
|||||||
2048, null, KeyFlags.AUTHENTICATION, 0L));
|
2048, null, KeyFlags.AUTHENTICATION, 0L));
|
||||||
|
|
||||||
// use empty passphrase
|
// use empty passphrase
|
||||||
saveKeyringParcel.mNewUnlock = new ChangeUnlockParcel(new Passphrase());
|
saveKeyringParcel.setNewUnlock(new Passphrase());
|
||||||
} else {
|
} else {
|
||||||
saveKeyringParcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(Algorithm.RSA,
|
saveKeyringParcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(Algorithm.RSA,
|
||||||
3072, null, KeyFlags.CERTIFY_OTHER, 0L));
|
3072, null, KeyFlags.CERTIFY_OTHER, 0L));
|
||||||
@@ -298,9 +298,9 @@ public class CreateKeyFinalFragment extends Fragment {
|
|||||||
saveKeyringParcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(Algorithm.RSA,
|
saveKeyringParcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(Algorithm.RSA,
|
||||||
3072, null, KeyFlags.ENCRYPT_COMMS | KeyFlags.ENCRYPT_STORAGE, 0L));
|
3072, null, KeyFlags.ENCRYPT_COMMS | KeyFlags.ENCRYPT_STORAGE, 0L));
|
||||||
|
|
||||||
saveKeyringParcel.mNewUnlock = createKeyActivity.mPassphrase != null
|
if(createKeyActivity.mPassphrase != null) {
|
||||||
? new ChangeUnlockParcel(createKeyActivity.mPassphrase)
|
saveKeyringParcel.setNewUnlock(createKeyActivity.mPassphrase);
|
||||||
: null;
|
}
|
||||||
}
|
}
|
||||||
String userId = KeyRing.createUserId(
|
String userId = KeyRing.createUserId(
|
||||||
new KeyRing.UserId(createKeyActivity.mName, createKeyActivity.mEmail, null)
|
new KeyRing.UserId(createKeyActivity.mName, createKeyActivity.mEmail, null)
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ import org.sufficientlysecure.keychain.provider.KeychainContract;
|
|||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets;
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException;
|
||||||
import org.sufficientlysecure.keychain.service.ChangeUnlockParcel;
|
|
||||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.SubkeyChange;
|
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.SubkeyChange;
|
||||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||||
@@ -339,9 +338,8 @@ public class EditKeyFragment extends QueueingCryptoOperationFragment<SaveKeyring
|
|||||||
Bundle data = message.getData();
|
Bundle data = message.getData();
|
||||||
|
|
||||||
// cache new returned passphrase!
|
// cache new returned passphrase!
|
||||||
mSaveKeyringParcel.mNewUnlock = new ChangeUnlockParcel(
|
mSaveKeyringParcel.setNewUnlock(
|
||||||
(Passphrase) data.getParcelable(SetPassphraseDialogFragment.MESSAGE_NEW_PASSPHRASE)
|
(Passphrase) data.getParcelable(SetPassphraseDialogFragment.MESSAGE_NEW_PASSPHRASE));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -83,8 +83,6 @@ import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
|||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException;
|
||||||
import org.sufficientlysecure.keychain.service.ChangeUnlockParcel;
|
import org.sufficientlysecure.keychain.service.ChangeUnlockParcel;
|
||||||
import org.sufficientlysecure.keychain.service.ImportKeyringParcel;
|
import org.sufficientlysecure.keychain.service.ImportKeyringParcel;
|
||||||
import org.sufficientlysecure.keychain.service.PassphraseChangeParcel;
|
|
||||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
|
||||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
||||||
import org.sufficientlysecure.keychain.ui.ViewKeyFragment.PostponeType;
|
import org.sufficientlysecure.keychain.ui.ViewKeyFragment.PostponeType;
|
||||||
import org.sufficientlysecure.keychain.ui.base.BaseSecurityTokenActivity;
|
import org.sufficientlysecure.keychain.ui.base.BaseSecurityTokenActivity;
|
||||||
@@ -132,8 +130,8 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity implements
|
|||||||
private String mKeyserver;
|
private String mKeyserver;
|
||||||
private ArrayList<ParcelableKeyRing> mKeyList;
|
private ArrayList<ParcelableKeyRing> mKeyList;
|
||||||
private CryptoOperationHelper<ImportKeyringParcel, ImportKeyResult> mImportOpHelper;
|
private CryptoOperationHelper<ImportKeyringParcel, ImportKeyResult> mImportOpHelper;
|
||||||
private CryptoOperationHelper<PassphraseChangeParcel, EditKeyResult> mEditOpHelper;
|
private CryptoOperationHelper<ChangeUnlockParcel, EditKeyResult> mEditOpHelper;
|
||||||
private PassphraseChangeParcel mPassphraseChangeParcel;
|
private ChangeUnlockParcel mChangeUnlockParcel;
|
||||||
|
|
||||||
private TextView mStatusText;
|
private TextView mStatusText;
|
||||||
private ImageView mStatusImage;
|
private ImageView mStatusImage;
|
||||||
@@ -431,13 +429,11 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void changePassword() {
|
private void changePassword() {
|
||||||
mPassphraseChangeParcel = new PassphraseChangeParcel(mMasterKeyId, mFingerprint);
|
CryptoOperationHelper.Callback<ChangeUnlockParcel, EditKeyResult> editKeyCallback
|
||||||
|
= new CryptoOperationHelper.Callback<ChangeUnlockParcel, EditKeyResult>() {
|
||||||
CryptoOperationHelper.Callback<PassphraseChangeParcel, EditKeyResult> editKeyCallback
|
|
||||||
= new CryptoOperationHelper.Callback<PassphraseChangeParcel, EditKeyResult>() {
|
|
||||||
@Override
|
@Override
|
||||||
public PassphraseChangeParcel createOperationInput() {
|
public ChangeUnlockParcel createOperationInput() {
|
||||||
return mPassphraseChangeParcel;
|
return mChangeUnlockParcel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -470,8 +466,9 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity implements
|
|||||||
if (message.what == SetPassphraseDialogFragment.MESSAGE_OKAY) {
|
if (message.what == SetPassphraseDialogFragment.MESSAGE_OKAY) {
|
||||||
Bundle data = message.getData();
|
Bundle data = message.getData();
|
||||||
|
|
||||||
// use new passphrase!
|
mChangeUnlockParcel = new ChangeUnlockParcel(
|
||||||
mPassphraseChangeParcel.mNewUnlock = new ChangeUnlockParcel(
|
mMasterKeyId,
|
||||||
|
mFingerprint,
|
||||||
(Passphrase) data.getParcelable(SetPassphraseDialogFragment.MESSAGE_NEW_PASSPHRASE)
|
(Passphrase) data.getParcelable(SetPassphraseDialogFragment.MESSAGE_NEW_PASSPHRASE)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public class CertifyOperationTest {
|
|||||||
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||||
Algorithm.ECDH, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.ENCRYPT_COMMS, 0L));
|
Algorithm.ECDH, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.ENCRYPT_COMMS, 0L));
|
||||||
parcel.mAddUserIds.add("derp");
|
parcel.mAddUserIds.add("derp");
|
||||||
parcel.mNewUnlock = new ChangeUnlockParcel(mKeyPhrase1);
|
parcel.setNewUnlock(mKeyPhrase1);
|
||||||
|
|
||||||
PgpEditKeyResult result = op.createSecretKeyRing(parcel);
|
PgpEditKeyResult result = op.createSecretKeyRing(parcel);
|
||||||
Assert.assertTrue("initial test key creation must succeed", result.success());
|
Assert.assertTrue("initial test key creation must succeed", result.success());
|
||||||
@@ -108,7 +108,7 @@ public class CertifyOperationTest {
|
|||||||
parcel.mAddUserAttribute.add(
|
parcel.mAddUserAttribute.add(
|
||||||
WrappedUserAttribute.fromSubpacket(random.nextInt(100)+1, uatdata));
|
WrappedUserAttribute.fromSubpacket(random.nextInt(100)+1, uatdata));
|
||||||
|
|
||||||
parcel.mNewUnlock = new ChangeUnlockParcel(mKeyPhrase2);
|
parcel.setNewUnlock(mKeyPhrase2);
|
||||||
|
|
||||||
PgpEditKeyResult result = op.createSecretKeyRing(parcel);
|
PgpEditKeyResult result = op.createSecretKeyRing(parcel);
|
||||||
Assert.assertTrue("initial test key creation must succeed", result.success());
|
Assert.assertTrue("initial test key creation must succeed", result.success());
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ public class ExportTest {
|
|||||||
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||||
Algorithm.ECDH, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.ENCRYPT_COMMS, 0L));
|
Algorithm.ECDH, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.ENCRYPT_COMMS, 0L));
|
||||||
parcel.mAddUserIds.add("snips");
|
parcel.mAddUserIds.add("snips");
|
||||||
parcel.mNewUnlock = new ChangeUnlockParcel(mKeyPhrase1);
|
parcel.setNewUnlock(mKeyPhrase1);
|
||||||
|
|
||||||
PgpEditKeyResult result = op.createSecretKeyRing(parcel);
|
PgpEditKeyResult result = op.createSecretKeyRing(parcel);
|
||||||
assertTrue("initial test key creation must succeed", result.success());
|
assertTrue("initial test key creation must succeed", result.success());
|
||||||
@@ -124,7 +124,7 @@ public class ExportTest {
|
|||||||
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||||
Algorithm.ECDH, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.ENCRYPT_COMMS, 0L));
|
Algorithm.ECDH, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.ENCRYPT_COMMS, 0L));
|
||||||
parcel.mAddUserIds.add("snails");
|
parcel.mAddUserIds.add("snails");
|
||||||
parcel.mNewUnlock = new ChangeUnlockParcel(new Passphrase("1234"));
|
parcel.setNewUnlock(new Passphrase("1234"));
|
||||||
|
|
||||||
PgpEditKeyResult result = op.createSecretKeyRing(parcel);
|
PgpEditKeyResult result = op.createSecretKeyRing(parcel);
|
||||||
assertTrue("initial test key creation must succeed", result.success());
|
assertTrue("initial test key creation must succeed", result.success());
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ public class PromoteKeyOperationTest {
|
|||||||
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||||
Algorithm.ECDH, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.ENCRYPT_COMMS, 0L));
|
Algorithm.ECDH, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.ENCRYPT_COMMS, 0L));
|
||||||
parcel.mAddUserIds.add("derp");
|
parcel.mAddUserIds.add("derp");
|
||||||
parcel.mNewUnlock = new ChangeUnlockParcel(mKeyPhrase1);
|
parcel.setNewUnlock(mKeyPhrase1);
|
||||||
|
|
||||||
PgpEditKeyResult result = op.createSecretKeyRing(parcel);
|
PgpEditKeyResult result = op.createSecretKeyRing(parcel);
|
||||||
Assert.assertTrue("initial test key creation must succeed", result.success());
|
Assert.assertTrue("initial test key creation must succeed", result.success());
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||||
Algorithm.ECDH, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.ENCRYPT_COMMS, 0L));
|
Algorithm.ECDH, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.ENCRYPT_COMMS, 0L));
|
||||||
parcel.mAddUserIds.add("bloom");
|
parcel.mAddUserIds.add("bloom");
|
||||||
parcel.mNewUnlock = new ChangeUnlockParcel(mKeyPhrase1);
|
parcel.setNewUnlock(mKeyPhrase1);
|
||||||
|
|
||||||
PgpEditKeyResult result = op.createSecretKeyRing(parcel);
|
PgpEditKeyResult result = op.createSecretKeyRing(parcel);
|
||||||
Assert.assertTrue("initial test key creation must succeed", result.success());
|
Assert.assertTrue("initial test key creation must succeed", result.success());
|
||||||
@@ -121,7 +121,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||||
Algorithm.ECDH, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.ENCRYPT_COMMS, 0L));
|
Algorithm.ECDH, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.ENCRYPT_COMMS, 0L));
|
||||||
parcel.mAddUserIds.add("belle");
|
parcel.mAddUserIds.add("belle");
|
||||||
parcel.mNewUnlock = new ChangeUnlockParcel(mKeyPhrase2);
|
parcel.setNewUnlock(mKeyPhrase2);
|
||||||
|
|
||||||
PgpEditKeyResult result = op.createSecretKeyRing(parcel);
|
PgpEditKeyResult result = op.createSecretKeyRing(parcel);
|
||||||
Assert.assertTrue("initial test key creation must succeed", result.success());
|
Assert.assertTrue("initial test key creation must succeed", result.success());
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ public class PgpKeyOperationTest {
|
|||||||
parcel.mAddUserAttribute.add(uat);
|
parcel.mAddUserAttribute.add(uat);
|
||||||
}
|
}
|
||||||
|
|
||||||
parcel.mNewUnlock = new ChangeUnlockParcel(passphrase);
|
parcel.setNewUnlock(passphrase);
|
||||||
PgpKeyOperation op = new PgpKeyOperation(null);
|
PgpKeyOperation op = new PgpKeyOperation(null);
|
||||||
|
|
||||||
PgpEditKeyResult result = op.createSecretKeyRing(parcel);
|
PgpEditKeyResult result = op.createSecretKeyRing(parcel);
|
||||||
@@ -149,7 +149,7 @@ public class PgpKeyOperationTest {
|
|||||||
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||||
Algorithm.RSA, new Random().nextInt(256)+255, null, KeyFlags.CERTIFY_OTHER, 0L));
|
Algorithm.RSA, new Random().nextInt(256)+255, null, KeyFlags.CERTIFY_OTHER, 0L));
|
||||||
parcel.mAddUserIds.add("shy");
|
parcel.mAddUserIds.add("shy");
|
||||||
parcel.mNewUnlock = new ChangeUnlockParcel(passphrase);
|
parcel.setNewUnlock(passphrase);
|
||||||
|
|
||||||
assertFailure("creating ring with < 2048 bit keysize should fail", parcel,
|
assertFailure("creating ring with < 2048 bit keysize should fail", parcel,
|
||||||
LogType.MSG_CR_ERROR_KEYSIZE_2048);
|
LogType.MSG_CR_ERROR_KEYSIZE_2048);
|
||||||
@@ -160,7 +160,7 @@ public class PgpKeyOperationTest {
|
|||||||
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||||
Algorithm.ELGAMAL, 2048, null, KeyFlags.CERTIFY_OTHER, 0L));
|
Algorithm.ELGAMAL, 2048, null, KeyFlags.CERTIFY_OTHER, 0L));
|
||||||
parcel.mAddUserIds.add("shy");
|
parcel.mAddUserIds.add("shy");
|
||||||
parcel.mNewUnlock = new ChangeUnlockParcel(passphrase);
|
parcel.setNewUnlock(passphrase);
|
||||||
|
|
||||||
assertFailure("creating ring with ElGamal master key should fail", parcel,
|
assertFailure("creating ring with ElGamal master key should fail", parcel,
|
||||||
LogType.MSG_CR_ERROR_FLAGS_ELGAMAL);
|
LogType.MSG_CR_ERROR_FLAGS_ELGAMAL);
|
||||||
@@ -171,7 +171,7 @@ public class PgpKeyOperationTest {
|
|||||||
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||||
Algorithm.ECDSA, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.CERTIFY_OTHER, null));
|
Algorithm.ECDSA, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.CERTIFY_OTHER, null));
|
||||||
parcel.mAddUserIds.add("lotus");
|
parcel.mAddUserIds.add("lotus");
|
||||||
parcel.mNewUnlock = new ChangeUnlockParcel(passphrase);
|
parcel.setNewUnlock(passphrase);
|
||||||
|
|
||||||
assertFailure("creating master key with null expiry should fail", parcel,
|
assertFailure("creating master key with null expiry should fail", parcel,
|
||||||
LogType.MSG_CR_ERROR_NULL_EXPIRY);
|
LogType.MSG_CR_ERROR_NULL_EXPIRY);
|
||||||
@@ -182,7 +182,7 @@ public class PgpKeyOperationTest {
|
|||||||
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||||
Algorithm.ECDSA, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.SIGN_DATA, 0L));
|
Algorithm.ECDSA, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.SIGN_DATA, 0L));
|
||||||
parcel.mAddUserIds.add("shy");
|
parcel.mAddUserIds.add("shy");
|
||||||
parcel.mNewUnlock = new ChangeUnlockParcel(passphrase);
|
parcel.setNewUnlock(passphrase);
|
||||||
|
|
||||||
assertFailure("creating ring with non-certifying master key should fail", parcel,
|
assertFailure("creating ring with non-certifying master key should fail", parcel,
|
||||||
LogType.MSG_CR_ERROR_NO_CERTIFY);
|
LogType.MSG_CR_ERROR_NO_CERTIFY);
|
||||||
@@ -192,7 +192,7 @@ public class PgpKeyOperationTest {
|
|||||||
parcel.reset();
|
parcel.reset();
|
||||||
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||||
Algorithm.ECDSA, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.CERTIFY_OTHER, 0L));
|
Algorithm.ECDSA, 0, SaveKeyringParcel.Curve.NIST_P256, KeyFlags.CERTIFY_OTHER, 0L));
|
||||||
parcel.mNewUnlock = new ChangeUnlockParcel(passphrase);
|
parcel.setNewUnlock(passphrase);
|
||||||
|
|
||||||
assertFailure("creating ring without user ids should fail", parcel,
|
assertFailure("creating ring without user ids should fail", parcel,
|
||||||
LogType.MSG_CR_ERROR_NO_USER_ID);
|
LogType.MSG_CR_ERROR_NO_USER_ID);
|
||||||
@@ -201,7 +201,7 @@ public class PgpKeyOperationTest {
|
|||||||
{
|
{
|
||||||
parcel.reset();
|
parcel.reset();
|
||||||
parcel.mAddUserIds.add("shy");
|
parcel.mAddUserIds.add("shy");
|
||||||
parcel.mNewUnlock = new ChangeUnlockParcel(passphrase);
|
parcel.setNewUnlock(passphrase);
|
||||||
|
|
||||||
assertFailure("creating ring with no master key should fail", parcel,
|
assertFailure("creating ring with no master key should fail", parcel,
|
||||||
LogType.MSG_CR_ERROR_NO_MASTER);
|
LogType.MSG_CR_ERROR_NO_MASTER);
|
||||||
@@ -841,7 +841,7 @@ public class PgpKeyOperationTest {
|
|||||||
|
|
||||||
parcelKey.mAddUserIds.add("yubikey");
|
parcelKey.mAddUserIds.add("yubikey");
|
||||||
|
|
||||||
parcelKey.mNewUnlock = new ChangeUnlockParcel(passphrase);
|
parcelKey.setNewUnlock(passphrase);
|
||||||
PgpKeyOperation opSecurityToken = new PgpKeyOperation(null);
|
PgpKeyOperation opSecurityToken = new PgpKeyOperation(null);
|
||||||
|
|
||||||
PgpEditKeyResult resultSecurityToken = opSecurityToken.createSecretKeyRing(parcelKey);
|
PgpEditKeyResult resultSecurityToken = opSecurityToken.createSecretKeyRing(parcelKey);
|
||||||
@@ -1156,7 +1156,7 @@ public class PgpKeyOperationTest {
|
|||||||
public void testPassphraseChange() throws Exception {
|
public void testPassphraseChange() throws Exception {
|
||||||
|
|
||||||
// change passphrase to empty
|
// change passphrase to empty
|
||||||
parcel.mNewUnlock = new ChangeUnlockParcel(new Passphrase());
|
parcel.setNewUnlock(new Passphrase());
|
||||||
// note that canonicalization here necessarily strips the empty notation packet
|
// note that canonicalization here necessarily strips the empty notation packet
|
||||||
UncachedKeyRing modified = applyModificationWithChecks(parcel, ring, onlyA, onlyB, cryptoInput);
|
UncachedKeyRing modified = applyModificationWithChecks(parcel, ring, onlyA, onlyB, cryptoInput);
|
||||||
|
|
||||||
@@ -1171,7 +1171,7 @@ public class PgpKeyOperationTest {
|
|||||||
// modify keyring, change to non-empty passphrase
|
// modify keyring, change to non-empty passphrase
|
||||||
Passphrase otherPassphrase = TestingUtils.genPassphrase(true);
|
Passphrase otherPassphrase = TestingUtils.genPassphrase(true);
|
||||||
CryptoInputParcel otherCryptoInput = new CryptoInputParcel(otherPassphrase);
|
CryptoInputParcel otherCryptoInput = new CryptoInputParcel(otherPassphrase);
|
||||||
parcel.mNewUnlock = new ChangeUnlockParcel(otherPassphrase);
|
parcel.setNewUnlock(otherPassphrase);
|
||||||
modified = applyModificationWithChecks(parcel, modified, onlyA, onlyB,
|
modified = applyModificationWithChecks(parcel, modified, onlyA, onlyB,
|
||||||
new CryptoInputParcel(new Date(), new Passphrase()));
|
new CryptoInputParcel(new Date(), new Passphrase()));
|
||||||
|
|
||||||
@@ -1197,7 +1197,7 @@ public class PgpKeyOperationTest {
|
|||||||
PacketTags.SECRET_SUBKEY, sKeyNoPassphrase.tag);
|
PacketTags.SECRET_SUBKEY, sKeyNoPassphrase.tag);
|
||||||
|
|
||||||
Passphrase otherPassphrase2 = TestingUtils.genPassphrase(true);
|
Passphrase otherPassphrase2 = TestingUtils.genPassphrase(true);
|
||||||
parcel.mNewUnlock = new ChangeUnlockParcel(otherPassphrase2);
|
parcel.setNewUnlock(otherPassphrase2);
|
||||||
{
|
{
|
||||||
// if we replace a secret key with one without passphrase
|
// if we replace a secret key with one without passphrase
|
||||||
modified = KeyringTestingHelper.removePacket(modified, sKeyNoPassphrase.position);
|
modified = KeyringTestingHelper.removePacket(modified, sKeyNoPassphrase.position);
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ public class UncachedKeyringCanonicalizeTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// passphrase is tested in PgpKeyOperationTest, just use empty here
|
// passphrase is tested in PgpKeyOperationTest, just use empty here
|
||||||
parcel.mNewUnlock = new ChangeUnlockParcel(new Passphrase());
|
parcel.setNewUnlock(new Passphrase());
|
||||||
PgpKeyOperation op = new PgpKeyOperation(null);
|
PgpKeyOperation op = new PgpKeyOperation(null);
|
||||||
|
|
||||||
PgpEditKeyResult result = op.createSecretKeyRing(parcel);
|
PgpEditKeyResult result = op.createSecretKeyRing(parcel);
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ public class UncachedKeyringMergeTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// passphrase is tested in PgpKeyOperationTest, just use empty here
|
// passphrase is tested in PgpKeyOperationTest, just use empty here
|
||||||
parcel.mNewUnlock = new ChangeUnlockParcel(new Passphrase());
|
parcel.setNewUnlock(new Passphrase());
|
||||||
PgpKeyOperation op = new PgpKeyOperation(null);
|
PgpKeyOperation op = new PgpKeyOperation(null);
|
||||||
|
|
||||||
OperationResult.OperationLog log = new OperationResult.OperationLog();
|
OperationResult.OperationLog log = new OperationResult.OperationLog();
|
||||||
@@ -131,7 +131,7 @@ public class UncachedKeyringMergeTest {
|
|||||||
|
|
||||||
parcel.mAddUserIds.add("shy");
|
parcel.mAddUserIds.add("shy");
|
||||||
// passphrase is tested in PgpKeyOperationTest, just use empty here
|
// passphrase is tested in PgpKeyOperationTest, just use empty here
|
||||||
parcel.mNewUnlock = new ChangeUnlockParcel(new Passphrase());
|
parcel.setNewUnlock(new Passphrase());
|
||||||
PgpKeyOperation op = new PgpKeyOperation(null);
|
PgpKeyOperation op = new PgpKeyOperation(null);
|
||||||
|
|
||||||
OperationResult.OperationLog log = new OperationResult.OperationLog();
|
OperationResult.OperationLog log = new OperationResult.OperationLog();
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public class UncachedKeyringTest {
|
|||||||
parcel.mAddUserAttribute.add(uat);
|
parcel.mAddUserAttribute.add(uat);
|
||||||
}
|
}
|
||||||
// passphrase is tested in PgpKeyOperationTest, just use empty here
|
// passphrase is tested in PgpKeyOperationTest, just use empty here
|
||||||
parcel.mNewUnlock = new ChangeUnlockParcel(new Passphrase());
|
parcel.setNewUnlock(new Passphrase());
|
||||||
PgpKeyOperation op = new PgpKeyOperation(null);
|
PgpKeyOperation op = new PgpKeyOperation(null);
|
||||||
|
|
||||||
PgpEditKeyResult result = op.createSecretKeyRing(parcel);
|
PgpEditKeyResult result = op.createSecretKeyRing(parcel);
|
||||||
|
|||||||
Reference in New Issue
Block a user