cleanup, NonNull annotation, never return null in PgpDecryptVerify
This commit is contained in:
@@ -19,6 +19,7 @@ package org.sufficientlysecure.keychain.operations;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||||
import org.sufficientlysecure.keychain.pgp.PassphraseCacheInterface;
|
import org.sufficientlysecure.keychain.pgp.PassphraseCacheInterface;
|
||||||
@@ -76,9 +77,8 @@ public abstract class BaseOperation <T extends Parcelable> implements Passphrase
|
|||||||
mCancelled = cancelled;
|
mCancelled = cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperationResult execute(T input, CryptoInputParcel cryptoInput) {
|
@NonNull
|
||||||
return null;
|
public abstract OperationResult execute(T input, CryptoInputParcel cryptoInput);
|
||||||
}
|
|
||||||
|
|
||||||
public void updateProgress(int message, int current, int total) {
|
public void updateProgress(int message, int current, int total) {
|
||||||
if (mProgressable != null) {
|
if (mProgressable != null) {
|
||||||
|
|||||||
@@ -18,10 +18,9 @@
|
|||||||
package org.sufficientlysecure.keychain.operations;
|
package org.sufficientlysecure.keychain.operations;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
|
||||||
import org.sufficientlysecure.keychain.keyimport.HkpKeyserver;
|
import org.sufficientlysecure.keychain.keyimport.HkpKeyserver;
|
||||||
import org.sufficientlysecure.keychain.keyimport.Keyserver;
|
|
||||||
import org.sufficientlysecure.keychain.operations.results.CertifyResult;
|
import org.sufficientlysecure.keychain.operations.results.CertifyResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.ExportResult;
|
import org.sufficientlysecure.keychain.operations.results.ExportResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
||||||
@@ -44,7 +43,6 @@ import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
|||||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
||||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel.NfcSignOperationsBuilder;
|
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel.NfcSignOperationsBuilder;
|
||||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||||
import org.sufficientlysecure.keychain.util.ParcelableProxy;
|
|
||||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||||
import org.sufficientlysecure.keychain.util.Preferences;
|
import org.sufficientlysecure.keychain.util.Preferences;
|
||||||
import org.sufficientlysecure.keychain.util.orbot.OrbotHelper;
|
import org.sufficientlysecure.keychain.util.orbot.OrbotHelper;
|
||||||
@@ -69,6 +67,7 @@ public class CertifyOperation extends BaseOperation<CertifyActionsParcel> {
|
|||||||
super(context, providerHelper, progressable, cancelled);
|
super(context, providerHelper, progressable, cancelled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public CertifyResult execute(CertifyActionsParcel parcel, CryptoInputParcel cryptoInput) {
|
public CertifyResult execute(CertifyActionsParcel parcel, CryptoInputParcel cryptoInput) {
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
package org.sufficientlysecure.keychain.operations;
|
package org.sufficientlysecure.keychain.operations;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.operations.results.ConsolidateResult;
|
import org.sufficientlysecure.keychain.operations.results.ConsolidateResult;
|
||||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||||
@@ -34,6 +35,7 @@ public class ConsolidateOperation extends BaseOperation<ConsolidateInputParcel>
|
|||||||
super(context, providerHelper, progressable);
|
super(context, providerHelper, progressable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public ConsolidateResult execute(ConsolidateInputParcel consolidateInputParcel,
|
public ConsolidateResult execute(ConsolidateInputParcel consolidateInputParcel,
|
||||||
CryptoInputParcel cryptoInputParcel) {
|
CryptoInputParcel cryptoInputParcel) {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
package org.sufficientlysecure.keychain.operations;
|
package org.sufficientlysecure.keychain.operations;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.operations.results.ConsolidateResult;
|
import org.sufficientlysecure.keychain.operations.results.ConsolidateResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.DeleteResult;
|
import org.sufficientlysecure.keychain.operations.results.DeleteResult;
|
||||||
@@ -45,6 +46,7 @@ public class DeleteOperation extends BaseOperation<DeleteKeyringParcel> {
|
|||||||
super(context, providerHelper, progressable);
|
super(context, providerHelper, progressable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public DeleteResult execute(DeleteKeyringParcel deleteKeyringParcel,
|
public DeleteResult execute(DeleteKeyringParcel deleteKeyringParcel,
|
||||||
CryptoInputParcel cryptoInputParcel) {
|
CryptoInputParcel cryptoInputParcel) {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
package org.sufficientlysecure.keychain.operations;
|
package org.sufficientlysecure.keychain.operations;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.operations.results.EditKeyResult;
|
import org.sufficientlysecure.keychain.operations.results.EditKeyResult;
|
||||||
@@ -57,6 +58,7 @@ public class EditKeyOperation extends BaseOperation<SaveKeyringParcel> {
|
|||||||
super(context, providerHelper, progressable, cancelled);
|
super(context, providerHelper, progressable, cancelled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public OperationResult execute(SaveKeyringParcel saveParcel, CryptoInputParcel cryptoInput) {
|
public OperationResult execute(SaveKeyringParcel saveParcel, CryptoInputParcel cryptoInput) {
|
||||||
|
|
||||||
OperationLog log = new OperationLog();
|
OperationLog log = new OperationLog();
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ package org.sufficientlysecure.keychain.operations;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import org.spongycastle.bcpg.ArmoredOutputStream;
|
import org.spongycastle.bcpg.ArmoredOutputStream;
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
@@ -329,6 +330,7 @@ public class ExportOperation extends BaseOperation<ExportKeyringParcel> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public ExportResult execute(ExportKeyringParcel exportInput, CryptoInputParcel cryptoInput) {
|
public ExportResult execute(ExportKeyringParcel exportInput, CryptoInputParcel cryptoInput) {
|
||||||
switch (exportInput.mExportType) {
|
switch (exportInput.mExportType) {
|
||||||
case UPLOAD_KEYSERVER: {
|
case UPLOAD_KEYSERVER: {
|
||||||
@@ -364,8 +366,8 @@ public class ExportOperation extends BaseOperation<ExportKeyringParcel> {
|
|||||||
return exportToUri(exportInput.mMasterKeyIds, exportInput.mExportSecret,
|
return exportToUri(exportInput.mMasterKeyIds, exportInput.mExportSecret,
|
||||||
exportInput.mOutputUri);
|
exportInput.mOutputUri);
|
||||||
}
|
}
|
||||||
default: { // can't happen
|
default: { // can never happen, all enum types must be handled above
|
||||||
return null;
|
throw new AssertionError("must not happen, this is a bug!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,24 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.operations;
|
package org.sufficientlysecure.keychain.operations;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.Proxy;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.ExecutorCompletionService;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.SynchronousQueue;
|
||||||
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
@@ -28,7 +45,6 @@ import org.sufficientlysecure.keychain.keyimport.Keyserver;
|
|||||||
import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
||||||
import org.sufficientlysecure.keychain.operations.results.ConsolidateResult;
|
import org.sufficientlysecure.keychain.operations.results.ConsolidateResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
|
import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.InputPendingResult;
|
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
||||||
@@ -48,21 +64,6 @@ import org.sufficientlysecure.keychain.util.Preferences;
|
|||||||
import org.sufficientlysecure.keychain.util.ProgressScaler;
|
import org.sufficientlysecure.keychain.util.ProgressScaler;
|
||||||
import org.sufficientlysecure.keychain.util.orbot.OrbotHelper;
|
import org.sufficientlysecure.keychain.util.orbot.OrbotHelper;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.Proxy;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.ExecutorCompletionService;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.SynchronousQueue;
|
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An operation class which implements high level import
|
* An operation class which implements high level import
|
||||||
* operations.
|
* operations.
|
||||||
@@ -118,6 +119,7 @@ public class ImportOperation extends BaseOperation<ImportKeyringParcel> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public ImportKeyResult serialKeyRingImport(ParcelableFileCache<ParcelableKeyRing> cache,
|
public ImportKeyResult serialKeyRingImport(ParcelableFileCache<ParcelableKeyRing> cache,
|
||||||
String keyServerUri, Proxy proxy) {
|
String keyServerUri, Proxy proxy) {
|
||||||
|
|
||||||
@@ -148,8 +150,8 @@ public class ImportOperation extends BaseOperation<ImportKeyringParcel> {
|
|||||||
* @param keyServerUri contains uri of keyserver to import from, if it is an import from cloud
|
* @param keyServerUri contains uri of keyserver to import from, if it is an import from cloud
|
||||||
* @param progressable Allows multi-threaded import to supply a progressable that ignores the
|
* @param progressable Allows multi-threaded import to supply a progressable that ignores the
|
||||||
* progress of a single key being imported
|
* progress of a single key being imported
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
|
@NonNull
|
||||||
public ImportKeyResult serialKeyRingImport(Iterator<ParcelableKeyRing> entries, int num,
|
public ImportKeyResult serialKeyRingImport(Iterator<ParcelableKeyRing> entries, int num,
|
||||||
String keyServerUri, Progressable progressable,
|
String keyServerUri, Progressable progressable,
|
||||||
Proxy proxy) {
|
Proxy proxy) {
|
||||||
@@ -380,6 +382,7 @@ public class ImportOperation extends BaseOperation<ImportKeyringParcel> {
|
|||||||
importedMasterKeyIdsArray);
|
importedMasterKeyIdsArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public OperationResult execute(ImportKeyringParcel importInput, CryptoInputParcel cryptoInput) {
|
public OperationResult execute(ImportKeyringParcel importInput, CryptoInputParcel cryptoInput) {
|
||||||
ArrayList<ParcelableKeyRing> keyList = importInput.mKeyList;
|
ArrayList<ParcelableKeyRing> keyList = importInput.mKeyList;
|
||||||
@@ -426,6 +429,7 @@ public class ImportOperation extends BaseOperation<ImportKeyringParcel> {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
private ImportKeyResult multiThreadedKeyImport(Iterator<ParcelableKeyRing> keyListIterator,
|
private ImportKeyResult multiThreadedKeyImport(Iterator<ParcelableKeyRing> keyListIterator,
|
||||||
int totKeys, final String keyServer,
|
int totKeys, final String keyServer,
|
||||||
final Proxy proxy) {
|
final Proxy proxy) {
|
||||||
@@ -441,7 +445,7 @@ public class ImportOperation extends BaseOperation<ImportKeyringParcel> {
|
|||||||
new SynchronousQueue<Runnable>());
|
new SynchronousQueue<Runnable>());
|
||||||
|
|
||||||
ExecutorCompletionService<ImportKeyResult> importCompletionService =
|
ExecutorCompletionService<ImportKeyResult> importCompletionService =
|
||||||
new ExecutorCompletionService(importExecutor);
|
new ExecutorCompletionService<>(importExecutor);
|
||||||
|
|
||||||
while (keyListIterator.hasNext()) { // submit all key rings to be imported
|
while (keyListIterator.hasNext()) { // submit all key rings to be imported
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,15 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.operations;
|
package org.sufficientlysecure.keychain.operations;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.Proxy;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import com.textuality.keybase.lib.Proof;
|
import com.textuality.keybase.lib.Proof;
|
||||||
import com.textuality.keybase.lib.prover.Prover;
|
import com.textuality.keybase.lib.prover.Prover;
|
||||||
@@ -32,7 +40,6 @@ import de.measite.minidns.record.TXT;
|
|||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.spongycastle.openpgp.PGPUtil;
|
import org.spongycastle.openpgp.PGPUtil;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.operations.results.CertifyResult;
|
|
||||||
import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
|
import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.KeybaseVerificationResult;
|
import org.sufficientlysecure.keychain.operations.results.KeybaseVerificationResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||||
@@ -46,12 +53,6 @@ import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
|||||||
import org.sufficientlysecure.keychain.util.Preferences;
|
import org.sufficientlysecure.keychain.util.Preferences;
|
||||||
import org.sufficientlysecure.keychain.util.orbot.OrbotHelper;
|
import org.sufficientlysecure.keychain.util.orbot.OrbotHelper;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.net.Proxy;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class KeybaseVerificationOperation extends BaseOperation<KeybaseVerificationParcel> {
|
public class KeybaseVerificationOperation extends BaseOperation<KeybaseVerificationParcel> {
|
||||||
|
|
||||||
public KeybaseVerificationOperation(Context context, ProviderHelper providerHelper,
|
public KeybaseVerificationOperation(Context context, ProviderHelper providerHelper,
|
||||||
@@ -59,6 +60,7 @@ public class KeybaseVerificationOperation extends BaseOperation<KeybaseVerificat
|
|||||||
super(context, providerHelper, progressable);
|
super(context, providerHelper, progressable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public KeybaseVerificationResult execute(KeybaseVerificationParcel keybaseInput,
|
public KeybaseVerificationResult execute(KeybaseVerificationParcel keybaseInput,
|
||||||
CryptoInputParcel cryptoInput) {
|
CryptoInputParcel cryptoInput) {
|
||||||
@@ -113,7 +115,7 @@ public class KeybaseVerificationOperation extends BaseOperation<KeybaseVerificat
|
|||||||
return new KeybaseVerificationResult(OperationResult.RESULT_ERROR, log);
|
return new KeybaseVerificationResult(OperationResult.RESULT_ERROR, log);
|
||||||
}
|
}
|
||||||
Record[] records = dnsQuery.getAnswers();
|
Record[] records = dnsQuery.getAnswers();
|
||||||
List<List<byte[]>> extents = new ArrayList<List<byte[]>>();
|
List<List<byte[]>> extents = new ArrayList<>();
|
||||||
for (Record r : records) {
|
for (Record r : records) {
|
||||||
Data d = r.getPayload();
|
Data d = r.getPayload();
|
||||||
if (d instanceof TXT) {
|
if (d instanceof TXT) {
|
||||||
|
|||||||
@@ -17,7 +17,11 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.operations;
|
package org.sufficientlysecure.keychain.operations;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
||||||
@@ -36,8 +40,6 @@ 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;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
|
||||||
|
|
||||||
/** An operation which promotes a public key ring to a secret one.
|
/** An operation which promotes a public key ring to a secret one.
|
||||||
*
|
*
|
||||||
* This operation can only be applied to public key rings where no secret key
|
* This operation can only be applied to public key rings where no secret key
|
||||||
@@ -52,18 +54,10 @@ public class PromoteKeyOperation extends BaseOperation<PromoteKeyringParcel> {
|
|||||||
super(context, providerHelper, progressable, cancelled);
|
super(context, providerHelper, progressable, cancelled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public PromoteKeyResult execute(PromoteKeyringParcel promoteKeyringParcel,
|
public PromoteKeyResult execute(PromoteKeyringParcel promoteKeyringParcel,
|
||||||
CryptoInputParcel cryptoInputParcel) {
|
CryptoInputParcel cryptoInputParcel) {
|
||||||
// Input
|
|
||||||
long masterKeyId = promoteKeyringParcel.mKeyRingId;
|
|
||||||
byte[] cardAid = promoteKeyringParcel.mCardAid;
|
|
||||||
long[] subKeyIds = promoteKeyringParcel.mSubKeyIds;
|
|
||||||
|
|
||||||
return execute(masterKeyId, cardAid, subKeyIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PromoteKeyResult execute(long masterKeyId, byte[] cardAid, long[] subKeyIds) {
|
|
||||||
|
|
||||||
OperationLog log = new OperationLog();
|
OperationLog log = new OperationLog();
|
||||||
log.add(LogType.MSG_PR, 0);
|
log.add(LogType.MSG_PR, 0);
|
||||||
@@ -74,17 +68,17 @@ public class PromoteKeyOperation extends BaseOperation<PromoteKeyringParcel> {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
log.add(LogType.MSG_PR_FETCHING, 1,
|
log.add(LogType.MSG_PR_FETCHING, 1,
|
||||||
KeyFormattingUtils.convertKeyIdToHex(masterKeyId));
|
KeyFormattingUtils.convertKeyIdToHex(promoteKeyringParcel.mKeyRingId));
|
||||||
CanonicalizedPublicKeyRing pubRing =
|
CanonicalizedPublicKeyRing pubRing =
|
||||||
mProviderHelper.getCanonicalizedPublicKeyRing(masterKeyId);
|
mProviderHelper.getCanonicalizedPublicKeyRing(promoteKeyringParcel.mKeyRingId);
|
||||||
|
|
||||||
if (subKeyIds == null) {
|
if (promoteKeyringParcel.mSubKeyIds == null) {
|
||||||
log.add(LogType.MSG_PR_ALL, 1);
|
log.add(LogType.MSG_PR_ALL, 1);
|
||||||
} else {
|
} else {
|
||||||
// sort for binary search
|
// sort for binary search
|
||||||
for (CanonicalizedPublicKey key : pubRing.publicKeyIterator()) {
|
for (CanonicalizedPublicKey key : pubRing.publicKeyIterator()) {
|
||||||
long subKeyId = key.getKeyId();
|
long subKeyId = key.getKeyId();
|
||||||
if (naiveIndexOf(subKeyIds, subKeyId) != null) {
|
if (naiveIndexOf(promoteKeyringParcel.mSubKeyIds, subKeyId) != null) {
|
||||||
log.add(LogType.MSG_PR_SUBKEY_MATCH, 1,
|
log.add(LogType.MSG_PR_SUBKEY_MATCH, 1,
|
||||||
KeyFormattingUtils.convertKeyIdToHex(subKeyId));
|
KeyFormattingUtils.convertKeyIdToHex(subKeyId));
|
||||||
} else {
|
} else {
|
||||||
@@ -95,7 +89,8 @@ public class PromoteKeyOperation extends BaseOperation<PromoteKeyringParcel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create divert-to-card secret key from public key
|
// create divert-to-card secret key from public key
|
||||||
promotedRing = pubRing.createDivertSecretRing(cardAid, subKeyIds);
|
promotedRing = pubRing.createDivertSecretRing(promoteKeyringParcel.mCardAid,
|
||||||
|
promoteKeyringParcel.mSubKeyIds);
|
||||||
|
|
||||||
} catch (NotFoundException e) {
|
} catch (NotFoundException e) {
|
||||||
log.add(LogType.MSG_PR_ERROR_KEY_NOT_FOUND, 2);
|
log.add(LogType.MSG_PR_ERROR_KEY_NOT_FOUND, 2);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package org.sufficientlysecure.keychain.operations;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
||||||
@@ -62,6 +63,7 @@ public class SignEncryptOperation extends BaseOperation<SignEncryptParcel> {
|
|||||||
super(context, providerHelper, progressable, cancelled);
|
super(context, providerHelper, progressable, cancelled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public SignEncryptResult execute(SignEncryptParcel input, CryptoInputParcel cryptoInput) {
|
public SignEncryptResult execute(SignEncryptParcel input, CryptoInputParcel cryptoInput) {
|
||||||
|
|
||||||
OperationLog log = new OperationLog();
|
OperationLog log = new OperationLog();
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
package org.sufficientlysecure.keychain.pgp;
|
package org.sufficientlysecure.keychain.pgp;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.webkit.MimeTypeMap;
|
import android.webkit.MimeTypeMap;
|
||||||
|
|
||||||
import org.openintents.openpgp.OpenPgpMetadata;
|
import org.openintents.openpgp.OpenPgpMetadata;
|
||||||
@@ -80,9 +81,8 @@ public class PgpDecryptVerify extends BaseOperation<PgpDecryptVerifyInputParcel>
|
|||||||
super(context, providerHelper, progressable);
|
super(context, providerHelper, progressable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Decrypts and/or verifies data based on parameters of PgpDecryptVerifyInputParcel. */
|
||||||
* Decrypts and/or verifies data based on parameters of class
|
@NonNull
|
||||||
*/
|
|
||||||
public DecryptVerifyResult execute(PgpDecryptVerifyInputParcel input, CryptoInputParcel cryptoInput) {
|
public DecryptVerifyResult execute(PgpDecryptVerifyInputParcel input, CryptoInputParcel cryptoInput) {
|
||||||
InputData inputData;
|
InputData inputData;
|
||||||
OutputStream outputStream;
|
OutputStream outputStream;
|
||||||
@@ -96,8 +96,10 @@ public class PgpDecryptVerify extends BaseOperation<PgpDecryptVerifyInputParcel>
|
|||||||
long inputSize = FileHelper.getFileSize(mContext, input.getInputUri(), 0);
|
long inputSize = FileHelper.getFileSize(mContext, input.getInputUri(), 0);
|
||||||
inputData = new InputData(inputStream, inputSize);
|
inputData = new InputData(inputStream, inputSize);
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
Log.e(Constants.TAG, "File not found at " + input.getInputUri(), e);
|
Log.e(Constants.TAG, "URI could not be opened: " + input.getInputUri(), e);
|
||||||
return null;
|
OperationLog log = new OperationLog();
|
||||||
|
log.add(LogType.MSG_DC_ERROR_IO, 1);
|
||||||
|
return new DecryptVerifyResult(DecryptVerifyResult.RESULT_ERROR, log);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,8 +109,10 @@ public class PgpDecryptVerify extends BaseOperation<PgpDecryptVerifyInputParcel>
|
|||||||
try {
|
try {
|
||||||
outputStream = mContext.getContentResolver().openOutputStream(input.getOutputUri());
|
outputStream = mContext.getContentResolver().openOutputStream(input.getOutputUri());
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
e.printStackTrace();
|
Log.e(Constants.TAG, "URI could not be opened: " + input.getOutputUri(), e);
|
||||||
return null;
|
OperationLog log = new OperationLog();
|
||||||
|
log.add(LogType.MSG_DC_ERROR_IO, 1);
|
||||||
|
return new DecryptVerifyResult(DecryptVerifyResult.RESULT_ERROR, log);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,11 +126,13 @@ public class PgpDecryptVerify extends BaseOperation<PgpDecryptVerifyInputParcel>
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public DecryptVerifyResult execute(PgpDecryptVerifyInputParcel input, CryptoInputParcel cryptoInput,
|
public DecryptVerifyResult execute(PgpDecryptVerifyInputParcel input, CryptoInputParcel cryptoInput,
|
||||||
InputData inputData, OutputStream outputStream) {
|
InputData inputData, OutputStream outputStream) {
|
||||||
return executeInternal(input, cryptoInput, inputData, outputStream);
|
return executeInternal(input, cryptoInput, inputData, outputStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
private DecryptVerifyResult executeInternal(PgpDecryptVerifyInputParcel input, CryptoInputParcel cryptoInput,
|
private DecryptVerifyResult executeInternal(PgpDecryptVerifyInputParcel input, CryptoInputParcel cryptoInput,
|
||||||
InputData inputData, OutputStream outputStream) {
|
InputData inputData, OutputStream outputStream) {
|
||||||
try {
|
try {
|
||||||
@@ -169,9 +175,8 @@ public class PgpDecryptVerify extends BaseOperation<PgpDecryptVerifyInputParcel>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**Verify signed plaintext data (PGP/INLINE). */
|
||||||
* Verify Keybase.io style signed literal data
|
@NonNull
|
||||||
*/
|
|
||||||
private DecryptVerifyResult verifySignedLiteralData(
|
private DecryptVerifyResult verifySignedLiteralData(
|
||||||
PgpDecryptVerifyInputParcel input, InputStream in, OutputStream out, int indent)
|
PgpDecryptVerifyInputParcel input, InputStream in, OutputStream out, int indent)
|
||||||
throws IOException, PGPException {
|
throws IOException, PGPException {
|
||||||
@@ -301,9 +306,8 @@ public class PgpDecryptVerify extends BaseOperation<PgpDecryptVerifyInputParcel>
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/** Decrypt and/or verify binary or ascii armored pgp data. */
|
||||||
* Decrypt and/or verifies binary or ascii armored pgp
|
@NonNull
|
||||||
*/
|
|
||||||
private DecryptVerifyResult decryptVerify(
|
private DecryptVerifyResult decryptVerify(
|
||||||
PgpDecryptVerifyInputParcel input, CryptoInputParcel cryptoInput,
|
PgpDecryptVerifyInputParcel input, CryptoInputParcel cryptoInput,
|
||||||
InputStream in, OutputStream out, int indent) throws IOException, PGPException {
|
InputStream in, OutputStream out, int indent) throws IOException, PGPException {
|
||||||
@@ -843,6 +847,7 @@ public class PgpDecryptVerify extends BaseOperation<PgpDecryptVerifyInputParcel>
|
|||||||
* The method is heavily based on
|
* The method is heavily based on
|
||||||
* pg/src/main/java/org/spongycastle/openpgp/examples/ClearSignedFileProcessor.java
|
* pg/src/main/java/org/spongycastle/openpgp/examples/ClearSignedFileProcessor.java
|
||||||
*/
|
*/
|
||||||
|
@NonNull
|
||||||
private DecryptVerifyResult verifyCleartextSignature(
|
private DecryptVerifyResult verifyCleartextSignature(
|
||||||
ArmoredInputStream aIn, OutputStream outputStream, int indent) throws IOException, PGPException {
|
ArmoredInputStream aIn, OutputStream outputStream, int indent) throws IOException, PGPException {
|
||||||
|
|
||||||
@@ -950,6 +955,7 @@ public class PgpDecryptVerify extends BaseOperation<PgpDecryptVerifyInputParcel>
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
private DecryptVerifyResult verifyDetachedSignature(
|
private DecryptVerifyResult verifyDetachedSignature(
|
||||||
PgpDecryptVerifyInputParcel input, InputData inputData, OutputStream out, int indent)
|
PgpDecryptVerifyInputParcel input, InputData inputData, OutputStream out, int indent)
|
||||||
throws IOException, PGPException {
|
throws IOException, PGPException {
|
||||||
@@ -1042,7 +1048,9 @@ public class PgpDecryptVerify extends BaseOperation<PgpDecryptVerifyInputParcel>
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PGPSignature processPGPSignatureList(PGPSignatureList sigList, OpenPgpSignatureResultBuilder signatureResultBuilder) throws PGPException {
|
private PGPSignature processPGPSignatureList(
|
||||||
|
PGPSignatureList sigList, OpenPgpSignatureResultBuilder signatureResultBuilder)
|
||||||
|
throws PGPException {
|
||||||
CanonicalizedPublicKeyRing signingRing = null;
|
CanonicalizedPublicKeyRing signingRing = null;
|
||||||
CanonicalizedPublicKey signingKey = null;
|
CanonicalizedPublicKey signingKey = null;
|
||||||
int signatureIndex = -1;
|
int signatureIndex = -1;
|
||||||
|
|||||||
@@ -1060,6 +1060,7 @@ public class ProviderHelper {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public ConsolidateResult consolidateDatabaseStep1(Progressable progress) {
|
public ConsolidateResult consolidateDatabaseStep1(Progressable progress) {
|
||||||
|
|
||||||
OperationLog log = new OperationLog();
|
OperationLog log = new OperationLog();
|
||||||
@@ -1205,12 +1206,14 @@ public class ProviderHelper {
|
|||||||
return consolidateDatabaseStep2(log, indent, progress, false);
|
return consolidateDatabaseStep2(log, indent, progress, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public ConsolidateResult consolidateDatabaseStep2(Progressable progress) {
|
public ConsolidateResult consolidateDatabaseStep2(Progressable progress) {
|
||||||
return consolidateDatabaseStep2(new OperationLog(), 0, progress, true);
|
return consolidateDatabaseStep2(new OperationLog(), 0, progress, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean mConsolidateCritical = false;
|
private static boolean mConsolidateCritical = false;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
private ConsolidateResult consolidateDatabaseStep2(
|
private ConsolidateResult consolidateDatabaseStep2(
|
||||||
OperationLog log, int indent, Progressable progress, boolean recovery) {
|
OperationLog log, int indent, Progressable progress, boolean recovery) {
|
||||||
|
|
||||||
|
|||||||
@@ -314,14 +314,6 @@ public class CryptoOperationHelper<T extends Parcelable, S extends OperationResu
|
|||||||
cryptoOperation(new CryptoInputParcel());
|
cryptoOperation(new CryptoInputParcel());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onCryptoOperationResult(S result) {
|
|
||||||
if (result.success()) {
|
|
||||||
mCallback.onCryptoOperationSuccess(result);
|
|
||||||
} else {
|
|
||||||
mCallback.onCryptoOperationError(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onHandleResult(OperationResult result, CryptoInputParcel oldCryptoInput) {
|
public void onHandleResult(OperationResult result, CryptoInputParcel oldCryptoInput) {
|
||||||
Log.d(Constants.TAG, "Handling result in OperationHelper success: " + result.success());
|
Log.d(Constants.TAG, "Handling result in OperationHelper success: " + result.success());
|
||||||
|
|
||||||
@@ -338,8 +330,13 @@ public class CryptoOperationHelper<T extends Parcelable, S extends OperationResu
|
|||||||
dismissProgress();
|
dismissProgress();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// noinspection unchecked, because type erasure :(
|
if (result.success()) {
|
||||||
onCryptoOperationResult((S) result);
|
// noinspection unchecked, because type erasure :(
|
||||||
|
mCallback.onCryptoOperationSuccess((S) result);
|
||||||
|
} else {
|
||||||
|
// noinspection unchecked, because type erasure :(
|
||||||
|
mCallback.onCryptoOperationError((S) result);
|
||||||
|
}
|
||||||
} catch (ClassCastException e) {
|
} catch (ClassCastException e) {
|
||||||
throw new AssertionError("bad return class ("
|
throw new AssertionError("bad return class ("
|
||||||
+ result.getClass().getSimpleName() + "), this is a programming error!");
|
+ result.getClass().getSimpleName() + "), this is a programming error!");
|
||||||
|
|||||||
Reference in New Issue
Block a user