use autovalue for PgpSignEncryptData class
This commit is contained in:
@@ -170,11 +170,11 @@ public class BackupOperation extends BaseOperation<BackupKeyringParcel> {
|
|||||||
throws FileNotFoundException {
|
throws FileNotFoundException {
|
||||||
PgpSignEncryptOperation signEncryptOperation = new PgpSignEncryptOperation(mContext, mKeyRepository, mProgressable, mCancelled);
|
PgpSignEncryptOperation signEncryptOperation = new PgpSignEncryptOperation(mContext, mKeyRepository, mProgressable, mCancelled);
|
||||||
|
|
||||||
PgpSignEncryptData data = new PgpSignEncryptData();
|
PgpSignEncryptData.Builder data = PgpSignEncryptData.builder();
|
||||||
data.setSymmetricPassphrase(cryptoInput.getPassphrase());
|
data.setSymmetricPassphrase(cryptoInput.getPassphrase());
|
||||||
data.setEnableAsciiArmorOutput(backupInput.mEnableAsciiArmorOutput);
|
data.setEnableAsciiArmorOutput(backupInput.mEnableAsciiArmorOutput);
|
||||||
data.setAddBackupHeader(true);
|
data.setAddBackupHeader(true);
|
||||||
PgpSignEncryptInputParcel inputParcel = new PgpSignEncryptInputParcel(data);
|
PgpSignEncryptInputParcel inputParcel = new PgpSignEncryptInputParcel(data.build());
|
||||||
|
|
||||||
InputStream inStream = mContext.getContentResolver().openInputStream(plainUri);
|
InputStream inStream = mContext.getContentResolver().openInputStream(plainUri);
|
||||||
|
|
||||||
|
|||||||
@@ -83,10 +83,10 @@ public class BenchmarkOperation extends BaseOperation<BenchmarkInputParcel> {
|
|||||||
SignEncryptOperation op =
|
SignEncryptOperation op =
|
||||||
new SignEncryptOperation(mContext, mKeyRepository,
|
new SignEncryptOperation(mContext, mKeyRepository,
|
||||||
new ProgressScaler(mProgressable, i*(50/numRepeats), (i+1)*(50/numRepeats), 100), mCancelled);
|
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.setSymmetricPassphrase(passphrase);
|
||||||
data.setSymmetricEncryptionAlgorithm(OpenKeychainSymmetricKeyAlgorithmTags.AES_128);
|
data.setSymmetricEncryptionAlgorithm(OpenKeychainSymmetricKeyAlgorithmTags.AES_128);
|
||||||
SignEncryptParcel input = new SignEncryptParcel(data);
|
SignEncryptParcel input = new SignEncryptParcel(data.build());
|
||||||
input.setBytes(buf);
|
input.setBytes(buf);
|
||||||
encryptResult = op.execute(input, new CryptoInputParcel());
|
encryptResult = op.execute(input, new CryptoInputParcel());
|
||||||
log.add(encryptResult, 1);
|
log.add(encryptResult, 1);
|
||||||
|
|||||||
@@ -77,18 +77,6 @@ public class SignEncryptOperation extends BaseOperation<SignEncryptParcel> {
|
|||||||
SecurityTokenSignOperationsBuilder pendingInputBuilder = null;
|
SecurityTokenSignOperationsBuilder pendingInputBuilder = null;
|
||||||
|
|
||||||
PgpSignEncryptData data = input.getData();
|
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 {
|
do {
|
||||||
if (checkCancelled()) {
|
if (checkCancelled()) {
|
||||||
|
|||||||
@@ -18,226 +18,73 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.pgp;
|
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.bouncycastle.bcpg.CompressionAlgorithmTags;
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
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 {
|
public abstract boolean isEnableAsciiArmorOutput();
|
||||||
private String mVersionHeader = null;
|
public abstract boolean isCleartextSignature();
|
||||||
private boolean mEnableAsciiArmorOutput = false;
|
public abstract boolean isDetachedSignature();
|
||||||
private int mCompressionAlgorithm = CompressionAlgorithmTags.UNCOMPRESSED;
|
public abstract boolean isAddBackupHeader();
|
||||||
private long[] mEncryptionMasterKeyIds = null;
|
public abstract boolean isHiddenRecipients();
|
||||||
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 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) {
|
@AutoValue.Builder
|
||||||
ClassLoader loader = getClass().getClassLoader();
|
public abstract static class Builder {
|
||||||
|
public abstract PgpSignEncryptData build();
|
||||||
|
|
||||||
mVersionHeader = source.readString();
|
public abstract Builder setCharset(String charset);
|
||||||
mEnableAsciiArmorOutput = source.readInt() == 1;
|
public abstract Builder setAdditionalEncryptId(long additionalEncryptId);
|
||||||
mCompressionAlgorithm = source.readInt();
|
public abstract Builder setSignatureHashAlgorithm(int signatureHashAlgorithm);
|
||||||
mEncryptionMasterKeyIds = source.createLongArray();
|
public abstract Builder setSignatureSubKeyId(Long signatureSubKeyId);
|
||||||
mSymmetricPassphrase = source.readParcelable(loader);
|
public abstract Builder setSignatureMasterKeyId(long signatureMasterKeyId);
|
||||||
mSymmetricEncryptionAlgorithm = source.readInt();
|
public abstract Builder setSymmetricEncryptionAlgorithm(int symmetricEncryptionAlgorithm);
|
||||||
mSignatureMasterKeyId = source.readLong();
|
public abstract Builder setSymmetricPassphrase(Passphrase symmetricPassphrase);
|
||||||
mSignatureSubKeyId = source.readInt() == 1 ? source.readLong() : null;
|
public abstract Builder setEncryptionMasterKeyIds(long[] encryptionMasterKeyIds);
|
||||||
mSignatureHashAlgorithm = source.readInt();
|
public abstract Builder setCompressionAlgorithm(int compressionAlgorithm);
|
||||||
mAdditionalEncryptId = source.readLong();
|
public abstract Builder setVersionHeader(String versionHeader);
|
||||||
mCharset = source.readString();
|
|
||||||
mCleartextSignature = source.readInt() == 1;
|
public abstract Builder setAddBackupHeader(boolean isAddBackupHeader);
|
||||||
mDetachedSignature = source.readInt() == 1;
|
public abstract Builder setEnableAsciiArmorOutput(boolean enableAsciiArmorOutput);
|
||||||
mHiddenRecipients = source.readInt() == 1;
|
public abstract Builder setCleartextSignature(boolean isCleartextSignature);
|
||||||
mAddBackupHeader = source.readInt() == 1;
|
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];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,23 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.pgp;
|
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.content.Context;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.support.annotation.NonNull;
|
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.Passphrase;
|
||||||
import org.sufficientlysecure.keychain.util.ProgressScaler;
|
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.
|
* This class supports a single, low-level, sign/encrypt operation.
|
||||||
* <p/>
|
* <p/>
|
||||||
@@ -187,12 +187,6 @@ public class PgpSignEncryptOperation extends BaseOperation<PgpSignEncryptInputPa
|
|||||||
+ "\nenableAsciiArmorOutput:" + data.isEnableAsciiArmorOutput()
|
+ "\nenableAsciiArmorOutput:" + data.isEnableAsciiArmorOutput()
|
||||||
+ "\nisHiddenRecipients:" + data.isHiddenRecipients());
|
+ "\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;
|
ArmoredOutputStream armorOut = null;
|
||||||
OutputStream out;
|
OutputStream out;
|
||||||
if (data.isEnableAsciiArmorOutput()) {
|
if (data.isEnableAsciiArmorOutput()) {
|
||||||
@@ -300,12 +294,6 @@ public class PgpSignEncryptOperation extends BaseOperation<PgpSignEncryptInputPa
|
|||||||
log.add(LogType.MSG_PSE_ERROR_UNLOCK, indent);
|
log.add(LogType.MSG_PSE_ERROR_UNLOCK, indent);
|
||||||
return new PgpSignEncryptResult(PgpSignEncryptResult.RESULT_ERROR, log);
|
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);
|
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);
|
log.add(LogType.MSG_PSE_ASYMMETRIC, indent);
|
||||||
|
|
||||||
// Asymmetric encryption
|
// Asymmetric encryption
|
||||||
for (long id : data.getEncryptionMasterKeyIds()) {
|
for (long encryptMasterKeyId : data.getEncryptionMasterKeyIds()) {
|
||||||
try {
|
boolean success = processEncryptionMasterKeyId(indent, log, data, cPk, encryptMasterKeyId);
|
||||||
CanonicalizedPublicKeyRing keyRing = mKeyRepository.getCanonicalizedPublicKeyRing(
|
if (!success) {
|
||||||
KeyRings.buildUnifiedKeyRingUri(id));
|
return new PgpSignEncryptResult(PgpSignEncryptResult.RESULT_ERROR, log);
|
||||||
Set<Long> encryptSubKeyIds = keyRing.getEncryptIds();
|
}
|
||||||
for (Long subKeyId : encryptSubKeyIds) {
|
}
|
||||||
CanonicalizedPublicKey key = keyRing.getPublicKey(subKeyId);
|
|
||||||
cPk.addMethod(key.getPubKeyEncryptionGenerator(data.isHiddenRecipients()));
|
long additionalEncryptId = data.getAdditionalEncryptId();
|
||||||
log.add(LogType.MSG_PSE_KEY_OK, indent + 1,
|
if (additionalEncryptId != Constants.key.none) {
|
||||||
KeyFormattingUtils.convertKeyIdToHex(subKeyId));
|
boolean success = processEncryptionMasterKeyId(indent, log, data, cPk, additionalEncryptId);
|
||||||
}
|
if (!success) {
|
||||||
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));
|
|
||||||
return new PgpSignEncryptResult(PgpSignEncryptResult.RESULT_ERROR, log);
|
return new PgpSignEncryptResult(PgpSignEncryptResult.RESULT_ERROR, log);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -663,6 +638,36 @@ public class PgpSignEncryptOperation extends BaseOperation<PgpSignEncryptInputPa
|
|||||||
return result;
|
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
|
* Remove whitespaces on line endings
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ public class OpenPgpService extends Service {
|
|||||||
boolean asciiArmor = cleartextSign || data.getBooleanExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
|
boolean asciiArmor = cleartextSign || data.getBooleanExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
|
||||||
|
|
||||||
// sign-only
|
// sign-only
|
||||||
PgpSignEncryptData pgpData = new PgpSignEncryptData();
|
PgpSignEncryptData.Builder pgpData = PgpSignEncryptData.builder();
|
||||||
pgpData.setEnableAsciiArmorOutput(asciiArmor)
|
pgpData.setEnableAsciiArmorOutput(asciiArmor)
|
||||||
.setCleartextSignature(cleartextSign)
|
.setCleartextSignature(cleartextSign)
|
||||||
.setDetachedSignature(!cleartextSign)
|
.setDetachedSignature(!cleartextSign)
|
||||||
@@ -132,8 +132,7 @@ public class OpenPgpService extends Service {
|
|||||||
|
|
||||||
// get first usable subkey capable of signing
|
// get first usable subkey capable of signing
|
||||||
try {
|
try {
|
||||||
long signSubKeyId = mKeyRepository.getCachedPublicKeyRing(
|
long signSubKeyId = mKeyRepository.getCachedPublicKeyRing(signKeyId).getSecretSignId();
|
||||||
pgpData.getSignatureMasterKeyId()).getSecretSignId();
|
|
||||||
pgpData.setSignatureSubKeyId(signSubKeyId);
|
pgpData.setSignatureSubKeyId(signSubKeyId);
|
||||||
} catch (PgpKeyNotFoundException e) {
|
} catch (PgpKeyNotFoundException e) {
|
||||||
throw new Exception("signing subkey not found!", 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());
|
pseInput.setAllowedKeyIds(getAllowedKeyIds());
|
||||||
|
|
||||||
// Get Input- and OutputStream from ParcelFileDescriptor
|
// Get Input- and OutputStream from ParcelFileDescriptor
|
||||||
@@ -213,7 +212,7 @@ public class OpenPgpService extends Service {
|
|||||||
compressionId = PgpSecurityConstants.OpenKeychainCompressionAlgorithmTags.UNCOMPRESSED;
|
compressionId = PgpSecurityConstants.OpenKeychainCompressionAlgorithmTags.UNCOMPRESSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
PgpSignEncryptData pgpData = new PgpSignEncryptData();
|
PgpSignEncryptData.Builder pgpData = PgpSignEncryptData.builder();
|
||||||
pgpData.setEnableAsciiArmorOutput(asciiArmor)
|
pgpData.setEnableAsciiArmorOutput(asciiArmor)
|
||||||
.setVersionHeader(null)
|
.setVersionHeader(null)
|
||||||
.setCompressionAlgorithm(compressionId);
|
.setCompressionAlgorithm(compressionId);
|
||||||
@@ -261,7 +260,7 @@ public class OpenPgpService extends Service {
|
|||||||
}
|
}
|
||||||
pgpData.setEncryptionMasterKeyIds(keyIdResult.getKeyIds());
|
pgpData.setEncryptionMasterKeyIds(keyIdResult.getKeyIds());
|
||||||
|
|
||||||
PgpSignEncryptInputParcel pseInput = new PgpSignEncryptInputParcel(pgpData);
|
PgpSignEncryptInputParcel pseInput = new PgpSignEncryptInputParcel(pgpData.build());
|
||||||
pseInput.setAllowedKeyIds(getAllowedKeyIds());
|
pseInput.setAllowedKeyIds(getAllowedKeyIds());
|
||||||
|
|
||||||
CryptoInputParcel inputParcel = CryptoInputParcelCacheService.getCryptoInputParcel(this, data);
|
CryptoInputParcel inputParcel = CryptoInputParcelCacheService.getCryptoInputParcel(this, data);
|
||||||
|
|||||||
@@ -623,7 +623,7 @@ public class EncryptFilesFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fill values for this action
|
// fill values for this action
|
||||||
PgpSignEncryptData data = new PgpSignEncryptData();
|
PgpSignEncryptData.Builder data = PgpSignEncryptData.builder();
|
||||||
|
|
||||||
if (mUseCompression) {
|
if (mUseCompression) {
|
||||||
data.setCompressionAlgorithm(
|
data.setCompressionAlgorithm(
|
||||||
@@ -675,7 +675,7 @@ public class EncryptFilesFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SignEncryptParcel parcel = new SignEncryptParcel(data);
|
SignEncryptParcel parcel = new SignEncryptParcel(data.build());
|
||||||
parcel.addInputUris(mFilesAdapter.getAsArrayList());
|
parcel.addInputUris(mFilesAdapter.getAsArrayList());
|
||||||
|
|
||||||
return parcel;
|
return parcel;
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ public class EncryptTextFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fill values for this action
|
// fill values for this action
|
||||||
PgpSignEncryptData data = new PgpSignEncryptData();
|
PgpSignEncryptData.Builder data = PgpSignEncryptData.builder();
|
||||||
|
|
||||||
data.setCleartextSignature(true);
|
data.setCleartextSignature(true);
|
||||||
|
|
||||||
@@ -286,7 +286,7 @@ public class EncryptTextFragment
|
|||||||
data.setSymmetricPassphrase(passphrase);
|
data.setSymmetricPassphrase(passphrase);
|
||||||
}
|
}
|
||||||
|
|
||||||
SignEncryptParcel parcel = new SignEncryptParcel(data);
|
SignEncryptParcel parcel = new SignEncryptParcel(data.build());
|
||||||
parcel.setBytes(mMessage.getBytes());
|
parcel.setBytes(mMessage.getBytes());
|
||||||
|
|
||||||
return parcel;
|
return parcel;
|
||||||
|
|||||||
@@ -178,12 +178,12 @@ public class PgpEncryptDecryptTest {
|
|||||||
|
|
||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
|
|
||||||
PgpSignEncryptData pgpData = new PgpSignEncryptData();
|
PgpSignEncryptData.Builder pgpData = PgpSignEncryptData.builder();
|
||||||
pgpData.setSymmetricPassphrase(mSymmetricPassphrase);
|
pgpData.setSymmetricPassphrase(mSymmetricPassphrase);
|
||||||
pgpData.setSymmetricEncryptionAlgorithm(
|
pgpData.setSymmetricEncryptionAlgorithm(
|
||||||
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.AES_128);
|
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.AES_128);
|
||||||
|
|
||||||
PgpSignEncryptInputParcel b = new PgpSignEncryptInputParcel(pgpData);
|
PgpSignEncryptInputParcel b = new PgpSignEncryptInputParcel(pgpData.build());
|
||||||
PgpSignEncryptResult result = op.execute(b, new CryptoInputParcel(new Date()),
|
PgpSignEncryptResult result = op.execute(b, new CryptoInputParcel(new Date()),
|
||||||
data, out);
|
data, out);
|
||||||
|
|
||||||
@@ -303,14 +303,14 @@ public class PgpEncryptDecryptTest {
|
|||||||
|
|
||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
|
|
||||||
PgpSignEncryptData pgpData = new PgpSignEncryptData();
|
PgpSignEncryptData.Builder pgpData = PgpSignEncryptData.builder();
|
||||||
// only sign, and not as cleartext
|
// only sign, and not as cleartext
|
||||||
pgpData.setSignatureMasterKeyId(mStaticRing1.getMasterKeyId());
|
pgpData.setSignatureMasterKeyId(mStaticRing1.getMasterKeyId());
|
||||||
pgpData.setSignatureSubKeyId(KeyringTestingHelper.getSubkeyId(mStaticRing1, 1));
|
pgpData.setSignatureSubKeyId(KeyringTestingHelper.getSubkeyId(mStaticRing1, 1));
|
||||||
pgpData.setCleartextSignature(false);
|
pgpData.setCleartextSignature(false);
|
||||||
pgpData.setDetachedSignature(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);
|
PgpSignEncryptResult result = op.execute(input, new CryptoInputParcel(mKeyPhrase1), data, out);
|
||||||
Assert.assertTrue("signing must succeed", result.success());
|
Assert.assertTrue("signing must succeed", result.success());
|
||||||
@@ -359,7 +359,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
|
|
||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
|
|
||||||
PgpSignEncryptData pgpData = new PgpSignEncryptData();
|
PgpSignEncryptData.Builder pgpData = PgpSignEncryptData.builder();
|
||||||
// only sign, as cleartext
|
// only sign, as cleartext
|
||||||
pgpData.setSignatureMasterKeyId(mStaticRing1.getMasterKeyId());
|
pgpData.setSignatureMasterKeyId(mStaticRing1.getMasterKeyId());
|
||||||
pgpData.setSignatureSubKeyId(KeyringTestingHelper.getSubkeyId(mStaticRing1, 1));
|
pgpData.setSignatureSubKeyId(KeyringTestingHelper.getSubkeyId(mStaticRing1, 1));
|
||||||
@@ -367,7 +367,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
pgpData.setEnableAsciiArmorOutput(true);
|
pgpData.setEnableAsciiArmorOutput(true);
|
||||||
pgpData.setDetachedSignature(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);
|
PgpSignEncryptResult result = op.execute(input, new CryptoInputParcel(mKeyPhrase1), data, out);
|
||||||
Assert.assertTrue("signing must succeed", result.success());
|
Assert.assertTrue("signing must succeed", result.success());
|
||||||
@@ -421,13 +421,13 @@ public class PgpEncryptDecryptTest {
|
|||||||
|
|
||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
|
|
||||||
PgpSignEncryptData pgpData = new PgpSignEncryptData();
|
PgpSignEncryptData.Builder pgpData = PgpSignEncryptData.builder();
|
||||||
// only sign, as cleartext
|
// only sign, as cleartext
|
||||||
pgpData.setSignatureMasterKeyId(mStaticRing1.getMasterKeyId());
|
pgpData.setSignatureMasterKeyId(mStaticRing1.getMasterKeyId());
|
||||||
pgpData.setSignatureSubKeyId(KeyringTestingHelper.getSubkeyId(mStaticRing1, 1));
|
pgpData.setSignatureSubKeyId(KeyringTestingHelper.getSubkeyId(mStaticRing1, 1));
|
||||||
pgpData.setDetachedSignature(true);
|
pgpData.setDetachedSignature(true);
|
||||||
|
|
||||||
PgpSignEncryptInputParcel input = new PgpSignEncryptInputParcel(pgpData);
|
PgpSignEncryptInputParcel input = new PgpSignEncryptInputParcel(pgpData.build());
|
||||||
|
|
||||||
PgpSignEncryptResult result = op.execute(input, new CryptoInputParcel(mKeyPhrase1), data, out);
|
PgpSignEncryptResult result = op.execute(input, new CryptoInputParcel(mKeyPhrase1), data, out);
|
||||||
Assert.assertTrue("signing must succeed", result.success());
|
Assert.assertTrue("signing must succeed", result.success());
|
||||||
@@ -478,12 +478,12 @@ public class PgpEncryptDecryptTest {
|
|||||||
|
|
||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
|
|
||||||
PgpSignEncryptData pgpData = new PgpSignEncryptData();
|
PgpSignEncryptData.Builder pgpData = PgpSignEncryptData.builder();
|
||||||
pgpData.setEncryptionMasterKeyIds(new long[] { mStaticRing1.getMasterKeyId() });
|
pgpData.setEncryptionMasterKeyIds(new long[] { mStaticRing1.getMasterKeyId() });
|
||||||
pgpData.setSymmetricEncryptionAlgorithm(
|
pgpData.setSymmetricEncryptionAlgorithm(
|
||||||
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.AES_128);
|
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.AES_128);
|
||||||
|
|
||||||
PgpSignEncryptInputParcel input = new PgpSignEncryptInputParcel(pgpData);
|
PgpSignEncryptInputParcel input = new PgpSignEncryptInputParcel(pgpData.build());
|
||||||
|
|
||||||
PgpSignEncryptResult result = op.execute(input, new CryptoInputParcel(new Date()),
|
PgpSignEncryptResult result = op.execute(input, new CryptoInputParcel(new Date()),
|
||||||
data, out);
|
data, out);
|
||||||
@@ -581,12 +581,12 @@ public class PgpEncryptDecryptTest {
|
|||||||
|
|
||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
|
|
||||||
PgpSignEncryptData pgpData = new PgpSignEncryptData();
|
PgpSignEncryptData.Builder pgpData = PgpSignEncryptData.builder();
|
||||||
pgpData.setEncryptionMasterKeyIds(new long[] { mStaticRing1.getMasterKeyId() });
|
pgpData.setEncryptionMasterKeyIds(new long[] { mStaticRing1.getMasterKeyId() });
|
||||||
pgpData.setSymmetricEncryptionAlgorithm(
|
pgpData.setSymmetricEncryptionAlgorithm(
|
||||||
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.AES_128);
|
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.AES_128);
|
||||||
|
|
||||||
PgpSignEncryptInputParcel input = new PgpSignEncryptInputParcel(pgpData);
|
PgpSignEncryptInputParcel input = new PgpSignEncryptInputParcel(pgpData.build());
|
||||||
|
|
||||||
PgpSignEncryptResult result = op.execute(input, new CryptoInputParcel(new Date()),
|
PgpSignEncryptResult result = op.execute(input, new CryptoInputParcel(new Date()),
|
||||||
data, out);
|
data, out);
|
||||||
@@ -694,12 +694,12 @@ public class PgpEncryptDecryptTest {
|
|||||||
|
|
||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
|
|
||||||
PgpSignEncryptData pgpData = new PgpSignEncryptData();
|
PgpSignEncryptData.Builder pgpData = PgpSignEncryptData.builder();
|
||||||
pgpData.setEncryptionMasterKeyIds(new long[] { mStaticRing1.getMasterKeyId() });
|
pgpData.setEncryptionMasterKeyIds(new long[] { mStaticRing1.getMasterKeyId() });
|
||||||
pgpData.setSymmetricEncryptionAlgorithm(
|
pgpData.setSymmetricEncryptionAlgorithm(
|
||||||
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.AES_128);
|
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.AES_128);
|
||||||
|
|
||||||
PgpSignEncryptInputParcel input = new PgpSignEncryptInputParcel(pgpData);
|
PgpSignEncryptInputParcel input = new PgpSignEncryptInputParcel(pgpData.build());
|
||||||
|
|
||||||
PgpSignEncryptResult result = op.execute(input, new CryptoInputParcel(new Date()),
|
PgpSignEncryptResult result = op.execute(input, new CryptoInputParcel(new Date()),
|
||||||
data, out);
|
data, out);
|
||||||
@@ -739,7 +739,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
|
|
||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
|
|
||||||
PgpSignEncryptData pgpData = new PgpSignEncryptData();
|
PgpSignEncryptData.Builder pgpData = PgpSignEncryptData.builder();
|
||||||
pgpData.setEncryptionMasterKeyIds(new long[] {
|
pgpData.setEncryptionMasterKeyIds(new long[] {
|
||||||
mStaticRing1.getMasterKeyId(),
|
mStaticRing1.getMasterKeyId(),
|
||||||
mStaticRing2.getMasterKeyId()
|
mStaticRing2.getMasterKeyId()
|
||||||
@@ -747,7 +747,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
pgpData.setSymmetricEncryptionAlgorithm(
|
pgpData.setSymmetricEncryptionAlgorithm(
|
||||||
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.AES_128);
|
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.AES_128);
|
||||||
|
|
||||||
PgpSignEncryptInputParcel b = new PgpSignEncryptInputParcel(pgpData);
|
PgpSignEncryptInputParcel b = new PgpSignEncryptInputParcel(pgpData.build());
|
||||||
|
|
||||||
PgpSignEncryptResult result = op.execute(b, new CryptoInputParcel(new Date()),
|
PgpSignEncryptResult result = op.execute(b, new CryptoInputParcel(new Date()),
|
||||||
data, out);
|
data, out);
|
||||||
@@ -868,7 +868,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
|
|
||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
|
|
||||||
PgpSignEncryptData pgpData = new PgpSignEncryptData();
|
PgpSignEncryptData.Builder pgpData = PgpSignEncryptData.builder();
|
||||||
pgpData.setEncryptionMasterKeyIds(new long[] {
|
pgpData.setEncryptionMasterKeyIds(new long[] {
|
||||||
mStaticRing1.getMasterKeyId(),
|
mStaticRing1.getMasterKeyId(),
|
||||||
mStaticRing2.getMasterKeyId()
|
mStaticRing2.getMasterKeyId()
|
||||||
@@ -878,7 +878,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
pgpData.setSymmetricEncryptionAlgorithm(
|
pgpData.setSymmetricEncryptionAlgorithm(
|
||||||
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.AES_128);
|
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.AES_128);
|
||||||
|
|
||||||
PgpSignEncryptInputParcel b = new PgpSignEncryptInputParcel(pgpData);
|
PgpSignEncryptInputParcel b = new PgpSignEncryptInputParcel(pgpData.build());
|
||||||
|
|
||||||
PgpSignEncryptResult result = op.execute(b,
|
PgpSignEncryptResult result = op.execute(b,
|
||||||
new CryptoInputParcel(new Date(), mKeyPhrase1), data, out);
|
new CryptoInputParcel(new Date(), mKeyPhrase1), data, out);
|
||||||
@@ -955,7 +955,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
|
|
||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
|
|
||||||
PgpSignEncryptData pgpData = new PgpSignEncryptData();
|
PgpSignEncryptData.Builder pgpData = PgpSignEncryptData.builder();
|
||||||
pgpData.setEncryptionMasterKeyIds(new long[] { mStaticRing1.getMasterKeyId() });
|
pgpData.setEncryptionMasterKeyIds(new long[] { mStaticRing1.getMasterKeyId() });
|
||||||
pgpData.setSymmetricEncryptionAlgorithm(
|
pgpData.setSymmetricEncryptionAlgorithm(
|
||||||
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.AES_128);
|
PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.AES_128);
|
||||||
@@ -963,7 +963,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
pgpData.setEnableAsciiArmorOutput(true);
|
pgpData.setEnableAsciiArmorOutput(true);
|
||||||
pgpData.setCharset("iso-2022-jp");
|
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()),
|
PgpSignEncryptResult result = op.execute(b, new CryptoInputParcel(new Date()),
|
||||||
data, out);
|
data, out);
|
||||||
@@ -1106,7 +1106,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
|
|
||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
|
|
||||||
PgpSignEncryptData pgpData = new PgpSignEncryptData();
|
PgpSignEncryptData.Builder pgpData = PgpSignEncryptData.builder();
|
||||||
pgpData.setEncryptionMasterKeyIds(new long[]{ mStaticRingInsecure.getMasterKeyId()});
|
pgpData.setEncryptionMasterKeyIds(new long[]{ mStaticRingInsecure.getMasterKeyId()});
|
||||||
|
|
||||||
PgpSignEncryptInputParcel input = new PgpSignEncryptInputParcel(pgpData);
|
PgpSignEncryptInputParcel input = new PgpSignEncryptInputParcel(pgpData);
|
||||||
@@ -1120,4 +1120,4 @@ public class PgpEncryptDecryptTest {
|
|||||||
armoredOutputStream.close();
|
armoredOutputStream.close();
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user