made mSignatureTime optional in CryptoOperationHelper
This commit is contained in:
@@ -64,6 +64,7 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
public class OpenPgpService extends RemoteService {
|
public class OpenPgpService extends RemoteService {
|
||||||
@@ -164,7 +165,9 @@ public class OpenPgpService extends RemoteService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static PendingIntent getRequiredInputPendingIntent(Context context,
|
private static PendingIntent getRequiredInputPendingIntent(Context context,
|
||||||
Intent data, RequiredInputParcel requiredInput) {
|
Intent data,
|
||||||
|
RequiredInputParcel requiredInput,
|
||||||
|
CryptoInputParcel cryptoInput) {
|
||||||
|
|
||||||
switch (requiredInput.mType) {
|
switch (requiredInput.mType) {
|
||||||
case NFC_MOVE_KEY_TO_CARD:
|
case NFC_MOVE_KEY_TO_CARD:
|
||||||
@@ -175,6 +178,7 @@ public class OpenPgpService extends RemoteService {
|
|||||||
// pass params through to activity that it can be returned again later to repeat pgp operation
|
// pass params through to activity that it can be returned again later to repeat pgp operation
|
||||||
intent.putExtra(NfcOperationActivity.EXTRA_SERVICE_INTENT, data);
|
intent.putExtra(NfcOperationActivity.EXTRA_SERVICE_INTENT, data);
|
||||||
intent.putExtra(NfcOperationActivity.EXTRA_REQUIRED_INPUT, requiredInput);
|
intent.putExtra(NfcOperationActivity.EXTRA_REQUIRED_INPUT, requiredInput);
|
||||||
|
intent.putExtra(NfcOperationActivity.EXTRA_CRYPTO_INPUT, cryptoInput);
|
||||||
return PendingIntent.getActivity(context, 0, intent,
|
return PendingIntent.getActivity(context, 0, intent,
|
||||||
PendingIntent.FLAG_CANCEL_CURRENT);
|
PendingIntent.FLAG_CANCEL_CURRENT);
|
||||||
}
|
}
|
||||||
@@ -185,6 +189,7 @@ public class OpenPgpService extends RemoteService {
|
|||||||
// pass params through to activity that it can be returned again later to repeat pgp operation
|
// pass params through to activity that it can be returned again later to repeat pgp operation
|
||||||
intent.putExtra(PassphraseDialogActivity.EXTRA_SERVICE_INTENT, data);
|
intent.putExtra(PassphraseDialogActivity.EXTRA_SERVICE_INTENT, data);
|
||||||
intent.putExtra(PassphraseDialogActivity.EXTRA_REQUIRED_INPUT, requiredInput);
|
intent.putExtra(PassphraseDialogActivity.EXTRA_REQUIRED_INPUT, requiredInput);
|
||||||
|
intent.putExtra(PassphraseDialogActivity.EXTRA_CRYPTO_INPUT, cryptoInput);
|
||||||
return PendingIntent.getActivity(context, 0, intent,
|
return PendingIntent.getActivity(context, 0, intent,
|
||||||
PendingIntent.FLAG_CANCEL_CURRENT);
|
PendingIntent.FLAG_CANCEL_CURRENT);
|
||||||
}
|
}
|
||||||
@@ -279,12 +284,12 @@ public class OpenPgpService extends RemoteService {
|
|||||||
|
|
||||||
CryptoInputParcel inputParcel = CryptoInputParcelCacheService.getCryptoInputParcel(this, data);
|
CryptoInputParcel inputParcel = CryptoInputParcelCacheService.getCryptoInputParcel(this, data);
|
||||||
if (inputParcel == null) {
|
if (inputParcel == null) {
|
||||||
inputParcel = new CryptoInputParcel();
|
inputParcel = new CryptoInputParcel(new Date());
|
||||||
}
|
}
|
||||||
// override passphrase in input parcel if given by API call
|
// override passphrase in input parcel if given by API call
|
||||||
if (data.hasExtra(OpenPgpApi.EXTRA_PASSPHRASE)) {
|
if (data.hasExtra(OpenPgpApi.EXTRA_PASSPHRASE)) {
|
||||||
inputParcel = new CryptoInputParcel(inputParcel.getSignatureTime(),
|
inputParcel.mPassphrase =
|
||||||
new Passphrase(data.getCharArrayExtra(OpenPgpApi.EXTRA_PASSPHRASE)));
|
new Passphrase(data.getCharArrayExtra(OpenPgpApi.EXTRA_PASSPHRASE));
|
||||||
}
|
}
|
||||||
|
|
||||||
// execute PGP operation!
|
// execute PGP operation!
|
||||||
@@ -294,7 +299,8 @@ public class OpenPgpService extends RemoteService {
|
|||||||
if (pgpResult.isPending()) {
|
if (pgpResult.isPending()) {
|
||||||
|
|
||||||
RequiredInputParcel requiredInput = pgpResult.getRequiredInputParcel();
|
RequiredInputParcel requiredInput = pgpResult.getRequiredInputParcel();
|
||||||
PendingIntent pIntent = getRequiredInputPendingIntent(getBaseContext(), data, requiredInput);
|
PendingIntent pIntent = getRequiredInputPendingIntent(getBaseContext(), data,
|
||||||
|
requiredInput, pgpResult.mCryptoInputParcel);
|
||||||
|
|
||||||
// return PendingIntent to be executed by client
|
// return PendingIntent to be executed by client
|
||||||
Intent result = new Intent();
|
Intent result = new Intent();
|
||||||
@@ -434,12 +440,12 @@ public class OpenPgpService extends RemoteService {
|
|||||||
|
|
||||||
CryptoInputParcel inputParcel = CryptoInputParcelCacheService.getCryptoInputParcel(this, data);
|
CryptoInputParcel inputParcel = CryptoInputParcelCacheService.getCryptoInputParcel(this, data);
|
||||||
if (inputParcel == null) {
|
if (inputParcel == null) {
|
||||||
inputParcel = new CryptoInputParcel();
|
inputParcel = new CryptoInputParcel(new Date());
|
||||||
}
|
}
|
||||||
// override passphrase in input parcel if given by API call
|
// override passphrase in input parcel if given by API call
|
||||||
if (data.hasExtra(OpenPgpApi.EXTRA_PASSPHRASE)) {
|
if (data.hasExtra(OpenPgpApi.EXTRA_PASSPHRASE)) {
|
||||||
inputParcel = new CryptoInputParcel(inputParcel.getSignatureTime(),
|
inputParcel.mPassphrase =
|
||||||
new Passphrase(data.getCharArrayExtra(OpenPgpApi.EXTRA_PASSPHRASE)));
|
new Passphrase(data.getCharArrayExtra(OpenPgpApi.EXTRA_PASSPHRASE));
|
||||||
}
|
}
|
||||||
|
|
||||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(this, new ProviderHelper(getContext()), null);
|
PgpSignEncryptOperation op = new PgpSignEncryptOperation(this, new ProviderHelper(getContext()), null);
|
||||||
@@ -449,7 +455,8 @@ public class OpenPgpService extends RemoteService {
|
|||||||
|
|
||||||
if (pgpResult.isPending()) {
|
if (pgpResult.isPending()) {
|
||||||
RequiredInputParcel requiredInput = pgpResult.getRequiredInputParcel();
|
RequiredInputParcel requiredInput = pgpResult.getRequiredInputParcel();
|
||||||
PendingIntent pIntent = getRequiredInputPendingIntent(getBaseContext(), data, requiredInput);
|
PendingIntent pIntent = getRequiredInputPendingIntent(getBaseContext(), data,
|
||||||
|
requiredInput, pgpResult.mCryptoInputParcel);
|
||||||
|
|
||||||
// return PendingIntent to be executed by client
|
// return PendingIntent to be executed by client
|
||||||
Intent result = new Intent();
|
Intent result = new Intent();
|
||||||
@@ -519,8 +526,8 @@ public class OpenPgpService extends RemoteService {
|
|||||||
}
|
}
|
||||||
// override passphrase in input parcel if given by API call
|
// override passphrase in input parcel if given by API call
|
||||||
if (data.hasExtra(OpenPgpApi.EXTRA_PASSPHRASE)) {
|
if (data.hasExtra(OpenPgpApi.EXTRA_PASSPHRASE)) {
|
||||||
cryptoInput = new CryptoInputParcel(cryptoInput.getSignatureTime(),
|
cryptoInput.mPassphrase =
|
||||||
new Passphrase(data.getCharArrayExtra(OpenPgpApi.EXTRA_PASSPHRASE)));
|
new Passphrase(data.getCharArrayExtra(OpenPgpApi.EXTRA_PASSPHRASE));
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] detachedSignature = data.getByteArrayExtra(OpenPgpApi.EXTRA_DETACHED_SIGNATURE);
|
byte[] detachedSignature = data.getByteArrayExtra(OpenPgpApi.EXTRA_DETACHED_SIGNATURE);
|
||||||
@@ -543,7 +550,8 @@ public class OpenPgpService extends RemoteService {
|
|||||||
if (pgpResult.isPending()) {
|
if (pgpResult.isPending()) {
|
||||||
// prepare and return PendingIntent to be executed by client
|
// prepare and return PendingIntent to be executed by client
|
||||||
RequiredInputParcel requiredInput = pgpResult.getRequiredInputParcel();
|
RequiredInputParcel requiredInput = pgpResult.getRequiredInputParcel();
|
||||||
PendingIntent pIntent = getRequiredInputPendingIntent(getBaseContext(), data, requiredInput);
|
PendingIntent pIntent = getRequiredInputPendingIntent(getBaseContext(), data,
|
||||||
|
requiredInput, pgpResult.mCryptoInputParcel);
|
||||||
|
|
||||||
Intent result = new Intent();
|
Intent result = new Intent();
|
||||||
result.putExtra(OpenPgpApi.RESULT_INTENT, pIntent);
|
result.putExtra(OpenPgpApi.RESULT_INTENT, pIntent);
|
||||||
|
|||||||
@@ -33,7 +33,9 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public class CryptoInputParcel implements Parcelable {
|
public class CryptoInputParcel implements Parcelable {
|
||||||
|
|
||||||
final Date mSignatureTime;
|
private Date mSignatureTime;
|
||||||
|
private boolean mHasSignature;
|
||||||
|
|
||||||
public Passphrase mPassphrase;
|
public Passphrase mPassphrase;
|
||||||
// used to supply an explicit proxy to operations that require it
|
// used to supply an explicit proxy to operations that require it
|
||||||
// this is not final so it can be added to an existing CryptoInputParcel
|
// this is not final so it can be added to an existing CryptoInputParcel
|
||||||
@@ -48,24 +50,25 @@ public class CryptoInputParcel implements Parcelable {
|
|||||||
private HashMap<ByteBuffer, byte[]> mCryptoData = new HashMap<>();
|
private HashMap<ByteBuffer, byte[]> mCryptoData = new HashMap<>();
|
||||||
|
|
||||||
public CryptoInputParcel() {
|
public CryptoInputParcel() {
|
||||||
mSignatureTime = new Date();
|
mSignatureTime = null;
|
||||||
mPassphrase = null;
|
mPassphrase = null;
|
||||||
mCachePassphrase = true;
|
mCachePassphrase = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CryptoInputParcel(Date signatureTime, Passphrase passphrase) {
|
public CryptoInputParcel(Date signatureTime, Passphrase passphrase) {
|
||||||
|
mHasSignature = true;
|
||||||
mSignatureTime = signatureTime == null ? new Date() : signatureTime;
|
mSignatureTime = signatureTime == null ? new Date() : signatureTime;
|
||||||
mPassphrase = passphrase;
|
mPassphrase = passphrase;
|
||||||
mCachePassphrase = true;
|
mCachePassphrase = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CryptoInputParcel(Passphrase passphrase) {
|
public CryptoInputParcel(Passphrase passphrase) {
|
||||||
mSignatureTime = new Date();
|
|
||||||
mPassphrase = passphrase;
|
mPassphrase = passphrase;
|
||||||
mCachePassphrase = true;
|
mCachePassphrase = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CryptoInputParcel(Date signatureTime) {
|
public CryptoInputParcel(Date signatureTime) {
|
||||||
|
mHasSignature = true;
|
||||||
mSignatureTime = signatureTime == null ? new Date() : signatureTime;
|
mSignatureTime = signatureTime == null ? new Date() : signatureTime;
|
||||||
mPassphrase = null;
|
mPassphrase = null;
|
||||||
mCachePassphrase = true;
|
mCachePassphrase = true;
|
||||||
@@ -76,14 +79,22 @@ public class CryptoInputParcel implements Parcelable {
|
|||||||
mParcelableProxy = parcelableProxy;
|
mParcelableProxy = parcelableProxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CryptoInputParcel(boolean cachePassphrase) {
|
public CryptoInputParcel(Date signatureTime, boolean cachePassphrase) {
|
||||||
mSignatureTime = new Date();
|
mHasSignature = true;
|
||||||
|
mSignatureTime = signatureTime == null ? new Date() : signatureTime;
|
||||||
mPassphrase = null;
|
mPassphrase = null;
|
||||||
mCachePassphrase = cachePassphrase;
|
mCachePassphrase = cachePassphrase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CryptoInputParcel(boolean cachePassphrase) {
|
||||||
|
mCachePassphrase = cachePassphrase;
|
||||||
|
}
|
||||||
|
|
||||||
protected CryptoInputParcel(Parcel source) {
|
protected CryptoInputParcel(Parcel source) {
|
||||||
mSignatureTime = new Date(source.readLong());
|
mHasSignature = source.readByte() != 0;
|
||||||
|
if (mHasSignature) {
|
||||||
|
mSignatureTime = new Date(source.readLong());
|
||||||
|
}
|
||||||
mPassphrase = source.readParcelable(getClass().getClassLoader());
|
mPassphrase = source.readParcelable(getClass().getClassLoader());
|
||||||
mParcelableProxy = source.readParcelable(getClass().getClassLoader());
|
mParcelableProxy = source.readParcelable(getClass().getClassLoader());
|
||||||
mCachePassphrase = source.readByte() != 0;
|
mCachePassphrase = source.readByte() != 0;
|
||||||
@@ -107,7 +118,10 @@ public class CryptoInputParcel implements Parcelable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
dest.writeLong(mSignatureTime.getTime());
|
dest.writeByte((byte) (mHasSignature ? 1 : 0));
|
||||||
|
if (mHasSignature) {
|
||||||
|
dest.writeLong(mSignatureTime.getTime());
|
||||||
|
}
|
||||||
dest.writeParcelable(mPassphrase, 0);
|
dest.writeParcelable(mPassphrase, 0);
|
||||||
dest.writeParcelable(mParcelableProxy, 0);
|
dest.writeParcelable(mParcelableProxy, 0);
|
||||||
dest.writeByte((byte) (mCachePassphrase ? 1 : 0));
|
dest.writeByte((byte) (mCachePassphrase ? 1 : 0));
|
||||||
@@ -123,6 +137,10 @@ public class CryptoInputParcel implements Parcelable {
|
|||||||
mParcelableProxy = parcelableProxy;
|
mParcelableProxy = parcelableProxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addSignatureTime(Date signatureTime) {
|
||||||
|
mSignatureTime = signatureTime;
|
||||||
|
}
|
||||||
|
|
||||||
public void addCryptoData(byte[] hash, byte[] signedHash) {
|
public void addCryptoData(byte[] hash, byte[] signedHash) {
|
||||||
mCryptoData.put(ByteBuffer.wrap(hash), signedHash);
|
mCryptoData.put(ByteBuffer.wrap(hash), signedHash);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
|
|||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
import org.sufficientlysecure.keychain.service.CertifyActionsParcel;
|
import org.sufficientlysecure.keychain.service.CertifyActionsParcel;
|
||||||
import org.sufficientlysecure.keychain.service.CertifyActionsParcel.CertifyAction;
|
import org.sufficientlysecure.keychain.service.CertifyActionsParcel.CertifyAction;
|
||||||
|
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.MultiUserIdsAdapter;
|
import org.sufficientlysecure.keychain.ui.adapter.MultiUserIdsAdapter;
|
||||||
import org.sufficientlysecure.keychain.ui.base.CachingCryptoOperationFragment;
|
import org.sufficientlysecure.keychain.ui.base.CachingCryptoOperationFragment;
|
||||||
import org.sufficientlysecure.keychain.ui.util.Notify;
|
import org.sufficientlysecure.keychain.ui.util.Notify;
|
||||||
@@ -57,6 +58,7 @@ import org.sufficientlysecure.keychain.util.Log;
|
|||||||
import org.sufficientlysecure.keychain.util.Preferences;
|
import org.sufficientlysecure.keychain.util.Preferences;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
public class CertifyKeyFragment
|
public class CertifyKeyFragment
|
||||||
extends CachingCryptoOperationFragment<CertifyActionsParcel, CertifyResult>
|
extends CachingCryptoOperationFragment<CertifyActionsParcel, CertifyResult>
|
||||||
@@ -165,7 +167,7 @@ public class CertifyKeyFragment
|
|||||||
Notify.create(getActivity(), getString(R.string.select_key_to_certify),
|
Notify.create(getActivity(), getString(R.string.select_key_to_certify),
|
||||||
Notify.Style.ERROR).show();
|
Notify.Style.ERROR).show();
|
||||||
} else {
|
} else {
|
||||||
cryptoOperation();
|
cryptoOperation(new CryptoInputParcel(new Date()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
package org.sufficientlysecure.keychain.ui;
|
package org.sufficientlysecure.keychain.ui;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
@@ -47,6 +48,7 @@ import org.sufficientlysecure.keychain.service.ExportKeyringParcel;
|
|||||||
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.ChangeUnlockParcel;
|
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.ChangeUnlockParcel;
|
||||||
|
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||||
import org.sufficientlysecure.keychain.ui.CreateKeyActivity.FragAction;
|
import org.sufficientlysecure.keychain.ui.CreateKeyActivity.FragAction;
|
||||||
import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper;
|
import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
@@ -393,7 +395,7 @@ public class CreateKeyFinalFragment extends Fragment {
|
|||||||
|
|
||||||
|
|
||||||
mMoveToCardOpHelper = new CryptoOperationHelper<>(2, this, callback, R.string.progress_modify);
|
mMoveToCardOpHelper = new CryptoOperationHelper<>(2, this, callback, R.string.progress_modify);
|
||||||
mMoveToCardOpHelper.cryptoOperation();
|
mMoveToCardOpHelper.cryptoOperation(new CryptoInputParcel(new Date()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void uploadKey(final EditKeyResult saveKeyResult) {
|
private void uploadKey(final EditKeyResult saveKeyResult) {
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper;
|
|||||||
import org.sufficientlysecure.keychain.ui.dialog.CustomAlertDialogBuilder;
|
import org.sufficientlysecure.keychain.ui.dialog.CustomAlertDialogBuilder;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class DeleteKeyDialogActivity extends FragmentActivity {
|
public class DeleteKeyDialogActivity extends FragmentActivity {
|
||||||
@@ -134,7 +135,7 @@ public class DeleteKeyDialogActivity extends FragmentActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void startRevocationOperation() {
|
private void startRevocationOperation() {
|
||||||
mRevokeOpHelper.cryptoOperation(new CryptoInputParcel(false));
|
mRevokeOpHelper.cryptoOperation(new CryptoInputParcel(new Date(), false));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startDeletionOperation() {
|
private void startDeletionOperation() {
|
||||||
|
|||||||
@@ -68,6 +68,8 @@ import org.sufficientlysecure.keychain.ui.util.Notify;
|
|||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
public class EditKeyFragment extends QueueingCryptoOperationFragment<SaveKeyringParcel, OperationResult>
|
public class EditKeyFragment extends QueueingCryptoOperationFragment<SaveKeyringParcel, OperationResult>
|
||||||
implements LoaderManager.LoaderCallbacks<Cursor> {
|
implements LoaderManager.LoaderCallbacks<Cursor> {
|
||||||
|
|
||||||
@@ -151,7 +153,7 @@ public class EditKeyFragment extends QueueingCryptoOperationFragment<SaveKeyring
|
|||||||
if (mDataUri == null) {
|
if (mDataUri == null) {
|
||||||
returnKeyringParcel();
|
returnKeyringParcel();
|
||||||
} else {
|
} else {
|
||||||
cryptoOperation(new CryptoInputParcel());
|
cryptoOperation(new CryptoInputParcel(new Date()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, new OnClickListener() {
|
}, new OnClickListener() {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ package org.sufficientlysecure.keychain.ui;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -57,6 +58,7 @@ import org.sufficientlysecure.keychain.pgp.KeyRing;
|
|||||||
import org.sufficientlysecure.keychain.pgp.PgpConstants;
|
import org.sufficientlysecure.keychain.pgp.PgpConstants;
|
||||||
import org.sufficientlysecure.keychain.pgp.SignEncryptParcel;
|
import org.sufficientlysecure.keychain.pgp.SignEncryptParcel;
|
||||||
import org.sufficientlysecure.keychain.provider.TemporaryStorageProvider;
|
import org.sufficientlysecure.keychain.provider.TemporaryStorageProvider;
|
||||||
|
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.SpacesItemDecoration;
|
import org.sufficientlysecure.keychain.ui.adapter.SpacesItemDecoration;
|
||||||
import org.sufficientlysecure.keychain.ui.base.CachingCryptoOperationFragment;
|
import org.sufficientlysecure.keychain.ui.base.CachingCryptoOperationFragment;
|
||||||
import org.sufficientlysecure.keychain.ui.dialog.DeleteFileDialogFragment;
|
import org.sufficientlysecure.keychain.ui.dialog.DeleteFileDialogFragment;
|
||||||
@@ -279,19 +281,19 @@ public class EncryptFilesFragment
|
|||||||
case R.id.encrypt_save: {
|
case R.id.encrypt_save: {
|
||||||
hideKeyboard();
|
hideKeyboard();
|
||||||
mAfterEncryptAction = AfterEncryptAction.SAVE;
|
mAfterEncryptAction = AfterEncryptAction.SAVE;
|
||||||
cryptoOperation();
|
cryptoOperation(new CryptoInputParcel(new Date()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case R.id.encrypt_share: {
|
case R.id.encrypt_share: {
|
||||||
hideKeyboard();
|
hideKeyboard();
|
||||||
mAfterEncryptAction = AfterEncryptAction.SHARE;
|
mAfterEncryptAction = AfterEncryptAction.SHARE;
|
||||||
cryptoOperation();
|
cryptoOperation(new CryptoInputParcel(new Date()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case R.id.encrypt_copy: {
|
case R.id.encrypt_copy: {
|
||||||
hideKeyboard();
|
hideKeyboard();
|
||||||
mAfterEncryptAction = AfterEncryptAction.COPY;
|
mAfterEncryptAction = AfterEncryptAction.COPY;
|
||||||
cryptoOperation();
|
cryptoOperation(new CryptoInputParcel(new Date()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case R.id.check_use_armor: {
|
case R.id.check_use_armor: {
|
||||||
@@ -666,7 +668,7 @@ public class EncryptFilesFragment
|
|||||||
mOutputUris.add(data.getData());
|
mOutputUris.add(data.getData());
|
||||||
// make sure this is correct at this point
|
// make sure this is correct at this point
|
||||||
mAfterEncryptAction = AfterEncryptAction.SAVE;
|
mAfterEncryptAction = AfterEncryptAction.SAVE;
|
||||||
cryptoOperation();
|
cryptoOperation(new CryptoInputParcel(new Date()));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import org.sufficientlysecure.keychain.operations.results.SignEncryptResult;
|
|||||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||||
import org.sufficientlysecure.keychain.pgp.PgpConstants;
|
import org.sufficientlysecure.keychain.pgp.PgpConstants;
|
||||||
import org.sufficientlysecure.keychain.pgp.SignEncryptParcel;
|
import org.sufficientlysecure.keychain.pgp.SignEncryptParcel;
|
||||||
|
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||||
import org.sufficientlysecure.keychain.ui.base.CachingCryptoOperationFragment;
|
import org.sufficientlysecure.keychain.ui.base.CachingCryptoOperationFragment;
|
||||||
import org.sufficientlysecure.keychain.ui.util.Notify;
|
import org.sufficientlysecure.keychain.ui.util.Notify;
|
||||||
import org.sufficientlysecure.keychain.ui.util.Notify.ActionListener;
|
import org.sufficientlysecure.keychain.ui.util.Notify.ActionListener;
|
||||||
@@ -48,6 +49,7 @@ import org.sufficientlysecure.keychain.util.Passphrase;
|
|||||||
import org.sufficientlysecure.keychain.util.Preferences;
|
import org.sufficientlysecure.keychain.util.Preferences;
|
||||||
import org.sufficientlysecure.keychain.util.ShareHelper;
|
import org.sufficientlysecure.keychain.util.ShareHelper;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -168,13 +170,13 @@ public class EncryptTextFragment
|
|||||||
case R.id.encrypt_copy: {
|
case R.id.encrypt_copy: {
|
||||||
hideKeyboard();
|
hideKeyboard();
|
||||||
mShareAfterEncrypt = false;
|
mShareAfterEncrypt = false;
|
||||||
cryptoOperation();
|
cryptoOperation(new CryptoInputParcel(new Date()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case R.id.encrypt_share: {
|
case R.id.encrypt_share: {
|
||||||
hideKeyboard();
|
hideKeyboard();
|
||||||
mShareAfterEncrypt = true;
|
mShareAfterEncrypt = true;
|
||||||
cryptoOperation();
|
cryptoOperation(new CryptoInputParcel(new Date()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
|||||||
@@ -33,12 +33,15 @@ import org.sufficientlysecure.keychain.util.Preferences;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides a communication interface to OpenPGP applications on ISO SmartCard compliant
|
* This class provides a communication interface to OpenPGP applications on ISO SmartCard compliant
|
||||||
* NFC devices.
|
* NFC devices.
|
||||||
* <p/>
|
* <p/>
|
||||||
* For the full specs, see http://g10code.com/docs/openpgp-card-2.0.pdf
|
* For the full specs, see http://g10code.com/docs/openpgp-card-2.0.pdf
|
||||||
|
* NOTE: If no CryptoInputParcel is passed via EXTRA_CRYPTO_INPUT, the CryptoInputParcel is created
|
||||||
|
* internally and is NOT meant to be used by signing operations before adding signature time
|
||||||
*/
|
*/
|
||||||
public class NfcOperationActivity extends BaseNfcActivity {
|
public class NfcOperationActivity extends BaseNfcActivity {
|
||||||
|
|
||||||
@@ -73,7 +76,8 @@ public class NfcOperationActivity extends BaseNfcActivity {
|
|||||||
if (mInputParcel == null) {
|
if (mInputParcel == null) {
|
||||||
// for compatibility when used from OpenPgpService
|
// for compatibility when used from OpenPgpService
|
||||||
// (or any place other than CryptoOperationHelper)
|
// (or any place other than CryptoOperationHelper)
|
||||||
mInputParcel = new CryptoInputParcel(mRequiredInput.mSignatureTime);
|
// NOTE: This CryptoInputParcel cannot be used for signing without adding signature time
|
||||||
|
mInputParcel = new CryptoInputParcel();
|
||||||
}
|
}
|
||||||
|
|
||||||
setTitle(R.string.nfc_text);
|
setTitle(R.string.nfc_text);
|
||||||
@@ -131,6 +135,9 @@ public class NfcOperationActivity extends BaseNfcActivity {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case NFC_SIGN: {
|
case NFC_SIGN: {
|
||||||
|
if (mInputParcel.getSignatureTime() == null) {
|
||||||
|
mInputParcel.addSignatureTime(new Date());
|
||||||
|
}
|
||||||
for (int i = 0; i < mRequiredInput.mInputData.length; i++) {
|
for (int i = 0; i < mRequiredInput.mInputData.length; i++) {
|
||||||
byte[] hash = mRequiredInput.mInputData[i];
|
byte[] hash = mRequiredInput.mInputData[i];
|
||||||
int algo = mRequiredInput.mSignAlgos[i];
|
int algo = mRequiredInput.mSignAlgos[i];
|
||||||
|
|||||||
@@ -66,6 +66,8 @@ import org.sufficientlysecure.keychain.util.Preferences;
|
|||||||
/**
|
/**
|
||||||
* We can not directly create a dialog on the application context.
|
* We can not directly create a dialog on the application context.
|
||||||
* This activity encapsulates a DialogFragment to emulate a dialog.
|
* This activity encapsulates a DialogFragment to emulate a dialog.
|
||||||
|
* NOTE: If no CryptoInputParcel is passed via EXTRA_CRYPTO_INPUT, the CryptoInputParcel is created
|
||||||
|
* internally and is NOT meant to be used by signing operations before adding a signature time
|
||||||
*/
|
*/
|
||||||
public class PassphraseDialogActivity extends FragmentActivity {
|
public class PassphraseDialogActivity extends FragmentActivity {
|
||||||
public static final String RESULT_CRYPTO_INPUT = "result_data";
|
public static final String RESULT_CRYPTO_INPUT = "result_data";
|
||||||
@@ -97,6 +99,8 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
|||||||
|
|
||||||
if (mCryptoInputParcel == null) {
|
if (mCryptoInputParcel == null) {
|
||||||
// not all usages of PassphraseActivity are from CryptoInputOperation
|
// not all usages of PassphraseActivity are from CryptoInputOperation
|
||||||
|
// NOTE: This CryptoInputParcel cannot be used for signing operations without setting
|
||||||
|
// signature time
|
||||||
mCryptoInputParcel = new CryptoInputParcel();
|
mCryptoInputParcel = new CryptoInputParcel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,7 +127,8 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
|||||||
SecretKeyType.PASSPHRASE_EMPTY) {
|
SecretKeyType.PASSPHRASE_EMPTY) {
|
||||||
// also return passphrase back to activity
|
// also return passphrase back to activity
|
||||||
Intent returnIntent = new Intent();
|
Intent returnIntent = new Intent();
|
||||||
returnIntent.putExtra(RESULT_CRYPTO_INPUT, new CryptoInputParcel(new Passphrase("")));
|
mCryptoInputParcel.mPassphrase = new Passphrase("");
|
||||||
|
returnIntent.putExtra(RESULT_CRYPTO_INPUT, mCryptoInputParcel);
|
||||||
setResult(RESULT_OK, returnIntent);
|
setResult(RESULT_OK, returnIntent);
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ import org.sufficientlysecure.keychain.util.TestingUtils;
|
|||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.security.Security;
|
import java.security.Security;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
@RunWith(RobolectricGradleTestRunner.class)
|
@RunWith(RobolectricGradleTestRunner.class)
|
||||||
@@ -158,7 +159,7 @@ public class CertifyOperationTest {
|
|||||||
CertifyActionsParcel actions = new CertifyActionsParcel(mStaticRing1.getMasterKeyId());
|
CertifyActionsParcel actions = new CertifyActionsParcel(mStaticRing1.getMasterKeyId());
|
||||||
actions.add(new CertifyAction(mStaticRing2.getMasterKeyId(),
|
actions.add(new CertifyAction(mStaticRing2.getMasterKeyId(),
|
||||||
mStaticRing2.getPublicKey().getUnorderedUserIds()));
|
mStaticRing2.getPublicKey().getUnorderedUserIds()));
|
||||||
CertifyResult result = op.execute(actions, new CryptoInputParcel(mKeyPhrase1));
|
CertifyResult result = op.execute(actions, new CryptoInputParcel(new Date(), mKeyPhrase1));
|
||||||
|
|
||||||
Assert.assertTrue("certification must succeed", result.success());
|
Assert.assertTrue("certification must succeed", result.success());
|
||||||
|
|
||||||
@@ -186,7 +187,7 @@ public class CertifyOperationTest {
|
|||||||
CertifyActionsParcel actions = new CertifyActionsParcel(mStaticRing1.getMasterKeyId());
|
CertifyActionsParcel actions = new CertifyActionsParcel(mStaticRing1.getMasterKeyId());
|
||||||
actions.add(new CertifyAction(mStaticRing2.getMasterKeyId(), null,
|
actions.add(new CertifyAction(mStaticRing2.getMasterKeyId(), null,
|
||||||
mStaticRing2.getPublicKey().getUnorderedUserAttributes()));
|
mStaticRing2.getPublicKey().getUnorderedUserAttributes()));
|
||||||
CertifyResult result = op.execute(actions, new CryptoInputParcel(mKeyPhrase1));
|
CertifyResult result = op.execute(actions, new CryptoInputParcel(new Date(), mKeyPhrase1));
|
||||||
|
|
||||||
Assert.assertTrue("certification must succeed", result.success());
|
Assert.assertTrue("certification must succeed", result.success());
|
||||||
|
|
||||||
@@ -209,7 +210,7 @@ public class CertifyOperationTest {
|
|||||||
actions.add(new CertifyAction(mStaticRing1.getMasterKeyId(),
|
actions.add(new CertifyAction(mStaticRing1.getMasterKeyId(),
|
||||||
mStaticRing2.getPublicKey().getUnorderedUserIds()));
|
mStaticRing2.getPublicKey().getUnorderedUserIds()));
|
||||||
|
|
||||||
CertifyResult result = op.execute(actions, new CryptoInputParcel(mKeyPhrase1));
|
CertifyResult result = op.execute(actions, new CryptoInputParcel(new Date(), mKeyPhrase1));
|
||||||
|
|
||||||
Assert.assertFalse("certification with itself must fail!", result.success());
|
Assert.assertFalse("certification with itself must fail!", result.success());
|
||||||
Assert.assertTrue("error msg must be about self certification",
|
Assert.assertTrue("error msg must be about self certification",
|
||||||
@@ -228,7 +229,8 @@ public class CertifyOperationTest {
|
|||||||
uids.add("nonexistent");
|
uids.add("nonexistent");
|
||||||
actions.add(new CertifyAction(1234L, uids));
|
actions.add(new CertifyAction(1234L, uids));
|
||||||
|
|
||||||
CertifyResult result = op.execute(actions, new CryptoInputParcel(mKeyPhrase1));
|
CertifyResult result = op.execute(actions, new CryptoInputParcel(new Date(),
|
||||||
|
mKeyPhrase1));
|
||||||
|
|
||||||
Assert.assertFalse("certification of nonexistent key must fail", result.success());
|
Assert.assertFalse("certification of nonexistent key must fail", result.success());
|
||||||
Assert.assertTrue("must contain error msg about not found",
|
Assert.assertTrue("must contain error msg about not found",
|
||||||
@@ -240,7 +242,8 @@ public class CertifyOperationTest {
|
|||||||
actions.add(new CertifyAction(mStaticRing1.getMasterKeyId(),
|
actions.add(new CertifyAction(mStaticRing1.getMasterKeyId(),
|
||||||
mStaticRing2.getPublicKey().getUnorderedUserIds()));
|
mStaticRing2.getPublicKey().getUnorderedUserIds()));
|
||||||
|
|
||||||
CertifyResult result = op.execute(actions, new CryptoInputParcel(mKeyPhrase1));
|
CertifyResult result = op.execute(actions, new CryptoInputParcel(new Date(),
|
||||||
|
mKeyPhrase1));
|
||||||
|
|
||||||
Assert.assertFalse("certification of nonexistent key must fail", result.success());
|
Assert.assertFalse("certification of nonexistent key must fail", result.success());
|
||||||
Assert.assertTrue("must contain error msg about not found",
|
Assert.assertTrue("must contain error msg about not found",
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import java.security.Security;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -160,7 +161,8 @@ public class PgpEncryptDecryptTest {
|
|||||||
b.setSymmetricPassphrase(mPassphrase);
|
b.setSymmetricPassphrase(mPassphrase);
|
||||||
b.setSymmetricEncryptionAlgorithm(PGPEncryptedData.AES_128);
|
b.setSymmetricEncryptionAlgorithm(PGPEncryptedData.AES_128);
|
||||||
|
|
||||||
PgpSignEncryptResult result = op.execute(b, new CryptoInputParcel(), data, out);
|
PgpSignEncryptResult result = op.execute(b, new CryptoInputParcel(new Date()),
|
||||||
|
data, out);
|
||||||
|
|
||||||
Assert.assertTrue("encryption must succeed", result.success());
|
Assert.assertTrue("encryption must succeed", result.success());
|
||||||
|
|
||||||
@@ -269,7 +271,8 @@ public class PgpEncryptDecryptTest {
|
|||||||
|
|
||||||
input.setEncryptionMasterKeyIds(new long[] { mStaticRing1.getMasterKeyId() });
|
input.setEncryptionMasterKeyIds(new long[] { mStaticRing1.getMasterKeyId() });
|
||||||
input.setSymmetricEncryptionAlgorithm(PGPEncryptedData.AES_128);
|
input.setSymmetricEncryptionAlgorithm(PGPEncryptedData.AES_128);
|
||||||
PgpSignEncryptResult result = op.execute(input, new CryptoInputParcel(), data, out);
|
PgpSignEncryptResult result = op.execute(input, new CryptoInputParcel(new Date()),
|
||||||
|
data, out);
|
||||||
Assert.assertTrue("encryption must succeed", result.success());
|
Assert.assertTrue("encryption must succeed", result.success());
|
||||||
|
|
||||||
ciphertext = out.toByteArray();
|
ciphertext = out.toByteArray();
|
||||||
@@ -359,7 +362,8 @@ public class PgpEncryptDecryptTest {
|
|||||||
|
|
||||||
input.setEncryptionMasterKeyIds(new long[] { mStaticRing1.getMasterKeyId() });
|
input.setEncryptionMasterKeyIds(new long[] { mStaticRing1.getMasterKeyId() });
|
||||||
input.setSymmetricEncryptionAlgorithm(PGPEncryptedData.AES_128);
|
input.setSymmetricEncryptionAlgorithm(PGPEncryptedData.AES_128);
|
||||||
PgpSignEncryptResult result = op.execute(input, new CryptoInputParcel(), data, out);
|
PgpSignEncryptResult result = op.execute(input, new CryptoInputParcel(new Date()),
|
||||||
|
data, out);
|
||||||
Assert.assertTrue("encryption must succeed", result.success());
|
Assert.assertTrue("encryption must succeed", result.success());
|
||||||
|
|
||||||
ciphertext = out.toByteArray();
|
ciphertext = out.toByteArray();
|
||||||
@@ -393,7 +397,8 @@ public class PgpEncryptDecryptTest {
|
|||||||
SaveKeyringParcel parcel = new SaveKeyringParcel(mStaticRing1.getMasterKeyId(), mStaticRing1.getFingerprint());
|
SaveKeyringParcel parcel = new SaveKeyringParcel(mStaticRing1.getMasterKeyId(), mStaticRing1.getFingerprint());
|
||||||
parcel.mRevokeSubKeys.add(KeyringTestingHelper.getSubkeyId(mStaticRing1, 2));
|
parcel.mRevokeSubKeys.add(KeyringTestingHelper.getSubkeyId(mStaticRing1, 2));
|
||||||
UncachedKeyRing modified = PgpKeyOperationTest.applyModificationWithChecks(parcel, mStaticRing1,
|
UncachedKeyRing modified = PgpKeyOperationTest.applyModificationWithChecks(parcel, mStaticRing1,
|
||||||
new ArrayList<RawPacket>(), new ArrayList<RawPacket>(), new CryptoInputParcel(mKeyPhrase1));
|
new ArrayList<RawPacket>(), new ArrayList<RawPacket>(),
|
||||||
|
new CryptoInputParcel(new Date(), mKeyPhrase1));
|
||||||
|
|
||||||
ProviderHelper providerHelper = new ProviderHelper(RuntimeEnvironment.application);
|
ProviderHelper providerHelper = new ProviderHelper(RuntimeEnvironment.application);
|
||||||
providerHelper.saveSecretKeyRing(modified, new ProgressScaler());
|
providerHelper.saveSecretKeyRing(modified, new ProgressScaler());
|
||||||
@@ -413,7 +418,8 @@ public class PgpEncryptDecryptTest {
|
|||||||
|
|
||||||
input.setEncryptionMasterKeyIds(new long[] { mStaticRing1.getMasterKeyId() });
|
input.setEncryptionMasterKeyIds(new long[] { mStaticRing1.getMasterKeyId() });
|
||||||
input.setSymmetricEncryptionAlgorithm(PGPEncryptedData.AES_128);
|
input.setSymmetricEncryptionAlgorithm(PGPEncryptedData.AES_128);
|
||||||
PgpSignEncryptResult result = op.execute(input, new CryptoInputParcel(), data, out);
|
PgpSignEncryptResult result = op.execute(input, new CryptoInputParcel(new Date()),
|
||||||
|
data, out);
|
||||||
Assert.assertTrue("encryption must succeed", result.success());
|
Assert.assertTrue("encryption must succeed", result.success());
|
||||||
|
|
||||||
ciphertext = out.toByteArray();
|
ciphertext = out.toByteArray();
|
||||||
@@ -457,7 +463,8 @@ public class PgpEncryptDecryptTest {
|
|||||||
});
|
});
|
||||||
b.setSymmetricEncryptionAlgorithm(PGPEncryptedData.AES_128);
|
b.setSymmetricEncryptionAlgorithm(PGPEncryptedData.AES_128);
|
||||||
|
|
||||||
PgpSignEncryptResult result = op.execute(b, new CryptoInputParcel(), data, out);
|
PgpSignEncryptResult result = op.execute(b, new CryptoInputParcel(new Date()),
|
||||||
|
data, out);
|
||||||
Assert.assertTrue("encryption must succeed", result.success());
|
Assert.assertTrue("encryption must succeed", result.success());
|
||||||
|
|
||||||
ciphertext = out.toByteArray();
|
ciphertext = out.toByteArray();
|
||||||
@@ -575,7 +582,8 @@ public class PgpEncryptDecryptTest {
|
|||||||
b.setSignatureSubKeyId(KeyringTestingHelper.getSubkeyId(mStaticRing1, 1));
|
b.setSignatureSubKeyId(KeyringTestingHelper.getSubkeyId(mStaticRing1, 1));
|
||||||
b.setSymmetricEncryptionAlgorithm(PGPEncryptedData.AES_128);
|
b.setSymmetricEncryptionAlgorithm(PGPEncryptedData.AES_128);
|
||||||
|
|
||||||
PgpSignEncryptResult result = op.execute(b, new CryptoInputParcel(mKeyPhrase1), data, out);
|
PgpSignEncryptResult result = op.execute(b,
|
||||||
|
new CryptoInputParcel(new Date(), mKeyPhrase1), data, out);
|
||||||
Assert.assertTrue("encryption must succeed", result.success());
|
Assert.assertTrue("encryption must succeed", result.success());
|
||||||
|
|
||||||
ciphertext = out.toByteArray();
|
ciphertext = out.toByteArray();
|
||||||
@@ -655,7 +663,8 @@ public class PgpEncryptDecryptTest {
|
|||||||
// this only works with ascii armored output!
|
// this only works with ascii armored output!
|
||||||
b.setEnableAsciiArmorOutput(true);
|
b.setEnableAsciiArmorOutput(true);
|
||||||
b.setCharset("iso-2022-jp");
|
b.setCharset("iso-2022-jp");
|
||||||
PgpSignEncryptResult result = op.execute(b, new CryptoInputParcel(), data, out);
|
PgpSignEncryptResult result = op.execute(b, new CryptoInputParcel(new Date()),
|
||||||
|
data, out);
|
||||||
Assert.assertTrue("encryption must succeed", result.success());
|
Assert.assertTrue("encryption must succeed", result.success());
|
||||||
|
|
||||||
ciphertext = out.toByteArray();
|
ciphertext = out.toByteArray();
|
||||||
|
|||||||
@@ -554,7 +554,7 @@ public class UncachedKeyringCanonicalizeTest {
|
|||||||
CanonicalizedSecretKey masterSecretKey = canonicalized.getSecretKey();
|
CanonicalizedSecretKey masterSecretKey = canonicalized.getSecretKey();
|
||||||
masterSecretKey.unlock(new Passphrase());
|
masterSecretKey.unlock(new Passphrase());
|
||||||
PGPPublicKey masterPublicKey = masterSecretKey.getPublicKey();
|
PGPPublicKey masterPublicKey = masterSecretKey.getPublicKey();
|
||||||
CryptoInputParcel cryptoInput = new CryptoInputParcel();
|
CryptoInputParcel cryptoInput = new CryptoInputParcel(new Date());
|
||||||
PGPSignature cert = PgpKeyOperation.generateSubkeyBindingSignature(
|
PGPSignature cert = PgpKeyOperation.generateSubkeyBindingSignature(
|
||||||
PgpKeyOperation.getSignatureGenerator(masterSecretKey.getSecretKey(), cryptoInput),
|
PgpKeyOperation.getSignatureGenerator(masterSecretKey.getSecretKey(), cryptoInput),
|
||||||
cryptoInput.getSignatureTime(),
|
cryptoInput.getSignatureTime(),
|
||||||
|
|||||||
@@ -194,11 +194,11 @@ public class UncachedKeyringMergeTest {
|
|||||||
|
|
||||||
parcel.reset();
|
parcel.reset();
|
||||||
parcel.mAddUserIds.add("flim");
|
parcel.mAddUserIds.add("flim");
|
||||||
modifiedA = op.modifySecretKeyRing(secretRing, new CryptoInputParcel(new Passphrase()), parcel).getRing();
|
modifiedA = op.modifySecretKeyRing(secretRing, new CryptoInputParcel(new Date(), new Passphrase()), parcel).getRing();
|
||||||
|
|
||||||
parcel.reset();
|
parcel.reset();
|
||||||
parcel.mAddUserIds.add("flam");
|
parcel.mAddUserIds.add("flam");
|
||||||
modifiedB = op.modifySecretKeyRing(secretRing, new CryptoInputParcel(new Passphrase()), parcel).getRing();
|
modifiedB = op.modifySecretKeyRing(secretRing, new CryptoInputParcel(new Date(), new Passphrase()), parcel).getRing();
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // merge A into base
|
{ // merge A into base
|
||||||
@@ -235,8 +235,8 @@ public class UncachedKeyringMergeTest {
|
|||||||
parcel.reset();
|
parcel.reset();
|
||||||
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||||
Algorithm.RSA, 1024, null, KeyFlags.SIGN_DATA, 0L));
|
Algorithm.RSA, 1024, null, KeyFlags.SIGN_DATA, 0L));
|
||||||
modifiedA = op.modifySecretKeyRing(secretRing, new CryptoInputParcel(new Passphrase()), parcel).getRing();
|
modifiedA = op.modifySecretKeyRing(secretRing, new CryptoInputParcel(new Date(), new Passphrase()), parcel).getRing();
|
||||||
modifiedB = op.modifySecretKeyRing(secretRing, new CryptoInputParcel(new Passphrase()), parcel).getRing();
|
modifiedB = op.modifySecretKeyRing(secretRing, new CryptoInputParcel(new Date(), new Passphrase()), parcel).getRing();
|
||||||
|
|
||||||
subKeyIdA = KeyringTestingHelper.getSubkeyId(modifiedA, 2);
|
subKeyIdA = KeyringTestingHelper.getSubkeyId(modifiedA, 2);
|
||||||
subKeyIdB = KeyringTestingHelper.getSubkeyId(modifiedB, 2);
|
subKeyIdB = KeyringTestingHelper.getSubkeyId(modifiedB, 2);
|
||||||
@@ -277,7 +277,7 @@ public class UncachedKeyringMergeTest {
|
|||||||
parcel.mRevokeSubKeys.add(KeyringTestingHelper.getSubkeyId(ringA, 1));
|
parcel.mRevokeSubKeys.add(KeyringTestingHelper.getSubkeyId(ringA, 1));
|
||||||
CanonicalizedSecretKeyRing secretRing = new CanonicalizedSecretKeyRing(
|
CanonicalizedSecretKeyRing secretRing = new CanonicalizedSecretKeyRing(
|
||||||
ringA.getEncoded(), false, 0);
|
ringA.getEncoded(), false, 0);
|
||||||
modified = op.modifySecretKeyRing(secretRing, new CryptoInputParcel(new Passphrase()), parcel).getRing();
|
modified = op.modifySecretKeyRing(secretRing, new CryptoInputParcel(new Date(), new Passphrase()), parcel).getRing();
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -376,7 +376,7 @@ public class UncachedKeyringMergeTest {
|
|||||||
|
|
||||||
CanonicalizedSecretKeyRing secretRing = new CanonicalizedSecretKeyRing(
|
CanonicalizedSecretKeyRing secretRing = new CanonicalizedSecretKeyRing(
|
||||||
ringA.getEncoded(), false, 0);
|
ringA.getEncoded(), false, 0);
|
||||||
modified = op.modifySecretKeyRing(secretRing, new CryptoInputParcel(new Passphrase()), parcel).getRing();
|
modified = op.modifySecretKeyRing(secretRing, new CryptoInputParcel(new Date(), new Passphrase()), parcel).getRing();
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user