decrypt: skip all encountered marker packets (fix #1582)
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package org.spongycastle.openpgp.jcajce;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.spongycastle.openpgp.PGPMarker;
|
||||
|
||||
|
||||
public class JcaSkipMarkerPGPObjectFactory extends JcaPGPObjectFactory {
|
||||
|
||||
public JcaSkipMarkerPGPObjectFactory(InputStream in) {
|
||||
super(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object nextObject() throws IOException {
|
||||
Object o = super.nextObject();
|
||||
while (o instanceof PGPMarker) {
|
||||
o = super.nextObject();
|
||||
}
|
||||
return o;
|
||||
}
|
||||
}
|
||||
@@ -110,10 +110,9 @@ public class InputDataOperation extends BaseOperation<InputDataParcel> {
|
||||
if (decryptResult.isPending()) {
|
||||
return new InputDataResult(log, decryptResult);
|
||||
}
|
||||
log.addByMerge(decryptResult, 2);
|
||||
log.addByMerge(decryptResult, 1);
|
||||
|
||||
if (!decryptResult.success()) {
|
||||
log.add(LogType.MSG_DATA_ERROR_OPENPGP, 1);
|
||||
if ( ! decryptResult.success()) {
|
||||
return new InputDataResult(InputDataResult.RESULT_ERROR, log);
|
||||
}
|
||||
|
||||
|
||||
@@ -836,7 +836,6 @@ public abstract class OperationResult implements Parcelable {
|
||||
MSG_DATA (LogLevel.START, R.string.msg_data),
|
||||
MSG_DATA_OPENPGP (LogLevel.DEBUG, R.string.msg_data_openpgp),
|
||||
MSG_DATA_ERROR_IO (LogLevel.ERROR, R.string.msg_data_error_io),
|
||||
MSG_DATA_ERROR_OPENPGP (LogLevel.ERROR, R.string.msg_data_error_openpgp),
|
||||
MSG_DATA_DETACHED (LogLevel.INFO, R.string.msg_data_detached),
|
||||
MSG_DATA_DETACHED_CLEAR (LogLevel.WARN, R.string.msg_data_detached_clear),
|
||||
MSG_DATA_DETACHED_SIG (LogLevel.DEBUG, R.string.msg_data_detached_sig),
|
||||
|
||||
@@ -48,7 +48,7 @@ import org.spongycastle.openpgp.PGPPBEEncryptedData;
|
||||
import org.spongycastle.openpgp.PGPPublicKeyEncryptedData;
|
||||
import org.spongycastle.openpgp.PGPSignatureList;
|
||||
import org.spongycastle.openpgp.PGPUtil;
|
||||
import org.spongycastle.openpgp.jcajce.JcaPGPObjectFactory;
|
||||
import org.spongycastle.openpgp.jcajce.JcaSkipMarkerPGPObjectFactory;
|
||||
import org.spongycastle.openpgp.operator.PBEDataDecryptorFactory;
|
||||
import org.spongycastle.openpgp.operator.PGPDigestCalculatorProvider;
|
||||
import org.spongycastle.openpgp.operator.jcajce.CachingDataDecryptorFactory;
|
||||
@@ -281,11 +281,11 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp
|
||||
|
||||
OpenPgpDecryptionResultBuilder decryptionResultBuilder = new OpenPgpDecryptionResultBuilder();
|
||||
|
||||
JcaPGPObjectFactory plainFact;
|
||||
JcaSkipMarkerPGPObjectFactory plainFact;
|
||||
Object dataChunk;
|
||||
EncryptStreamResult esResult = null;
|
||||
{ // resolve encrypted (symmetric and asymmetric) packets
|
||||
JcaPGPObjectFactory pgpF = new JcaPGPObjectFactory(in);
|
||||
JcaSkipMarkerPGPObjectFactory pgpF = new JcaSkipMarkerPGPObjectFactory(in);
|
||||
Object obj = pgpF.nextObject();
|
||||
|
||||
if (obj instanceof PGPEncryptedDataList) {
|
||||
@@ -312,7 +312,7 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp
|
||||
decryptionResultBuilder.setInsecure(true);
|
||||
}
|
||||
|
||||
plainFact = new JcaPGPObjectFactory(esResult.cleartextStream);
|
||||
plainFact = new JcaSkipMarkerPGPObjectFactory(esResult.cleartextStream);
|
||||
dataChunk = plainFact.nextObject();
|
||||
|
||||
} else {
|
||||
@@ -337,7 +337,7 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp
|
||||
|
||||
PGPCompressedData compressedData = (PGPCompressedData) dataChunk;
|
||||
|
||||
JcaPGPObjectFactory fact = new JcaPGPObjectFactory(compressedData.getDataStream());
|
||||
JcaSkipMarkerPGPObjectFactory fact = new JcaSkipMarkerPGPObjectFactory(compressedData.getDataStream());
|
||||
dataChunk = fact.nextObject();
|
||||
plainFact = fact;
|
||||
}
|
||||
@@ -839,7 +839,7 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp
|
||||
}
|
||||
|
||||
updateProgress(R.string.progress_processing_signature, 60, 100);
|
||||
JcaPGPObjectFactory pgpFact = new JcaPGPObjectFactory(aIn);
|
||||
JcaSkipMarkerPGPObjectFactory pgpFact = new JcaSkipMarkerPGPObjectFactory(aIn);
|
||||
|
||||
PgpSignatureChecker signatureChecker = new PgpSignatureChecker(mProviderHelper);
|
||||
|
||||
@@ -891,12 +891,12 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp
|
||||
InputStream detachedSigIn = new ByteArrayInputStream(input.getDetachedSignature());
|
||||
detachedSigIn = PGPUtil.getDecoderStream(detachedSigIn);
|
||||
|
||||
JcaPGPObjectFactory pgpFact = new JcaPGPObjectFactory(detachedSigIn);
|
||||
JcaSkipMarkerPGPObjectFactory pgpFact = new JcaSkipMarkerPGPObjectFactory(detachedSigIn);
|
||||
|
||||
Object o = pgpFact.nextObject();
|
||||
if (o instanceof PGPCompressedData) {
|
||||
PGPCompressedData c1 = (PGPCompressedData) o;
|
||||
pgpFact = new JcaPGPObjectFactory(c1.getDataStream());
|
||||
pgpFact = new JcaSkipMarkerPGPObjectFactory(c1.getDataStream());
|
||||
o = pgpFact.nextObject();
|
||||
}
|
||||
|
||||
|
||||
@@ -712,6 +712,7 @@ public class KeychainProvider extends ContentProvider {
|
||||
}
|
||||
|
||||
SQLiteDatabase db = getDb().getReadableDatabase();
|
||||
|
||||
Cursor cursor = qb.query(db, projection, selection, selectionArgs, groupBy, having, orderBy);
|
||||
if (cursor != null) {
|
||||
// Tell the cursor what uri to watch, so it knows when its source data changes
|
||||
|
||||
Reference in New Issue
Block a user