Adding keytocard flag to SubkeyChange: UI sets this flag to initiate keytocard; operation unsets it and fills in dummyDivert to finish it.

This commit is contained in:
Joey Castillo
2015-05-13 06:01:42 -04:00
parent d21fb77336
commit 28b9068ae0
4 changed files with 45 additions and 32 deletions

View File

@@ -95,8 +95,8 @@ public class SaveKeyringParcel implements Parcelable {
}
for (SubkeyChange change : mChangeSubKeys) {
if (change.mRecertify || change.mFlags != null || change.mExpiry != null ||
(change.mDummyDivert != null && change.mDummyDivert.length == 0)) {
if (change.mRecertify || change.mFlags != null || change.mExpiry != null
|| change.mMoveKeyToCard) {
return false;
}
}
@@ -143,6 +143,8 @@ public class SaveKeyringParcel implements Parcelable {
public boolean mRecertify;
// if this flag is true, the subkey should be changed to a stripped key
public boolean mDummyStrip;
// if this flag is true, the subkey should be moved to a card
public boolean mMoveKeyToCard;
// if this is non-null, the subkey will be changed to a divert-to-card
// key for the given serial number
public byte[] mDummyDivert;
@@ -174,12 +176,25 @@ public class SaveKeyringParcel implements Parcelable {
mDummyDivert = dummyDivert;
}
public SubkeyChange(long keyId, boolean dummyStrip, boolean moveKeyToCard) {
this(keyId, null, null);
// these flags are mutually exclusive!
if (dummyStrip && moveKeyToCard) {
throw new AssertionError(
"cannot set strip and keytocard flags at the same time - this is a bug!");
}
mDummyStrip = dummyStrip;
mMoveKeyToCard = moveKeyToCard;
}
@Override
public String toString() {
String out = "mKeyId: " + mKeyId + ", ";
out += "mFlags: " + mFlags + ", ";
out += "mExpiry: " + mExpiry + ", ";
out += "mDummyStrip: " + mDummyStrip + ", ";
out += "mMoveKeyToCard: " + mMoveKeyToCard + ", ";
out += "mDummyDivert: [" + (mDummyDivert == null ? 0 : mDummyDivert.length) + " bytes]";
return out;