use autovalue for PgpSignEncryptData class

This commit is contained in:
Vincent Breitmoser
2017-05-15 15:52:18 +02:00
parent 97ac237ac3
commit 368528e9dd
9 changed files with 150 additions and 311 deletions

View File

@@ -170,11 +170,11 @@ public class BackupOperation extends BaseOperation<BackupKeyringParcel> {
throws FileNotFoundException {
PgpSignEncryptOperation signEncryptOperation = new PgpSignEncryptOperation(mContext, mKeyRepository, mProgressable, mCancelled);
PgpSignEncryptData data = new PgpSignEncryptData();
PgpSignEncryptData.Builder data = PgpSignEncryptData.builder();
data.setSymmetricPassphrase(cryptoInput.getPassphrase());
data.setEnableAsciiArmorOutput(backupInput.mEnableAsciiArmorOutput);
data.setAddBackupHeader(true);
PgpSignEncryptInputParcel inputParcel = new PgpSignEncryptInputParcel(data);
PgpSignEncryptInputParcel inputParcel = new PgpSignEncryptInputParcel(data.build());
InputStream inStream = mContext.getContentResolver().openInputStream(plainUri);

View File

@@ -83,10 +83,10 @@ public class BenchmarkOperation extends BaseOperation<BenchmarkInputParcel> {
SignEncryptOperation op =
new SignEncryptOperation(mContext, mKeyRepository,
new ProgressScaler(mProgressable, i*(50/numRepeats), (i+1)*(50/numRepeats), 100), mCancelled);
PgpSignEncryptData data = new PgpSignEncryptData();
PgpSignEncryptData.Builder data = PgpSignEncryptData.builder();
data.setSymmetricPassphrase(passphrase);
data.setSymmetricEncryptionAlgorithm(OpenKeychainSymmetricKeyAlgorithmTags.AES_128);
SignEncryptParcel input = new SignEncryptParcel(data);
SignEncryptParcel input = new SignEncryptParcel(data.build());
input.setBytes(buf);
encryptResult = op.execute(input, new CryptoInputParcel());
log.add(encryptResult, 1);

View File

@@ -77,18 +77,6 @@ public class SignEncryptOperation extends BaseOperation<SignEncryptParcel> {
SecurityTokenSignOperationsBuilder pendingInputBuilder = null;
PgpSignEncryptData data = input.getData();
// if signing subkey has not explicitly been set, get first usable subkey capable of signing
if (data.getSignatureMasterKeyId() != Constants.key.none
&& data.getSignatureSubKeyId() == null) {
try {
long signKeyId = mKeyRepository.getCachedPublicKeyRing(
data.getSignatureMasterKeyId()).getSecretSignId();
data.setSignatureSubKeyId(signKeyId);
} catch (PgpKeyNotFoundException e) {
Log.e(Constants.TAG, "Key not found", e);
return new SignEncryptResult(SignEncryptResult.RESULT_ERROR, log, results);
}
}
do {
if (checkCancelled()) {

View File

@@ -18,226 +18,73 @@
package org.sufficientlysecure.keychain.pgp;
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.bouncycastle.bcpg.CompressionAlgorithmTags;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.util.Passphrase;
@AutoValue
public abstract class PgpSignEncryptData implements Parcelable {
@Nullable
public abstract String getCharset();
abstract long getAdditionalEncryptId();
abstract int getSignatureHashAlgorithm();
@Nullable
public abstract Long getSignatureSubKeyId();
public abstract long getSignatureMasterKeyId();
public abstract int getSymmetricEncryptionAlgorithm();
@Nullable
public abstract Passphrase getSymmetricPassphrase();
@Nullable
public abstract long[] getEncryptionMasterKeyIds();
public abstract int getCompressionAlgorithm();
@Nullable
public abstract String getVersionHeader();
public class PgpSignEncryptData implements Parcelable {
private String mVersionHeader = null;
private boolean mEnableAsciiArmorOutput = false;
private int mCompressionAlgorithm = CompressionAlgorithmTags.UNCOMPRESSED;
private long[] mEncryptionMasterKeyIds = null;
private Passphrase mSymmetricPassphrase = null;
private int mSymmetricEncryptionAlgorithm = PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.USE_DEFAULT;
private long mSignatureMasterKeyId = Constants.key.none;
private Long mSignatureSubKeyId = null;
private int mSignatureHashAlgorithm = PgpSecurityConstants.OpenKeychainHashAlgorithmTags.USE_DEFAULT;
private long mAdditionalEncryptId = Constants.key.none;
private String mCharset;
private boolean mCleartextSignature;
private boolean mDetachedSignature = false;
private boolean mHiddenRecipients = false;
private boolean mAddBackupHeader = false;
public abstract boolean isEnableAsciiArmorOutput();
public abstract boolean isCleartextSignature();
public abstract boolean isDetachedSignature();
public abstract boolean isAddBackupHeader();
public abstract boolean isHiddenRecipients();
public PgpSignEncryptData(){
public static Builder builder() {
return new AutoValue_PgpSignEncryptData.Builder()
.setCompressionAlgorithm(CompressionAlgorithmTags.UNCOMPRESSED)
.setSymmetricEncryptionAlgorithm(PgpSecurityConstants.DEFAULT_SYMMETRIC_ALGORITHM)
.setSignatureMasterKeyId(Constants.key.none)
.setSignatureHashAlgorithm(PgpSecurityConstants.DEFAULT_HASH_ALGORITHM)
.setAdditionalEncryptId(Constants.key.none)
.setEnableAsciiArmorOutput(false)
.setCleartextSignature(false)
.setDetachedSignature(false)
.setAddBackupHeader(false)
.setHiddenRecipients(false);
}
private PgpSignEncryptData(Parcel source) {
ClassLoader loader = getClass().getClassLoader();
@AutoValue.Builder
public abstract static class Builder {
public abstract PgpSignEncryptData build();
mVersionHeader = source.readString();
mEnableAsciiArmorOutput = source.readInt() == 1;
mCompressionAlgorithm = source.readInt();
mEncryptionMasterKeyIds = source.createLongArray();
mSymmetricPassphrase = source.readParcelable(loader);
mSymmetricEncryptionAlgorithm = source.readInt();
mSignatureMasterKeyId = source.readLong();
mSignatureSubKeyId = source.readInt() == 1 ? source.readLong() : null;
mSignatureHashAlgorithm = source.readInt();
mAdditionalEncryptId = source.readLong();
mCharset = source.readString();
mCleartextSignature = source.readInt() == 1;
mDetachedSignature = source.readInt() == 1;
mHiddenRecipients = source.readInt() == 1;
mAddBackupHeader = source.readInt() == 1;
public abstract Builder setCharset(String charset);
public abstract Builder setAdditionalEncryptId(long additionalEncryptId);
public abstract Builder setSignatureHashAlgorithm(int signatureHashAlgorithm);
public abstract Builder setSignatureSubKeyId(Long signatureSubKeyId);
public abstract Builder setSignatureMasterKeyId(long signatureMasterKeyId);
public abstract Builder setSymmetricEncryptionAlgorithm(int symmetricEncryptionAlgorithm);
public abstract Builder setSymmetricPassphrase(Passphrase symmetricPassphrase);
public abstract Builder setEncryptionMasterKeyIds(long[] encryptionMasterKeyIds);
public abstract Builder setCompressionAlgorithm(int compressionAlgorithm);
public abstract Builder setVersionHeader(String versionHeader);
public abstract Builder setAddBackupHeader(boolean isAddBackupHeader);
public abstract Builder setEnableAsciiArmorOutput(boolean enableAsciiArmorOutput);
public abstract Builder setCleartextSignature(boolean isCleartextSignature);
public abstract Builder setDetachedSignature(boolean isDetachedSignature);
public abstract Builder setHiddenRecipients(boolean isHiddenRecipients);
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(mVersionHeader);
dest.writeInt(mEnableAsciiArmorOutput ? 1 : 0);
dest.writeInt(mCompressionAlgorithm);
dest.writeLongArray(mEncryptionMasterKeyIds);
dest.writeParcelable(mSymmetricPassphrase, 0);
dest.writeInt(mSymmetricEncryptionAlgorithm);
dest.writeLong(mSignatureMasterKeyId);
if (mSignatureSubKeyId != null) {
dest.writeInt(1);
dest.writeLong(mSignatureSubKeyId);
} else {
dest.writeInt(0);
}
dest.writeInt(mSignatureHashAlgorithm);
dest.writeLong(mAdditionalEncryptId);
dest.writeString(mCharset);
dest.writeInt(mCleartextSignature ? 1 : 0);
dest.writeInt(mDetachedSignature ? 1 : 0);
dest.writeInt(mHiddenRecipients ? 1 : 0);
dest.writeInt(mAddBackupHeader ? 1 : 0);
}
public String getCharset() {
return mCharset;
}
public void setCharset(String mCharset) {
this.mCharset = mCharset;
}
public long getAdditionalEncryptId() {
return mAdditionalEncryptId;
}
public PgpSignEncryptData setAdditionalEncryptId(long additionalEncryptId) {
mAdditionalEncryptId = additionalEncryptId;
return this;
}
public int getSignatureHashAlgorithm() {
return mSignatureHashAlgorithm;
}
public PgpSignEncryptData setSignatureHashAlgorithm(int signatureHashAlgorithm) {
mSignatureHashAlgorithm = signatureHashAlgorithm;
return this;
}
public Long getSignatureSubKeyId() {
return mSignatureSubKeyId;
}
public PgpSignEncryptData setSignatureSubKeyId(long signatureSubKeyId) {
mSignatureSubKeyId = signatureSubKeyId;
return this;
}
public long getSignatureMasterKeyId() {
return mSignatureMasterKeyId;
}
public PgpSignEncryptData setSignatureMasterKeyId(long signatureMasterKeyId) {
mSignatureMasterKeyId = signatureMasterKeyId;
return this;
}
public int getSymmetricEncryptionAlgorithm() {
return mSymmetricEncryptionAlgorithm;
}
public PgpSignEncryptData setSymmetricEncryptionAlgorithm(int symmetricEncryptionAlgorithm) {
mSymmetricEncryptionAlgorithm = symmetricEncryptionAlgorithm;
return this;
}
public Passphrase getSymmetricPassphrase() {
return mSymmetricPassphrase;
}
public PgpSignEncryptData setSymmetricPassphrase(Passphrase symmetricPassphrase) {
mSymmetricPassphrase = symmetricPassphrase;
return this;
}
public long[] getEncryptionMasterKeyIds() {
return mEncryptionMasterKeyIds;
}
public PgpSignEncryptData setEncryptionMasterKeyIds(long[] encryptionMasterKeyIds) {
mEncryptionMasterKeyIds = encryptionMasterKeyIds;
return this;
}
public int getCompressionAlgorithm() {
return mCompressionAlgorithm;
}
public PgpSignEncryptData setCompressionAlgorithm(int compressionAlgorithm) {
mCompressionAlgorithm = compressionAlgorithm;
return this;
}
public boolean isEnableAsciiArmorOutput() {
return mEnableAsciiArmorOutput;
}
public String getVersionHeader() {
return mVersionHeader;
}
public PgpSignEncryptData setVersionHeader(String versionHeader) {
mVersionHeader = versionHeader;
return this;
}
public PgpSignEncryptData setEnableAsciiArmorOutput(boolean enableAsciiArmorOutput) {
mEnableAsciiArmorOutput = enableAsciiArmorOutput;
return this;
}
public PgpSignEncryptData setCleartextSignature(boolean cleartextSignature) {
this.mCleartextSignature = cleartextSignature;
return this;
}
public boolean isCleartextSignature() {
return mCleartextSignature;
}
public PgpSignEncryptData setDetachedSignature(boolean detachedSignature) {
this.mDetachedSignature = detachedSignature;
return this;
}
public boolean isDetachedSignature() {
return mDetachedSignature;
}
public PgpSignEncryptData setHiddenRecipients(boolean hiddenRecipients) {
this.mHiddenRecipients = hiddenRecipients;
return this;
}
public PgpSignEncryptData setAddBackupHeader(boolean addBackupHeader) {
this.mAddBackupHeader = addBackupHeader;
return this;
}
public boolean isAddBackupHeader() {
return mAddBackupHeader;
}
public boolean isHiddenRecipients() {
return mHiddenRecipients;
}
public static final Creator<PgpSignEncryptData> CREATOR = new Creator<PgpSignEncryptData>() {
public PgpSignEncryptData createFromParcel(final Parcel source) {
return new PgpSignEncryptData(source);
}
public PgpSignEncryptData[] newArray(final int size) {
return new PgpSignEncryptData[size];
}
};
}

View File

@@ -19,6 +19,23 @@
package org.sufficientlysecure.keychain.pgp;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.security.SignatureException;
import java.util.Date;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import android.content.Context;
import android.net.Uri;
import android.support.annotation.NonNull;
@@ -56,23 +73,6 @@ import org.sufficientlysecure.keychain.util.Log;
import org.sufficientlysecure.keychain.util.Passphrase;
import org.sufficientlysecure.keychain.util.ProgressScaler;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.security.SignatureException;
import java.util.Arrays;
import java.util.Date;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* This class supports a single, low-level, sign/encrypt operation.
* <p/>
@@ -187,12 +187,6 @@ public class PgpSignEncryptOperation extends BaseOperation<PgpSignEncryptInputPa
+ "\nenableAsciiArmorOutput:" + data.isEnableAsciiArmorOutput()
+ "\nisHiddenRecipients:" + data.isHiddenRecipients());
// add additional key id to encryption ids (mostly to do self-encryption)
if (enableEncryption && data.getAdditionalEncryptId() != Constants.key.none) {
data.setEncryptionMasterKeyIds(Arrays.copyOf(data.getEncryptionMasterKeyIds(), data.getEncryptionMasterKeyIds().length + 1));
data.getEncryptionMasterKeyIds()[data.getEncryptionMasterKeyIds().length - 1] = data.getAdditionalEncryptId();
}
ArmoredOutputStream armorOut = null;
OutputStream out;
if (data.isEnableAsciiArmorOutput()) {
@@ -300,12 +294,6 @@ public class PgpSignEncryptOperation extends BaseOperation<PgpSignEncryptInputPa
log.add(LogType.MSG_PSE_ERROR_UNLOCK, indent);
return new PgpSignEncryptResult(PgpSignEncryptResult.RESULT_ERROR, log);
}
// Use requested hash algo
int requestedAlgorithm = data.getSignatureHashAlgorithm();
if (requestedAlgorithm == PgpSecurityConstants.OpenKeychainHashAlgorithmTags.USE_DEFAULT) {
data.setSignatureHashAlgorithm(PgpSecurityConstants.DEFAULT_HASH_ALGORITHM);
}
}
updateProgress(R.string.progress_preparing_streams, 2, 100);
@@ -336,30 +324,17 @@ public class PgpSignEncryptOperation extends BaseOperation<PgpSignEncryptInputPa
log.add(LogType.MSG_PSE_ASYMMETRIC, indent);
// Asymmetric encryption
for (long id : data.getEncryptionMasterKeyIds()) {
try {
CanonicalizedPublicKeyRing keyRing = mKeyRepository.getCanonicalizedPublicKeyRing(
KeyRings.buildUnifiedKeyRingUri(id));
Set<Long> encryptSubKeyIds = keyRing.getEncryptIds();
for (Long subKeyId : encryptSubKeyIds) {
CanonicalizedPublicKey key = keyRing.getPublicKey(subKeyId);
cPk.addMethod(key.getPubKeyEncryptionGenerator(data.isHiddenRecipients()));
log.add(LogType.MSG_PSE_KEY_OK, indent + 1,
KeyFormattingUtils.convertKeyIdToHex(subKeyId));
}
if (encryptSubKeyIds.isEmpty()) {
log.add(LogType.MSG_PSE_KEY_WARN, indent + 1,
KeyFormattingUtils.convertKeyIdToHex(id));
return new PgpSignEncryptResult(PgpSignEncryptResult.RESULT_ERROR, log);
}
// Make sure key is not expired or revoked
if (keyRing.isExpired() || keyRing.isRevoked()) {
log.add(LogType.MSG_PSE_ERROR_REVOKED_OR_EXPIRED, indent);
return new PgpSignEncryptResult(PgpSignEncryptResult.RESULT_ERROR, log);
}
} catch (KeyWritableRepository.NotFoundException e) {
log.add(LogType.MSG_PSE_KEY_UNKNOWN, indent + 1,
KeyFormattingUtils.convertKeyIdToHex(id));
for (long encryptMasterKeyId : data.getEncryptionMasterKeyIds()) {
boolean success = processEncryptionMasterKeyId(indent, log, data, cPk, encryptMasterKeyId);
if (!success) {
return new PgpSignEncryptResult(PgpSignEncryptResult.RESULT_ERROR, log);
}
}
long additionalEncryptId = data.getAdditionalEncryptId();
if (additionalEncryptId != Constants.key.none) {
boolean success = processEncryptionMasterKeyId(indent, log, data, cPk, additionalEncryptId);
if (!success) {
return new PgpSignEncryptResult(PgpSignEncryptResult.RESULT_ERROR, log);
}
}
@@ -663,6 +638,36 @@ public class PgpSignEncryptOperation extends BaseOperation<PgpSignEncryptInputPa
return result;
}
private boolean processEncryptionMasterKeyId(int indent, OperationLog log, PgpSignEncryptData data,
PGPEncryptedDataGenerator cPk, long encryptMasterKeyId) {
try {
CanonicalizedPublicKeyRing keyRing = mKeyRepository.getCanonicalizedPublicKeyRing(
KeyRings.buildUnifiedKeyRingUri(encryptMasterKeyId));
Set<Long> encryptSubKeyIds = keyRing.getEncryptIds();
for (Long subKeyId : encryptSubKeyIds) {
CanonicalizedPublicKey key = keyRing.getPublicKey(subKeyId);
cPk.addMethod(key.getPubKeyEncryptionGenerator(data.isHiddenRecipients()));
log.add(LogType.MSG_PSE_KEY_OK, indent + 1,
KeyFormattingUtils.convertKeyIdToHex(subKeyId));
}
if (encryptSubKeyIds.isEmpty()) {
log.add(LogType.MSG_PSE_KEY_WARN, indent + 1,
KeyFormattingUtils.convertKeyIdToHex(encryptMasterKeyId));
return false;
}
// Make sure key is not expired or revoked
if (keyRing.isExpired() || keyRing.isRevoked()) {
log.add(LogType.MSG_PSE_ERROR_REVOKED_OR_EXPIRED, indent);
return false;
}
} catch (KeyWritableRepository.NotFoundException e) {
log.add(LogType.MSG_PSE_KEY_UNKNOWN, indent + 1,
KeyFormattingUtils.convertKeyIdToHex(encryptMasterKeyId));
return false;
}
return true;
}
/**
* Remove whitespaces on line endings
*/

View File

@@ -109,7 +109,7 @@ public class OpenPgpService extends Service {
boolean asciiArmor = cleartextSign || data.getBooleanExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
// sign-only
PgpSignEncryptData pgpData = new PgpSignEncryptData();
PgpSignEncryptData.Builder pgpData = PgpSignEncryptData.builder();
pgpData.setEnableAsciiArmorOutput(asciiArmor)
.setCleartextSignature(cleartextSign)
.setDetachedSignature(!cleartextSign)
@@ -132,8 +132,7 @@ public class OpenPgpService extends Service {
// get first usable subkey capable of signing
try {
long signSubKeyId = mKeyRepository.getCachedPublicKeyRing(
pgpData.getSignatureMasterKeyId()).getSecretSignId();
long signSubKeyId = mKeyRepository.getCachedPublicKeyRing(signKeyId).getSecretSignId();
pgpData.setSignatureSubKeyId(signSubKeyId);
} catch (PgpKeyNotFoundException e) {
throw new Exception("signing subkey not found!", e);
@@ -141,7 +140,7 @@ public class OpenPgpService extends Service {
}
PgpSignEncryptInputParcel pseInput = new PgpSignEncryptInputParcel(pgpData);
PgpSignEncryptInputParcel pseInput = new PgpSignEncryptInputParcel(pgpData.build());
pseInput.setAllowedKeyIds(getAllowedKeyIds());
// Get Input- and OutputStream from ParcelFileDescriptor
@@ -213,7 +212,7 @@ public class OpenPgpService extends Service {
compressionId = PgpSecurityConstants.OpenKeychainCompressionAlgorithmTags.UNCOMPRESSED;
}
PgpSignEncryptData pgpData = new PgpSignEncryptData();
PgpSignEncryptData.Builder pgpData = PgpSignEncryptData.builder();
pgpData.setEnableAsciiArmorOutput(asciiArmor)
.setVersionHeader(null)
.setCompressionAlgorithm(compressionId);
@@ -261,7 +260,7 @@ public class OpenPgpService extends Service {
}
pgpData.setEncryptionMasterKeyIds(keyIdResult.getKeyIds());
PgpSignEncryptInputParcel pseInput = new PgpSignEncryptInputParcel(pgpData);
PgpSignEncryptInputParcel pseInput = new PgpSignEncryptInputParcel(pgpData.build());
pseInput.setAllowedKeyIds(getAllowedKeyIds());
CryptoInputParcel inputParcel = CryptoInputParcelCacheService.getCryptoInputParcel(this, data);

View File

@@ -623,7 +623,7 @@ public class EncryptFilesFragment
}
// fill values for this action
PgpSignEncryptData data = new PgpSignEncryptData();
PgpSignEncryptData.Builder data = PgpSignEncryptData.builder();
if (mUseCompression) {
data.setCompressionAlgorithm(
@@ -675,7 +675,7 @@ public class EncryptFilesFragment
}
SignEncryptParcel parcel = new SignEncryptParcel(data);
SignEncryptParcel parcel = new SignEncryptParcel(data.build());
parcel.addInputUris(mFilesAdapter.getAsArrayList());
return parcel;

View File

@@ -233,7 +233,7 @@ public class EncryptTextFragment
}
// fill values for this action
PgpSignEncryptData data = new PgpSignEncryptData();
PgpSignEncryptData.Builder data = PgpSignEncryptData.builder();
data.setCleartextSignature(true);
@@ -286,7 +286,7 @@ public class EncryptTextFragment
data.setSymmetricPassphrase(passphrase);
}
SignEncryptParcel parcel = new SignEncryptParcel(data);
SignEncryptParcel parcel = new SignEncryptParcel(data.build());
parcel.setBytes(mMessage.getBytes());
return parcel;

View File

@@ -178,12 +178,12 @@ public class PgpEncryptDecryptTest {
InputData data = new InputData(in, in.available());
PgpSignEncryptData pgpData = new PgpSignEncryptData();
PgpSignEncryptData.Builder pgpData = PgpSignEncryptData.builder();
pgpData.setSymmetricPassphrase(mSymmetricPassphrase);
pgpData.setSymmetricEncryptionAlgorithm(
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.AES_128);
PgpSignEncryptInputParcel b = new PgpSignEncryptInputParcel(pgpData);
PgpSignEncryptInputParcel b = new PgpSignEncryptInputParcel(pgpData.build());
PgpSignEncryptResult result = op.execute(b, new CryptoInputParcel(new Date()),
data, out);
@@ -303,14 +303,14 @@ public class PgpEncryptDecryptTest {
InputData data = new InputData(in, in.available());
PgpSignEncryptData pgpData = new PgpSignEncryptData();
PgpSignEncryptData.Builder pgpData = PgpSignEncryptData.builder();
// only sign, and not as cleartext
pgpData.setSignatureMasterKeyId(mStaticRing1.getMasterKeyId());
pgpData.setSignatureSubKeyId(KeyringTestingHelper.getSubkeyId(mStaticRing1, 1));
pgpData.setCleartextSignature(false);
pgpData.setDetachedSignature(false);
PgpSignEncryptInputParcel input = new PgpSignEncryptInputParcel(pgpData);
PgpSignEncryptInputParcel input = new PgpSignEncryptInputParcel(pgpData.build());
PgpSignEncryptResult result = op.execute(input, new CryptoInputParcel(mKeyPhrase1), data, out);
Assert.assertTrue("signing must succeed", result.success());
@@ -359,7 +359,7 @@ public class PgpEncryptDecryptTest {
InputData data = new InputData(in, in.available());
PgpSignEncryptData pgpData = new PgpSignEncryptData();
PgpSignEncryptData.Builder pgpData = PgpSignEncryptData.builder();
// only sign, as cleartext
pgpData.setSignatureMasterKeyId(mStaticRing1.getMasterKeyId());
pgpData.setSignatureSubKeyId(KeyringTestingHelper.getSubkeyId(mStaticRing1, 1));
@@ -367,7 +367,7 @@ public class PgpEncryptDecryptTest {
pgpData.setEnableAsciiArmorOutput(true);
pgpData.setDetachedSignature(false);
PgpSignEncryptInputParcel input = new PgpSignEncryptInputParcel(pgpData);
PgpSignEncryptInputParcel input = new PgpSignEncryptInputParcel(pgpData.build());
PgpSignEncryptResult result = op.execute(input, new CryptoInputParcel(mKeyPhrase1), data, out);
Assert.assertTrue("signing must succeed", result.success());
@@ -421,13 +421,13 @@ public class PgpEncryptDecryptTest {
InputData data = new InputData(in, in.available());
PgpSignEncryptData pgpData = new PgpSignEncryptData();
PgpSignEncryptData.Builder pgpData = PgpSignEncryptData.builder();
// only sign, as cleartext
pgpData.setSignatureMasterKeyId(mStaticRing1.getMasterKeyId());
pgpData.setSignatureSubKeyId(KeyringTestingHelper.getSubkeyId(mStaticRing1, 1));
pgpData.setDetachedSignature(true);
PgpSignEncryptInputParcel input = new PgpSignEncryptInputParcel(pgpData);
PgpSignEncryptInputParcel input = new PgpSignEncryptInputParcel(pgpData.build());
PgpSignEncryptResult result = op.execute(input, new CryptoInputParcel(mKeyPhrase1), data, out);
Assert.assertTrue("signing must succeed", result.success());
@@ -478,12 +478,12 @@ public class PgpEncryptDecryptTest {
InputData data = new InputData(in, in.available());
PgpSignEncryptData pgpData = new PgpSignEncryptData();
PgpSignEncryptData.Builder pgpData = PgpSignEncryptData.builder();
pgpData.setEncryptionMasterKeyIds(new long[] { mStaticRing1.getMasterKeyId() });
pgpData.setSymmetricEncryptionAlgorithm(
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.AES_128);
PgpSignEncryptInputParcel input = new PgpSignEncryptInputParcel(pgpData);
PgpSignEncryptInputParcel input = new PgpSignEncryptInputParcel(pgpData.build());
PgpSignEncryptResult result = op.execute(input, new CryptoInputParcel(new Date()),
data, out);
@@ -581,12 +581,12 @@ public class PgpEncryptDecryptTest {
InputData data = new InputData(in, in.available());
PgpSignEncryptData pgpData = new PgpSignEncryptData();
PgpSignEncryptData.Builder pgpData = PgpSignEncryptData.builder();
pgpData.setEncryptionMasterKeyIds(new long[] { mStaticRing1.getMasterKeyId() });
pgpData.setSymmetricEncryptionAlgorithm(
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.AES_128);
PgpSignEncryptInputParcel input = new PgpSignEncryptInputParcel(pgpData);
PgpSignEncryptInputParcel input = new PgpSignEncryptInputParcel(pgpData.build());
PgpSignEncryptResult result = op.execute(input, new CryptoInputParcel(new Date()),
data, out);
@@ -694,12 +694,12 @@ public class PgpEncryptDecryptTest {
InputData data = new InputData(in, in.available());
PgpSignEncryptData pgpData = new PgpSignEncryptData();
PgpSignEncryptData.Builder pgpData = PgpSignEncryptData.builder();
pgpData.setEncryptionMasterKeyIds(new long[] { mStaticRing1.getMasterKeyId() });
pgpData.setSymmetricEncryptionAlgorithm(
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.AES_128);
PgpSignEncryptInputParcel input = new PgpSignEncryptInputParcel(pgpData);
PgpSignEncryptInputParcel input = new PgpSignEncryptInputParcel(pgpData.build());
PgpSignEncryptResult result = op.execute(input, new CryptoInputParcel(new Date()),
data, out);
@@ -739,7 +739,7 @@ public class PgpEncryptDecryptTest {
InputData data = new InputData(in, in.available());
PgpSignEncryptData pgpData = new PgpSignEncryptData();
PgpSignEncryptData.Builder pgpData = PgpSignEncryptData.builder();
pgpData.setEncryptionMasterKeyIds(new long[] {
mStaticRing1.getMasterKeyId(),
mStaticRing2.getMasterKeyId()
@@ -747,7 +747,7 @@ public class PgpEncryptDecryptTest {
pgpData.setSymmetricEncryptionAlgorithm(
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.AES_128);
PgpSignEncryptInputParcel b = new PgpSignEncryptInputParcel(pgpData);
PgpSignEncryptInputParcel b = new PgpSignEncryptInputParcel(pgpData.build());
PgpSignEncryptResult result = op.execute(b, new CryptoInputParcel(new Date()),
data, out);
@@ -868,7 +868,7 @@ public class PgpEncryptDecryptTest {
InputData data = new InputData(in, in.available());
PgpSignEncryptData pgpData = new PgpSignEncryptData();
PgpSignEncryptData.Builder pgpData = PgpSignEncryptData.builder();
pgpData.setEncryptionMasterKeyIds(new long[] {
mStaticRing1.getMasterKeyId(),
mStaticRing2.getMasterKeyId()
@@ -878,7 +878,7 @@ public class PgpEncryptDecryptTest {
pgpData.setSymmetricEncryptionAlgorithm(
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.AES_128);
PgpSignEncryptInputParcel b = new PgpSignEncryptInputParcel(pgpData);
PgpSignEncryptInputParcel b = new PgpSignEncryptInputParcel(pgpData.build());
PgpSignEncryptResult result = op.execute(b,
new CryptoInputParcel(new Date(), mKeyPhrase1), data, out);
@@ -955,7 +955,7 @@ public class PgpEncryptDecryptTest {
InputData data = new InputData(in, in.available());
PgpSignEncryptData pgpData = new PgpSignEncryptData();
PgpSignEncryptData.Builder pgpData = PgpSignEncryptData.builder();
pgpData.setEncryptionMasterKeyIds(new long[] { mStaticRing1.getMasterKeyId() });
pgpData.setSymmetricEncryptionAlgorithm(
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.AES_128);
@@ -963,7 +963,7 @@ public class PgpEncryptDecryptTest {
pgpData.setEnableAsciiArmorOutput(true);
pgpData.setCharset("iso-2022-jp");
PgpSignEncryptInputParcel b = new PgpSignEncryptInputParcel(pgpData);
PgpSignEncryptInputParcel b = new PgpSignEncryptInputParcel(pgpData.build());
PgpSignEncryptResult result = op.execute(b, new CryptoInputParcel(new Date()),
data, out);
@@ -1106,7 +1106,7 @@ public class PgpEncryptDecryptTest {
InputData data = new InputData(in, in.available());
PgpSignEncryptData pgpData = new PgpSignEncryptData();
PgpSignEncryptData.Builder pgpData = PgpSignEncryptData.builder();
pgpData.setEncryptionMasterKeyIds(new long[]{ mStaticRingInsecure.getMasterKeyId()});
PgpSignEncryptInputParcel input = new PgpSignEncryptInputParcel(pgpData);
@@ -1120,4 +1120,4 @@ public class PgpEncryptDecryptTest {
armoredOutputStream.close();
}
*/
}
}