token-import: bind only relevant subkeys
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
package org.sufficientlysecure.keychain.operations;
|
||||
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import android.content.Context;
|
||||
@@ -77,6 +78,11 @@ public class PromoteKeyOperation extends BaseReadWriteOperation<PromoteKeyringPa
|
||||
// sort for binary search
|
||||
for (CanonicalizedPublicKey key : pubRing.publicKeyIterator()) {
|
||||
long subKeyId = key.getKeyId();
|
||||
|
||||
// we ignore key ids from empty fingerprints here
|
||||
if (subKeyId == 0L) {
|
||||
continue;
|
||||
}
|
||||
if (naiveIndexOf(subKeyIds, subKeyId) != null) {
|
||||
log.add(LogType.MSG_PR_SUBKEY_MATCH, 1,
|
||||
KeyFormattingUtils.convertKeyIdToHex(subKeyId));
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.os.Parcelable;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import org.sufficientlysecure.keychain.securitytoken.SecurityTokenInfo;
|
||||
|
||||
|
||||
@AutoValue
|
||||
|
||||
@@ -79,7 +79,7 @@ class ManageSecurityTokenContract {
|
||||
void hideAction();
|
||||
|
||||
void operationImportKey(byte[] importKeyData);
|
||||
void operationPromote(long masterKeyId, byte[] cardAid);
|
||||
void operationPromote(long masterKeyId, byte[] cardAid, long[] subKeyIds);
|
||||
void operationResetSecurityToken();
|
||||
void operationChangePinSecurityToken(String adminPin, String newPin);
|
||||
|
||||
|
||||
@@ -277,12 +277,12 @@ public class ManageSecurityTokenFragment extends Fragment implements ManageSecur
|
||||
}
|
||||
|
||||
@Override
|
||||
public void operationPromote(long masterKeyId, byte[] cardAid) {
|
||||
public void operationPromote(long masterKeyId, byte[] cardAid, long[] subkeys) {
|
||||
if (currentImportKeyringParcel != null) {
|
||||
throw new IllegalStateException("Cannot trigger import operation twice!");
|
||||
}
|
||||
|
||||
currentPromoteKeyringParcel = PromoteKeyringParcel.createPromoteKeyringParcel(masterKeyId, cardAid, null);
|
||||
currentPromoteKeyringParcel = PromoteKeyringParcel.createPromoteKeyringParcel(masterKeyId, cardAid, subkeys);
|
||||
cryptoPromoteOperationHelper.setOperationMinimumDelay(1000L);
|
||||
cryptoPromoteOperationHelper.cryptoOperation();
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.sufficientlysecure.keychain.ui.token.PublicKeyRetrievalLoader.KeyRetr
|
||||
import org.sufficientlysecure.keychain.ui.token.PublicKeyRetrievalLoader.KeyserverRetrievalLoader;
|
||||
import org.sufficientlysecure.keychain.ui.token.PublicKeyRetrievalLoader.LocalKeyLookupLoader;
|
||||
import org.sufficientlysecure.keychain.ui.token.PublicKeyRetrievalLoader.UriKeyRetrievalLoader;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
import org.sufficientlysecure.keychain.ui.util.PermissionsUtil;
|
||||
|
||||
|
||||
@@ -276,13 +277,21 @@ class ManageSecurityTokenPresenter implements ManageSecurityTokenMvpPresenter {
|
||||
if (masterKeyId != null) {
|
||||
this.masterKeyId = masterKeyId;
|
||||
view.statusLineAdd(StatusLine.TOKEN_CHECK);
|
||||
view.operationPromote(masterKeyId, tokenInfo.getAid());
|
||||
|
||||
promoteKeyWithTokenInfo(masterKeyId);
|
||||
return;
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Method can only be called with successful result!");
|
||||
}
|
||||
|
||||
private void promoteKeyWithTokenInfo(Long masterKeyId) {
|
||||
long signKeyId = KeyFormattingUtils.getKeyIdFromFingerprint(tokenInfo.getFingerprintSign());
|
||||
long decryptKeyId = KeyFormattingUtils.getKeyIdFromFingerprint(tokenInfo.getFingerprintDecrypt());
|
||||
long authKeyId = KeyFormattingUtils.getKeyIdFromFingerprint(tokenInfo.getFingerprintAuth());
|
||||
view.operationPromote(masterKeyId, tokenInfo.getAid(), new long[] { signKeyId, decryptKeyId, authKeyId });
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClickImport() {
|
||||
view.statusLineAdd(StatusLine.IMPORT);
|
||||
@@ -296,7 +305,7 @@ class ManageSecurityTokenPresenter implements ManageSecurityTokenMvpPresenter {
|
||||
|
||||
view.statusLineOk();
|
||||
view.statusLineAdd(StatusLine.TOKEN_PROMOTE);
|
||||
view.operationPromote(masterKeyId, tokenInfo.getAid());
|
||||
promoteKeyWithTokenInfo(masterKeyId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user