fix Decrypt*Fragment for RequiredInputParcel (except decryptOriginalFilename)
This commit is contained in:
@@ -151,8 +151,6 @@ public class KeychainIntentService extends IntentService implements Progressable
|
||||
|
||||
// decrypt/verify
|
||||
public static final String DECRYPT_CIPHERTEXT_BYTES = "ciphertext_bytes";
|
||||
public static final String DECRYPT_PASSPHRASE = "passphrase";
|
||||
public static final String DECRYPT_NFC_DECRYPTED_SESSION_KEY = "nfc_decrypted_session_key";
|
||||
|
||||
// keybase proof
|
||||
public static final String KEYBASE_REQUIRED_FINGERPRINT = "keybase_required_fingerprint";
|
||||
@@ -284,25 +282,19 @@ public class KeychainIntentService extends IntentService implements Progressable
|
||||
|
||||
try {
|
||||
/* Input */
|
||||
Passphrase passphrase = data.getParcelable(DECRYPT_PASSPHRASE);
|
||||
byte[] nfcDecryptedSessionKey = data.getByteArray(DECRYPT_NFC_DECRYPTED_SESSION_KEY);
|
||||
CryptoInputParcel cryptoInput = data.getParcelable(EXTRA_CRYPTO_INPUT);
|
||||
|
||||
InputData inputData = createDecryptInputData(data);
|
||||
|
||||
/* Operation */
|
||||
Bundle resultData = new Bundle();
|
||||
|
||||
// verifyText and decrypt returning additional resultData values for the
|
||||
// verification of signatures
|
||||
PgpDecryptVerify.Builder builder = new PgpDecryptVerify.Builder(
|
||||
this, new ProviderHelper(this), this, inputData, null
|
||||
);
|
||||
builder.setAllowSymmetricDecryption(true)
|
||||
.setPassphrase(passphrase)
|
||||
.setDecryptMetadataOnly(true)
|
||||
.setNfcState(nfcDecryptedSessionKey);
|
||||
.setDecryptMetadataOnly(true);
|
||||
|
||||
DecryptVerifyResult decryptVerifyResult = builder.build().execute();
|
||||
DecryptVerifyResult decryptVerifyResult = builder.build().execute(cryptoInput);
|
||||
|
||||
sendMessageToHandler(MessageStatus.OKAY, decryptVerifyResult);
|
||||
} catch (Exception e) {
|
||||
@@ -377,7 +369,8 @@ public class KeychainIntentService extends IntentService implements Progressable
|
||||
);
|
||||
builder.setSignedLiteralData(true).setRequiredSignerFingerprint(requiredFingerprint);
|
||||
|
||||
DecryptVerifyResult decryptVerifyResult = builder.build().execute();
|
||||
DecryptVerifyResult decryptVerifyResult = builder.build().execute(
|
||||
new CryptoInputParcel());
|
||||
outStream.close();
|
||||
|
||||
if (!decryptVerifyResult.success()) {
|
||||
@@ -412,15 +405,13 @@ public class KeychainIntentService extends IntentService implements Progressable
|
||||
case ACTION_DECRYPT_VERIFY: {
|
||||
|
||||
try {
|
||||
/* Input */
|
||||
Passphrase passphrase = data.getParcelable(DECRYPT_PASSPHRASE);
|
||||
byte[] nfcDecryptedSessionKey = data.getByteArray(DECRYPT_NFC_DECRYPTED_SESSION_KEY);
|
||||
/* Input */
|
||||
CryptoInputParcel cryptoInput = data.getParcelable(EXTRA_CRYPTO_INPUT);
|
||||
|
||||
InputData inputData = createDecryptInputData(data);
|
||||
OutputStream outStream = createCryptOutputStream(data);
|
||||
|
||||
/* Operation */
|
||||
|
||||
/* Operation */
|
||||
Bundle resultData = new Bundle();
|
||||
|
||||
// verifyText and decrypt returning additional resultData values for the
|
||||
@@ -429,24 +420,22 @@ public class KeychainIntentService extends IntentService implements Progressable
|
||||
this, new ProviderHelper(this), this,
|
||||
inputData, outStream
|
||||
);
|
||||
builder.setAllowSymmetricDecryption(true)
|
||||
.setPassphrase(passphrase)
|
||||
.setNfcState(nfcDecryptedSessionKey);
|
||||
builder.setAllowSymmetricDecryption(true);
|
||||
|
||||
DecryptVerifyResult decryptVerifyResult = builder.build().execute();
|
||||
DecryptVerifyResult decryptVerifyResult = builder.build().execute(cryptoInput);
|
||||
|
||||
outStream.close();
|
||||
|
||||
resultData.putParcelable(DecryptVerifyResult.EXTRA_RESULT, decryptVerifyResult);
|
||||
|
||||
/* Output */
|
||||
|
||||
/* Output */
|
||||
finalizeDecryptOutputStream(data, resultData, outStream);
|
||||
|
||||
Log.logDebugBundle(resultData, "resultData");
|
||||
|
||||
sendMessageToHandler(MessageStatus.OKAY, resultData);
|
||||
} catch (Exception e) {
|
||||
|
||||
} catch (IOException | PgpGeneralException e) {
|
||||
// TODO get rid of this!
|
||||
sendErrorToHandler(e);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
package org.sufficientlysecure.keychain.service.input;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants.key;
|
||||
|
||||
|
||||
public class RequiredInputParcel implements Parcelable {
|
||||
|
||||
public enum RequiredInputType {
|
||||
PASSPHRASE, NFC_SIGN, NFC_DECRYPT
|
||||
PASSPHRASE, PASSPHRASE_SYMMETRIC, NFC_SIGN, NFC_DECRYPT
|
||||
}
|
||||
|
||||
public Date mSignatureTime;
|
||||
@@ -38,13 +39,22 @@ public class RequiredInputParcel implements Parcelable {
|
||||
public RequiredInputParcel(Parcel source) {
|
||||
mType = RequiredInputType.values()[source.readInt()];
|
||||
|
||||
if (source.readInt() != 0) {
|
||||
// 0 = none, 1 = both, 2 = only hashes (decrypt)
|
||||
int hashTypes = source.readInt();
|
||||
if (hashTypes != 0) {
|
||||
int count = source.readInt();
|
||||
mInputHashes = new byte[count][];
|
||||
mSignAlgos = new int[count];
|
||||
for (int i = 0; i < count; i++) {
|
||||
mInputHashes[i] = source.createByteArray();
|
||||
mSignAlgos[i] = source.readInt();
|
||||
if (hashTypes == 1) {
|
||||
mSignAlgos = new int[count];
|
||||
for (int i = 0; i < count; i++) {
|
||||
mInputHashes[i] = source.createByteArray();
|
||||
mSignAlgos[i] = source.readInt();
|
||||
}
|
||||
} else {
|
||||
mSignAlgos = null;
|
||||
for (int i = 0; i < count; i++) {
|
||||
mInputHashes[i] = source.createByteArray();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mInputHashes = null;
|
||||
@@ -72,17 +82,28 @@ public class RequiredInputParcel implements Parcelable {
|
||||
signatureTime, null, null);
|
||||
}
|
||||
|
||||
public static RequiredInputParcel createNfcDecryptOperation(byte[] inputHash) {
|
||||
public static RequiredInputParcel createNfcDecryptOperation(byte[] inputHash, long subKeyId) {
|
||||
return new RequiredInputParcel(RequiredInputType.NFC_DECRYPT,
|
||||
new byte[][] { inputHash }, null, null, null, null);
|
||||
new byte[][] { inputHash }, null, null, null, subKeyId);
|
||||
}
|
||||
|
||||
public static RequiredInputParcel createRequiredPassphrase(
|
||||
public static RequiredInputParcel createRequiredSignPassphrase(
|
||||
long masterKeyId, long subKeyId, Date signatureTime) {
|
||||
return new RequiredInputParcel(RequiredInputType.PASSPHRASE,
|
||||
null, null, signatureTime, masterKeyId, subKeyId);
|
||||
}
|
||||
|
||||
public static RequiredInputParcel createRequiredDecryptPassphrase(
|
||||
long masterKeyId, long subKeyId) {
|
||||
return new RequiredInputParcel(RequiredInputType.PASSPHRASE,
|
||||
null, null, null, masterKeyId, subKeyId);
|
||||
}
|
||||
|
||||
public static RequiredInputParcel createRequiredSymmetricPassphrase() {
|
||||
return new RequiredInputParcel(RequiredInputType.PASSPHRASE_SYMMETRIC,
|
||||
null, null, null, null, null);
|
||||
}
|
||||
|
||||
public static RequiredInputParcel createRequiredPassphrase(
|
||||
RequiredInputParcel req) {
|
||||
return new RequiredInputParcel(RequiredInputType.PASSPHRASE,
|
||||
@@ -98,11 +119,13 @@ public class RequiredInputParcel implements Parcelable {
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(mType.ordinal());
|
||||
if (mInputHashes != null) {
|
||||
dest.writeInt(1);
|
||||
dest.writeInt(mSignAlgos != null ? 1 : 2);
|
||||
dest.writeInt(mInputHashes.length);
|
||||
for (int i = 0; i < mInputHashes.length; i++) {
|
||||
dest.writeByteArray(mInputHashes[i]);
|
||||
dest.writeInt(mSignAlgos[i]);
|
||||
if (mSignAlgos != null) {
|
||||
dest.writeInt(mSignAlgos[i]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dest.writeInt(0);
|
||||
|
||||
Reference in New Issue
Block a user