use autovalue for ChangeUnlockParcel
This commit is contained in:
@@ -47,7 +47,7 @@ public class ChangeUnlockOperation extends BaseReadWriteOperation<ChangeUnlockPa
|
|||||||
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 (unlockParcel == null || unlockParcel.mMasterKeyId == null) {
|
if (unlockParcel == null || unlockParcel.getMasterKeyId() == 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);
|
||||||
}
|
}
|
||||||
@@ -60,10 +60,10 @@ public class ChangeUnlockOperation extends BaseReadWriteOperation<ChangeUnlockPa
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
log.add(OperationResult.LogType.MSG_ED_FETCHING, 1,
|
log.add(OperationResult.LogType.MSG_ED_FETCHING, 1,
|
||||||
KeyFormattingUtils.convertKeyIdToHex(unlockParcel.mMasterKeyId));
|
KeyFormattingUtils.convertKeyIdToHex(unlockParcel.getMasterKeyId()));
|
||||||
|
|
||||||
CanonicalizedSecretKeyRing secRing =
|
CanonicalizedSecretKeyRing secRing =
|
||||||
mKeyRepository.getCanonicalizedSecretKeyRing(unlockParcel.mMasterKeyId);
|
mKeyRepository.getCanonicalizedSecretKeyRing(unlockParcel.getMasterKeyId());
|
||||||
modifyResult = keyOperations.modifyKeyRingPassphrase(secRing, cryptoInput, unlockParcel);
|
modifyResult = keyOperations.modifyKeyRingPassphrase(secRing, cryptoInput, unlockParcel);
|
||||||
|
|
||||||
if (modifyResult.isPending()) {
|
if (modifyResult.isPending()) {
|
||||||
|
|||||||
@@ -1064,7 +1064,7 @@ public class PgpKeyOperation {
|
|||||||
indent += 1;
|
indent += 1;
|
||||||
|
|
||||||
sKR = applyNewPassphrase(sKR, masterPublicKey, cryptoInput.getPassphrase(),
|
sKR = applyNewPassphrase(sKR, masterPublicKey, cryptoInput.getPassphrase(),
|
||||||
saveParcel.getChangeUnlockParcel().mNewPassphrase, log, indent);
|
saveParcel.getChangeUnlockParcel().getNewPassphrase(), 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);
|
||||||
@@ -1204,7 +1204,8 @@ public class PgpKeyOperation {
|
|||||||
OperationLog log = new OperationLog();
|
OperationLog log = new OperationLog();
|
||||||
int indent = 0;
|
int indent = 0;
|
||||||
|
|
||||||
if (changeUnlockParcel.mMasterKeyId == null || changeUnlockParcel.mMasterKeyId != wsKR.getMasterKeyId()) {
|
Long masterKeyId = changeUnlockParcel.getMasterKeyId();
|
||||||
|
if (masterKeyId == null || masterKeyId != wsKR.getMasterKeyId()) {
|
||||||
log.add(LogType.MSG_MF_ERROR_KEYID, indent);
|
log.add(LogType.MSG_MF_ERROR_KEYID, indent);
|
||||||
return new PgpEditKeyResult(PgpEditKeyResult.RESULT_ERROR, log, null);
|
return new PgpEditKeyResult(PgpEditKeyResult.RESULT_ERROR, log, null);
|
||||||
}
|
}
|
||||||
@@ -1219,7 +1220,7 @@ public class PgpKeyOperation {
|
|||||||
PGPSecretKey masterSecretKey = sKR.getSecretKey();
|
PGPSecretKey masterSecretKey = sKR.getSecretKey();
|
||||||
PGPPublicKey masterPublicKey = masterSecretKey.getPublicKey();
|
PGPPublicKey masterPublicKey = masterSecretKey.getPublicKey();
|
||||||
// Make sure the fingerprint matches
|
// Make sure the fingerprint matches
|
||||||
if (changeUnlockParcel.mFingerprint == null || !Arrays.equals(changeUnlockParcel.mFingerprint,
|
if (changeUnlockParcel.getFingerprint()== null || !Arrays.equals(changeUnlockParcel.getFingerprint(),
|
||||||
masterSecretKey.getPublicKey().getFingerprint())) {
|
masterSecretKey.getPublicKey().getFingerprint())) {
|
||||||
log.add(LogType.MSG_MF_ERROR_FINGERPRINT, indent);
|
log.add(LogType.MSG_MF_ERROR_FINGERPRINT, indent);
|
||||||
return new PgpEditKeyResult(PgpEditKeyResult.RESULT_ERROR, log, null);
|
return new PgpEditKeyResult(PgpEditKeyResult.RESULT_ERROR, log, null);
|
||||||
@@ -1245,7 +1246,7 @@ public class PgpKeyOperation {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
sKR = applyNewPassphrase(sKR, masterPublicKey, cryptoInput.getPassphrase(),
|
sKR = applyNewPassphrase(sKR, masterPublicKey, cryptoInput.getPassphrase(),
|
||||||
changeUnlockParcel.mNewPassphrase, log, indent);
|
changeUnlockParcel.getNewPassphrase(), 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);
|
||||||
|
|||||||
@@ -19,70 +19,28 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.service;
|
package org.sufficientlysecure.keychain.service;
|
||||||
|
|
||||||
import android.os.Parcel;
|
|
||||||
import android.os.Parcelable;
|
|
||||||
|
|
||||||
|
import android.os.Parcelable;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||||
|
|
||||||
public class ChangeUnlockParcel implements Parcelable {
|
@AutoValue
|
||||||
|
public abstract class ChangeUnlockParcel implements Parcelable {
|
||||||
|
@Nullable
|
||||||
|
public abstract Long getMasterKeyId();
|
||||||
|
@Nullable
|
||||||
|
public abstract byte[] getFingerprint();
|
||||||
|
public abstract Passphrase getNewPassphrase();
|
||||||
|
|
||||||
// the master key id of keyring.
|
|
||||||
public Long mMasterKeyId;
|
|
||||||
// the key fingerprint, for safety.
|
|
||||||
public byte[] mFingerprint;
|
|
||||||
// The new passphrase to use
|
|
||||||
public final Passphrase mNewPassphrase;
|
|
||||||
|
|
||||||
public ChangeUnlockParcel(Passphrase newPassphrase) {
|
public static ChangeUnlockParcel createChangeUnlockParcel(Long masterKeyId, byte[] fingerprint,
|
||||||
mNewPassphrase = newPassphrase;
|
Passphrase newPassphrase) {
|
||||||
|
return new AutoValue_ChangeUnlockParcel(masterKeyId, fingerprint, newPassphrase);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChangeUnlockParcel(Long masterKeyId, byte[] fingerprint, Passphrase newPassphrase) {
|
public static ChangeUnlockParcel createUnLockParcelForNewKey(Passphrase newPassphrase) {
|
||||||
if (newPassphrase == null) {
|
return new AutoValue_ChangeUnlockParcel(null, null, newPassphrase);
|
||||||
throw new AssertionError("newPassphrase must be non-null. THIS IS A BUG!");
|
|
||||||
}
|
|
||||||
|
|
||||||
mMasterKeyId = masterKeyId;
|
|
||||||
mFingerprint = fingerprint;
|
|
||||||
mNewPassphrase = newPassphrase;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChangeUnlockParcel(Parcel source) {
|
|
||||||
mMasterKeyId = source.readInt() != 0 ? source.readLong() : null;
|
|
||||||
mFingerprint = source.createByteArray();
|
|
||||||
mNewPassphrase = source.readParcelable(Passphrase.class.getClassLoader());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
@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() {
|
|
||||||
String out = "mMasterKeyId: " + mMasterKeyId + "\n";
|
|
||||||
out += "passphrase (" + mNewPassphrase + ")";
|
|
||||||
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,10 +109,6 @@ public class SaveKeyringParcel implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ChangeUnlockParcel getChangeUnlockParcel() {
|
public ChangeUnlockParcel getChangeUnlockParcel() {
|
||||||
if(mNewUnlock != null) {
|
|
||||||
mNewUnlock.mMasterKeyId = mMasterKeyId;
|
|
||||||
mNewUnlock.mFingerprint = mFingerprint;
|
|
||||||
}
|
|
||||||
return mNewUnlock;
|
return mNewUnlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -307,12 +307,13 @@ public class CreateKeyFinalFragment extends Fragment {
|
|||||||
createKeyActivity.mSecurityTokenAuth.addToSaveKeyringParcel(saveKeyringParcel, KeyFlags.AUTHENTICATION);
|
createKeyActivity.mSecurityTokenAuth.addToSaveKeyringParcel(saveKeyringParcel, KeyFlags.AUTHENTICATION);
|
||||||
|
|
||||||
// use empty passphrase
|
// use empty passphrase
|
||||||
saveKeyringParcel.setNewUnlock(new ChangeUnlockParcel(new Passphrase()));
|
saveKeyringParcel.setNewUnlock(ChangeUnlockParcel.createUnLockParcelForNewKey(new Passphrase()));
|
||||||
} else {
|
} else {
|
||||||
Constants.addDefaultSubkeys(saveKeyringParcel);
|
Constants.addDefaultSubkeys(saveKeyringParcel);
|
||||||
|
|
||||||
if (createKeyActivity.mPassphrase != null) {
|
if (createKeyActivity.mPassphrase != null) {
|
||||||
saveKeyringParcel.setNewUnlock(new ChangeUnlockParcel(createKeyActivity.mPassphrase));
|
saveKeyringParcel.setNewUnlock(
|
||||||
|
ChangeUnlockParcel.createUnLockParcelForNewKey(createKeyActivity.mPassphrase));
|
||||||
} else {
|
} else {
|
||||||
saveKeyringParcel.setNewUnlock(null);
|
saveKeyringParcel.setNewUnlock(null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -341,7 +341,8 @@ public class EditKeyFragment extends QueueingCryptoOperationFragment<SaveKeyring
|
|||||||
Bundle data = message.getData();
|
Bundle data = message.getData();
|
||||||
|
|
||||||
// cache new returned passphrase!
|
// cache new returned passphrase!
|
||||||
mSaveKeyringParcel.setNewUnlock(new ChangeUnlockParcel(
|
mSaveKeyringParcel.setNewUnlock(ChangeUnlockParcel.createChangeUnlockParcel(
|
||||||
|
mSaveKeyringParcel.mMasterKeyId, mSaveKeyringParcel.mFingerprint,
|
||||||
(Passphrase) data.getParcelable(SetPassphraseDialogFragment.MESSAGE_NEW_PASSPHRASE)));
|
(Passphrase) data.getParcelable(SetPassphraseDialogFragment.MESSAGE_NEW_PASSPHRASE)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -474,9 +474,8 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity implements
|
|||||||
Bundle data = message.getData();
|
Bundle data = message.getData();
|
||||||
|
|
||||||
// use new passphrase!
|
// use new passphrase!
|
||||||
mChangeUnlockParcel = new ChangeUnlockParcel(
|
mChangeUnlockParcel = ChangeUnlockParcel.createChangeUnlockParcel(
|
||||||
mMasterKeyId,
|
mMasterKeyId, mFingerprint,
|
||||||
mFingerprint,
|
|
||||||
(Passphrase) data.getParcelable(SetPassphraseDialogFragment.MESSAGE_NEW_PASSPHRASE)
|
(Passphrase) data.getParcelable(SetPassphraseDialogFragment.MESSAGE_NEW_PASSPHRASE)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ public class BackupOperationTest {
|
|||||||
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.setNewUnlock(new ChangeUnlockParcel(mKeyPhrase1));
|
parcel.setNewUnlock(ChangeUnlockParcel.createUnLockParcelForNewKey(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());
|
||||||
@@ -120,7 +120,7 @@ public class BackupOperationTest {
|
|||||||
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.setNewUnlock(new ChangeUnlockParcel(new Passphrase("1234")));
|
parcel.setNewUnlock(ChangeUnlockParcel.createUnLockParcelForNewKey(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 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.setNewUnlock(new ChangeUnlockParcel(mKeyPhrase1));
|
parcel.setNewUnlock(ChangeUnlockParcel.createUnLockParcelForNewKey(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());
|
||||||
@@ -104,7 +104,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.setNewUnlock(new ChangeUnlockParcel(mKeyPhrase2));
|
parcel.setNewUnlock(ChangeUnlockParcel.createUnLockParcelForNewKey(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());
|
||||||
|
|||||||
@@ -76,7 +76,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.setNewUnlock(new ChangeUnlockParcel(mKeyPhrase1));
|
parcel.setNewUnlock(ChangeUnlockParcel.createUnLockParcelForNewKey(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());
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ public class PgpKeyOperationTest {
|
|||||||
parcel.mAddUserAttribute.add(uat);
|
parcel.mAddUserAttribute.add(uat);
|
||||||
}
|
}
|
||||||
|
|
||||||
parcel.setNewUnlock(new ChangeUnlockParcel(passphrase));
|
parcel.setNewUnlock(ChangeUnlockParcel.createUnLockParcelForNewKey(passphrase));
|
||||||
PgpKeyOperation op = new PgpKeyOperation(null);
|
PgpKeyOperation op = new PgpKeyOperation(null);
|
||||||
|
|
||||||
PgpEditKeyResult result = op.createSecretKeyRing(parcel);
|
PgpEditKeyResult result = op.createSecretKeyRing(parcel);
|
||||||
@@ -146,7 +146,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.setNewUnlock(new ChangeUnlockParcel(passphrase));
|
parcel.setNewUnlock(ChangeUnlockParcel.createUnLockParcelForNewKey(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);
|
||||||
@@ -157,7 +157,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.setNewUnlock(new ChangeUnlockParcel(passphrase));
|
parcel.setNewUnlock(ChangeUnlockParcel.createUnLockParcelForNewKey(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);
|
||||||
@@ -168,7 +168,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.setNewUnlock(new ChangeUnlockParcel(passphrase));
|
parcel.setNewUnlock(ChangeUnlockParcel.createUnLockParcelForNewKey(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);
|
||||||
@@ -179,7 +179,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.setNewUnlock(new ChangeUnlockParcel(passphrase));
|
parcel.setNewUnlock(ChangeUnlockParcel.createUnLockParcelForNewKey(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);
|
||||||
@@ -189,7 +189,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.setNewUnlock(new ChangeUnlockParcel(passphrase));
|
parcel.setNewUnlock(ChangeUnlockParcel.createUnLockParcelForNewKey(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);
|
||||||
@@ -198,7 +198,7 @@ public class PgpKeyOperationTest {
|
|||||||
{
|
{
|
||||||
parcel.reset();
|
parcel.reset();
|
||||||
parcel.mAddUserIds.add("shy");
|
parcel.mAddUserIds.add("shy");
|
||||||
parcel.setNewUnlock(new ChangeUnlockParcel(passphrase));
|
parcel.setNewUnlock(ChangeUnlockParcel.createUnLockParcelForNewKey(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);
|
||||||
@@ -839,7 +839,7 @@ public class PgpKeyOperationTest {
|
|||||||
|
|
||||||
parcelKey.mAddUserIds.add("yubikey");
|
parcelKey.mAddUserIds.add("yubikey");
|
||||||
|
|
||||||
parcelKey.setNewUnlock(new ChangeUnlockParcel(passphrase));
|
parcelKey.setNewUnlock(ChangeUnlockParcel.createUnLockParcelForNewKey(passphrase));
|
||||||
PgpKeyOperation opSecurityToken = new PgpKeyOperation(null);
|
PgpKeyOperation opSecurityToken = new PgpKeyOperation(null);
|
||||||
|
|
||||||
PgpEditKeyResult resultSecurityToken = opSecurityToken.createSecretKeyRing(parcelKey);
|
PgpEditKeyResult resultSecurityToken = opSecurityToken.createSecretKeyRing(parcelKey);
|
||||||
@@ -1145,7 +1145,7 @@ public class PgpKeyOperationTest {
|
|||||||
public void testPassphraseChange() throws Exception {
|
public void testPassphraseChange() throws Exception {
|
||||||
|
|
||||||
// change passphrase to empty
|
// change passphrase to empty
|
||||||
parcel.setNewUnlock(new ChangeUnlockParcel(new Passphrase()));
|
parcel.setNewUnlock(ChangeUnlockParcel.createUnLockParcelForNewKey(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);
|
||||||
|
|
||||||
@@ -1160,7 +1160,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 = CryptoInputParcel.createCryptoInputParcel(otherPassphrase);
|
CryptoInputParcel otherCryptoInput = CryptoInputParcel.createCryptoInputParcel(otherPassphrase);
|
||||||
parcel.setNewUnlock(new ChangeUnlockParcel(otherPassphrase));
|
parcel.setNewUnlock(ChangeUnlockParcel.createUnLockParcelForNewKey(otherPassphrase));
|
||||||
modified = applyModificationWithChecks(parcel, modified, onlyA, onlyB,
|
modified = applyModificationWithChecks(parcel, modified, onlyA, onlyB,
|
||||||
CryptoInputParcel.createCryptoInputParcel(new Date(), new Passphrase()));
|
CryptoInputParcel.createCryptoInputParcel(new Date(), new Passphrase()));
|
||||||
|
|
||||||
@@ -1186,7 +1186,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.setNewUnlock(new ChangeUnlockParcel(otherPassphrase2));
|
parcel.setNewUnlock(ChangeUnlockParcel.createUnLockParcelForNewKey(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);
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ public class UncachedKeyringCanonicalizeTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// passphrase is tested in PgpKeyOperationTest, just use empty here
|
// passphrase is tested in PgpKeyOperationTest, just use empty here
|
||||||
parcel.setNewUnlock(new ChangeUnlockParcel(new Passphrase()));
|
parcel.setNewUnlock(ChangeUnlockParcel.createUnLockParcelForNewKey(new Passphrase()));
|
||||||
PgpKeyOperation op = new PgpKeyOperation(null);
|
PgpKeyOperation op = new PgpKeyOperation(null);
|
||||||
|
|
||||||
PgpEditKeyResult result = op.createSecretKeyRing(parcel);
|
PgpEditKeyResult result = op.createSecretKeyRing(parcel);
|
||||||
|
|||||||
@@ -54,12 +54,6 @@ import org.sufficientlysecure.keychain.support.KeyringTestingHelper.RawPacket;
|
|||||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||||
import org.sufficientlysecure.keychain.util.ProgressScaler;
|
import org.sufficientlysecure.keychain.util.ProgressScaler;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.security.Security;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
/** Tests for the UncachedKeyring.merge method.
|
/** Tests for the UncachedKeyring.merge method.
|
||||||
*
|
*
|
||||||
@@ -117,7 +111,7 @@ public class UncachedKeyringMergeTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// passphrase is tested in PgpKeyOperationTest, just use empty here
|
// passphrase is tested in PgpKeyOperationTest, just use empty here
|
||||||
parcel.setNewUnlock(new ChangeUnlockParcel(new Passphrase()));
|
parcel.setNewUnlock(ChangeUnlockParcel.createUnLockParcelForNewKey(new Passphrase()));
|
||||||
PgpKeyOperation op = new PgpKeyOperation(null);
|
PgpKeyOperation op = new PgpKeyOperation(null);
|
||||||
|
|
||||||
OperationResult.OperationLog log = new OperationResult.OperationLog();
|
OperationResult.OperationLog log = new OperationResult.OperationLog();
|
||||||
@@ -134,7 +128,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.setNewUnlock(new ChangeUnlockParcel(new Passphrase()));
|
parcel.setNewUnlock(ChangeUnlockParcel.createUnLockParcelForNewKey(new Passphrase()));
|
||||||
PgpKeyOperation op = new PgpKeyOperation(null);
|
PgpKeyOperation op = new PgpKeyOperation(null);
|
||||||
|
|
||||||
OperationResult.OperationLog log = new OperationResult.OperationLog();
|
OperationResult.OperationLog log = new OperationResult.OperationLog();
|
||||||
|
|||||||
@@ -73,7 +73,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.setNewUnlock(new ChangeUnlockParcel(new Passphrase()));
|
parcel.setNewUnlock(ChangeUnlockParcel.createUnLockParcelForNewKey(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