Use Timber instead of Android.Log
This commit is contained in:
@@ -18,6 +18,14 @@
|
||||
package org.sufficientlysecure.keychain.pgp;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.PublicKey;
|
||||
import java.security.interfaces.ECPublicKey;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
|
||||
import org.bouncycastle.asn1.nist.NISTObjectIdentifiers;
|
||||
import org.bouncycastle.bcpg.ECDHPublicBCPGKey;
|
||||
@@ -31,18 +39,9 @@ import org.bouncycastle.openpgp.operator.KeyFingerPrintCalculator;
|
||||
import org.bouncycastle.openpgp.operator.RFC6637Utils;
|
||||
import org.bouncycastle.openpgp.operator.jcajce.JcaPGPKeyConverter;
|
||||
import org.bouncycastle.openpgp.operator.jcajce.JcePublicKeyKeyEncryptionMethodGenerator;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.util.IterableIterator;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.PublicKey;
|
||||
import java.security.interfaces.ECPublicKey;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Iterator;
|
||||
import timber.log.Timber;
|
||||
|
||||
/** Wrapper for a PGPPublicKey.
|
||||
*
|
||||
@@ -185,7 +184,7 @@ public class CanonicalizedPublicKey extends UncachedPublicKey {
|
||||
long seconds = getValidSeconds();
|
||||
|
||||
if (seconds > Integer.MAX_VALUE) {
|
||||
Log.e(Constants.TAG, "error, expiry time too large");
|
||||
Timber.e("error, expiry time too large");
|
||||
return null;
|
||||
}
|
||||
if (seconds == 0) {
|
||||
|
||||
@@ -37,14 +37,21 @@ import org.bouncycastle.openpgp.PGPSignatureGenerator;
|
||||
import org.bouncycastle.openpgp.PGPSignatureSubpacketGenerator;
|
||||
import org.bouncycastle.openpgp.operator.PBESecretKeyDecryptor;
|
||||
import org.bouncycastle.openpgp.operator.PGPContentSignerBuilder;
|
||||
import org.bouncycastle.openpgp.operator.jcajce.*;
|
||||
import org.bouncycastle.openpgp.operator.jcajce.CachingDataDecryptorFactory;
|
||||
import org.bouncycastle.openpgp.operator.jcajce.EdDsaAuthenticationContentSignerBuilder;
|
||||
import org.bouncycastle.openpgp.operator.jcajce.JcaPGPContentSignerBuilder;
|
||||
import org.bouncycastle.openpgp.operator.jcajce.JcaPGPKeyConverter;
|
||||
import org.bouncycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder;
|
||||
import org.bouncycastle.openpgp.operator.jcajce.JcePublicKeyDataDecryptorFactoryBuilder;
|
||||
import org.bouncycastle.openpgp.operator.jcajce.NfcSyncPGPContentSignerBuilder;
|
||||
import org.bouncycastle.openpgp.operator.jcajce.SessionKeySecretKeyDecryptorBuilder;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.KeyWritableRepository;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||
import timber.log.Timber;
|
||||
|
||||
|
||||
/**
|
||||
@@ -204,7 +211,7 @@ public class CanonicalizedSecretKey extends CanonicalizedPublicKey {
|
||||
mPrivateKey = mSecretKey.extractPrivateKey(keyDecryptor);
|
||||
mPrivateKeyState = PRIVATE_KEY_STATE_UNLOCKED;
|
||||
} catch (PGPException e) {
|
||||
Log.e(Constants.TAG, "Error extracting private key!", e);
|
||||
Timber.e(e, "Error extracting private key!");
|
||||
return false;
|
||||
}
|
||||
if (mPrivateKey == null) {
|
||||
@@ -241,7 +248,7 @@ public class CanonicalizedSecretKey extends CanonicalizedPublicKey {
|
||||
signatureGenerator.init(PGPSignature.DEFAULT_CERTIFICATION, mPrivateKey);
|
||||
return signatureGenerator;
|
||||
} catch (PGPException e) {
|
||||
Log.e(Constants.TAG, "signing error", e);
|
||||
Timber.e(e, "signing error");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,19 +17,19 @@
|
||||
|
||||
package org.sufficientlysecure.keychain.pgp;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bouncycastle.openpgp.PGPKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPPublicKey;
|
||||
import org.bouncycastle.openpgp.PGPSecretKey;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPSignature;
|
||||
import org.bouncycastle.openpgp.jcajce.JcaPGPObjectFactory;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.util.IterableIterator;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import timber.log.Timber;
|
||||
|
||||
public class CanonicalizedSecretKeyRing extends CanonicalizedKeyRing {
|
||||
|
||||
@@ -47,10 +47,10 @@ public class CanonicalizedSecretKeyRing extends CanonicalizedKeyRing {
|
||||
PGPKeyRing keyRing = null;
|
||||
try {
|
||||
if ((keyRing = (PGPKeyRing) factory.nextObject()) == null) {
|
||||
Log.e(Constants.TAG, "No keys given!");
|
||||
Timber.e("No keys given!");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.e(Constants.TAG, "Error while converting to PGPKeyRing!", e);
|
||||
Timber.e(e, "Error while converting to PGPKeyRing!");
|
||||
}
|
||||
|
||||
mRing = (PGPSecretKeyRing) keyRing;
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
package org.sufficientlysecure.keychain.pgp;
|
||||
|
||||
import org.openintents.openpgp.OpenPgpDecryptionResult;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
import timber.log.Timber;
|
||||
|
||||
|
||||
class OpenPgpDecryptionResultBuilder {
|
||||
|
||||
@@ -39,16 +39,16 @@ class OpenPgpDecryptionResultBuilder {
|
||||
|
||||
public OpenPgpDecryptionResult build() {
|
||||
if (isInsecure) {
|
||||
Log.d(Constants.TAG, "RESULT_INSECURE");
|
||||
Timber.d("RESULT_INSECURE");
|
||||
return new OpenPgpDecryptionResult(OpenPgpDecryptionResult.RESULT_INSECURE, sessionKey, decryptedSessionKey);
|
||||
}
|
||||
|
||||
if (isEncrypted) {
|
||||
Log.d(Constants.TAG, "RESULT_ENCRYPTED");
|
||||
Timber.d("RESULT_ENCRYPTED");
|
||||
return new OpenPgpDecryptionResult(OpenPgpDecryptionResult.RESULT_ENCRYPTED, sessionKey, decryptedSessionKey);
|
||||
}
|
||||
|
||||
Log.d(Constants.TAG, "RESULT_NOT_ENCRYPTED");
|
||||
Timber.d("RESULT_NOT_ENCRYPTED");
|
||||
return new OpenPgpDecryptionResult(OpenPgpDecryptionResult.RESULT_NOT_ENCRYPTED);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,11 +25,11 @@ import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||
import org.openintents.openpgp.OpenPgpSignatureResult.SenderStatusResult;
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.openintents.openpgp.util.OpenPgpUtils.UserId;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.KeyRepository;
|
||||
import org.sufficientlysecure.keychain.provider.KeyRepository.NotFoundException;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
import timber.log.Timber;
|
||||
|
||||
|
||||
/**
|
||||
* This class can be used to build OpenPgpSignatureResult objects based on several checks.
|
||||
@@ -121,7 +121,7 @@ public class OpenPgpSignatureResultBuilder {
|
||||
try {
|
||||
setPrimaryUserId(signingRing.getPrimaryUserIdWithFallback());
|
||||
} catch (PgpKeyNotFoundException e) {
|
||||
Log.d(Constants.TAG, "No primary user id in keyring with master key id " + signingRing.getMasterKeyId());
|
||||
Timber.d("No primary user id in keyring with master key id " + signingRing.getMasterKeyId());
|
||||
}
|
||||
setSignatureKeyCertified(signingRing.getVerified() > 0);
|
||||
|
||||
@@ -168,35 +168,35 @@ public class OpenPgpSignatureResultBuilder {
|
||||
|
||||
public OpenPgpSignatureResult build() {
|
||||
if (!mSignatureAvailable) {
|
||||
Log.d(Constants.TAG, "RESULT_NO_SIGNATURE");
|
||||
Timber.d("RESULT_NO_SIGNATURE");
|
||||
return OpenPgpSignatureResult.createWithNoSignature();
|
||||
}
|
||||
|
||||
if (!mKnownKey) {
|
||||
Log.d(Constants.TAG, "RESULT_KEY_MISSING");
|
||||
Timber.d("RESULT_KEY_MISSING");
|
||||
return OpenPgpSignatureResult.createWithKeyMissing(mKeyId, mSignatureTimestamp);
|
||||
}
|
||||
|
||||
if (!mValidSignature) {
|
||||
Log.d(Constants.TAG, "RESULT_INVALID_SIGNATURE");
|
||||
Timber.d("RESULT_INVALID_SIGNATURE");
|
||||
return OpenPgpSignatureResult.createWithInvalidSignature();
|
||||
}
|
||||
|
||||
int signatureStatus;
|
||||
if (mIsKeyRevoked) {
|
||||
Log.d(Constants.TAG, "RESULT_INVALID_KEY_REVOKED");
|
||||
Timber.d("RESULT_INVALID_KEY_REVOKED");
|
||||
signatureStatus = OpenPgpSignatureResult.RESULT_INVALID_KEY_REVOKED;
|
||||
} else if (mIsKeyExpired) {
|
||||
Log.d(Constants.TAG, "RESULT_INVALID_KEY_EXPIRED");
|
||||
Timber.d("RESULT_INVALID_KEY_EXPIRED");
|
||||
signatureStatus = OpenPgpSignatureResult.RESULT_INVALID_KEY_EXPIRED;
|
||||
} else if (mInsecure) {
|
||||
Log.d(Constants.TAG, "RESULT_INVALID_INSECURE");
|
||||
Timber.d("RESULT_INVALID_INSECURE");
|
||||
signatureStatus = OpenPgpSignatureResult.RESULT_INVALID_KEY_INSECURE;
|
||||
} else if (mIsSignatureKeyCertified) {
|
||||
Log.d(Constants.TAG, "RESULT_VALID_CONFIRMED");
|
||||
Timber.d("RESULT_VALID_CONFIRMED");
|
||||
signatureStatus = OpenPgpSignatureResult.RESULT_VALID_KEY_CONFIRMED;
|
||||
} else {
|
||||
Log.d(Constants.TAG, "RESULT_VALID_UNCONFIRMED");
|
||||
Timber.d("RESULT_VALID_UNCONFIRMED");
|
||||
signatureStatus = OpenPgpSignatureResult.RESULT_VALID_KEY_UNCONFIRMED;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,14 +32,13 @@ import org.bouncycastle.openpgp.PGPSignatureSubpacketGenerator;
|
||||
import org.bouncycastle.openpgp.PGPSignatureSubpacketVector;
|
||||
import org.bouncycastle.openpgp.PGPUserAttributeSubpacketVector;
|
||||
import org.bouncycastle.openpgp.operator.jcajce.NfcSyncPGPContentSignerBuilder.NfcInteractionNeeded;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
||||
import org.sufficientlysecure.keychain.service.CertifyActionsParcel.CertifyAction;
|
||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel.SecurityTokenSignOperationsBuilder;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
import timber.log.Timber;
|
||||
|
||||
|
||||
public class PgpCertifyOperation {
|
||||
@@ -67,7 +66,7 @@ public class PgpCertifyOperation {
|
||||
PGPSignatureSubpacketGenerator spGen = new PGPSignatureSubpacketGenerator();
|
||||
if (creationTimestamp != null) {
|
||||
spGen.setSignatureCreationTime(false, creationTimestamp);
|
||||
Log.d(Constants.TAG, "For NFC: set sig creation time to " + creationTimestamp);
|
||||
Timber.d("For NFC: set sig creation time to " + creationTimestamp);
|
||||
}
|
||||
PGPSignatureSubpacketVector packetVector = spGen.generate();
|
||||
signatureGenerator.setHashedSubpackets(packetVector);
|
||||
@@ -115,7 +114,7 @@ public class PgpCertifyOperation {
|
||||
|
||||
}
|
||||
} catch (PGPException e) {
|
||||
Log.e(Constants.TAG, "signing error", e);
|
||||
Timber.e(e, "signing error");
|
||||
return new PgpCertifyResult();
|
||||
}
|
||||
|
||||
|
||||
@@ -83,9 +83,12 @@ import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
import org.sufficientlysecure.keychain.util.CharsetVerifier;
|
||||
import org.sufficientlysecure.keychain.util.FileHelper;
|
||||
import org.sufficientlysecure.keychain.util.InputData;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||
import org.sufficientlysecure.keychain.util.ProgressScaler;
|
||||
import timber.log.Timber;
|
||||
|
||||
import static java.lang.String.format;
|
||||
|
||||
|
||||
public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInputParcel> {
|
||||
|
||||
@@ -112,7 +115,7 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp
|
||||
long inputSize = FileHelper.getFileSize(mContext, input.getInputUri(), 0);
|
||||
inputData = new InputData(inputStream, inputSize);
|
||||
} catch (FileNotFoundException e) {
|
||||
Log.e(Constants.TAG, "Input URI could not be opened: " + input.getInputUri(), e);
|
||||
Timber.e(e, "Input URI could not be opened: " + input.getInputUri());
|
||||
OperationLog log = new OperationLog();
|
||||
log.add(LogType.MSG_DC_ERROR_INPUT, 1);
|
||||
return new DecryptVerifyResult(DecryptVerifyResult.RESULT_ERROR, log);
|
||||
@@ -125,7 +128,7 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp
|
||||
try {
|
||||
outputStream = mContext.getContentResolver().openOutputStream(input.getOutputUri());
|
||||
} catch (FileNotFoundException e) {
|
||||
Log.e(Constants.TAG, "Output URI could not be opened: " + input.getOutputUri(), e);
|
||||
Timber.e(e, "Output URI could not be opened: " + input.getOutputUri());
|
||||
OperationLog log = new OperationLog();
|
||||
log.add(LogType.MSG_DC_ERROR_IO, 1);
|
||||
return new DecryptVerifyResult(DecryptVerifyResult.RESULT_ERROR, log);
|
||||
@@ -139,7 +142,7 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp
|
||||
}
|
||||
|
||||
result.mOperationTime = System.currentTimeMillis() - startTime;
|
||||
Log.d(Constants.TAG, "total time taken: " + String.format("%.2f", result.mOperationTime / 1000.0) + "s");
|
||||
Timber.d("total time taken: " + format("%.2f", result.mOperationTime / 1000.0) + "s");
|
||||
return result;
|
||||
|
||||
}
|
||||
@@ -155,7 +158,7 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp
|
||||
InputData inputData, OutputStream outputStream) {
|
||||
try {
|
||||
if (input.getDetachedSignature() != null) {
|
||||
Log.d(Constants.TAG, "Detached signature present, verifying with this signature only");
|
||||
Timber.d("Detached signature present, verifying with this signature only");
|
||||
|
||||
return verifyDetachedSignature(input, inputData, outputStream, 0);
|
||||
} else {
|
||||
@@ -165,7 +168,7 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp
|
||||
if (inputStream instanceof ArmoredInputStream) {
|
||||
ArmoredInputStream aIn = (ArmoredInputStream) inputStream;
|
||||
// it is ascii armored
|
||||
Log.d(Constants.TAG, "ASCII Armor Header Line: " + aIn.getArmorHeaderLine());
|
||||
Timber.d("ASCII Armor Header Line: " + aIn.getArmorHeaderLine());
|
||||
|
||||
if (aIn.isClearText()) {
|
||||
// a cleartext signature, verify it with the other method
|
||||
@@ -179,19 +182,19 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp
|
||||
}
|
||||
}
|
||||
} catch (PGPException e) {
|
||||
Log.d(Constants.TAG, "PGPException", e);
|
||||
Timber.d(e, "PGPException");
|
||||
OperationLog log = new OperationLog();
|
||||
log.add(LogType.MSG_DC_ERROR_PGP_EXCEPTION, 1);
|
||||
return new DecryptVerifyResult(DecryptVerifyResult.RESULT_ERROR, log);
|
||||
} catch (DecoderException | ArrayIndexOutOfBoundsException e) {
|
||||
// these can happen if assumptions in JcaPGPObjectFactory.nextObject() aren't
|
||||
// fulfilled, so we need to catch them here to handle this gracefully
|
||||
Log.d(Constants.TAG, "data error", e);
|
||||
Timber.d(e, "data error");
|
||||
OperationLog log = new OperationLog();
|
||||
log.add(LogType.MSG_DC_ERROR_IO, 1);
|
||||
return new DecryptVerifyResult(DecryptVerifyResult.RESULT_ERROR, log);
|
||||
} catch (IOException e) {
|
||||
Log.d(Constants.TAG, "IOException", e);
|
||||
Timber.d(e, "IOException");
|
||||
OperationLog log = new OperationLog();
|
||||
log.add(LogType.MSG_DC_ERROR_IO, 1);
|
||||
return new DecryptVerifyResult(DecryptVerifyResult.RESULT_ERROR, log);
|
||||
@@ -504,7 +507,7 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp
|
||||
}
|
||||
|
||||
opTime = System.currentTimeMillis()-startTime;
|
||||
Log.d(Constants.TAG, "decrypt time taken: " + String.format("%.2f", opTime / 1000.0) + "s, for "
|
||||
Timber.d("decrypt time taken: " + format("%.2f", opTime / 1000.0) + "s, for "
|
||||
+ alreadyWritten + " bytes");
|
||||
|
||||
// special treatment to detect pgp mime types
|
||||
@@ -522,7 +525,7 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp
|
||||
alreadyWritten, charsetVerifier.getCharset());
|
||||
|
||||
log.add(LogType.MSG_DC_CLEAR_META_MIME, indent + 1, mimeType);
|
||||
Log.d(Constants.TAG, metadata.toString());
|
||||
Timber.d(metadata.toString());
|
||||
|
||||
indent -= 1;
|
||||
|
||||
@@ -613,9 +616,9 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp
|
||||
|
||||
// allow only specific keys for decryption?
|
||||
if (input.getAllowedKeyIds() != null) {
|
||||
Log.d(Constants.TAG, "encData.getKeyID(): " + subKeyId);
|
||||
Log.d(Constants.TAG, "mAllowedKeyIds: " + input.getAllowedKeyIds());
|
||||
Log.d(Constants.TAG, "masterKeyId: " + masterKeyId);
|
||||
Timber.d("encData.getKeyID(): " + subKeyId);
|
||||
Timber.d("mAllowedKeyIds: " + input.getAllowedKeyIds());
|
||||
Timber.d("masterKeyId: " + masterKeyId);
|
||||
|
||||
if (!input.getAllowedKeyIds().contains(masterKeyId)) {
|
||||
// this key is in our db, but NOT allowed!
|
||||
@@ -913,7 +916,7 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp
|
||||
signatureChecker.verifySignature(log, indent);
|
||||
|
||||
} catch (SignatureException e) {
|
||||
Log.d(Constants.TAG, "SignatureException", e);
|
||||
Timber.d(e, "SignatureException");
|
||||
return new DecryptVerifyResult(DecryptVerifyResult.RESULT_ERROR, log);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ import android.support.annotation.Nullable;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
import timber.log.Timber;
|
||||
|
||||
|
||||
public class PgpHelper {
|
||||
|
||||
@@ -84,14 +84,14 @@ public class PgpHelper {
|
||||
}
|
||||
|
||||
public static String getPgpMessageContent(@NonNull CharSequence input) {
|
||||
Log.dEscaped(Constants.TAG, "input: " + input);
|
||||
Timber.d("input: %s");
|
||||
|
||||
Matcher matcher = PgpHelper.PGP_MESSAGE.matcher(input);
|
||||
if (matcher.matches()) {
|
||||
String text = matcher.group(1);
|
||||
text = fixPgpMessage(text);
|
||||
|
||||
Log.dEscaped(Constants.TAG, "input fixed: " + text);
|
||||
Timber.d("input fixed: %s", text);
|
||||
return text;
|
||||
} else {
|
||||
matcher = PgpHelper.PGP_CLEARTEXT_SIGNATURE.matcher(input);
|
||||
@@ -99,7 +99,7 @@ public class PgpHelper {
|
||||
String text = matcher.group(1);
|
||||
text = fixPgpCleartextSignature(text);
|
||||
|
||||
Log.dEscaped(Constants.TAG, "input fixed: " + text);
|
||||
Timber.d("input fixed: %s", text);
|
||||
return text;
|
||||
} else {
|
||||
return null;
|
||||
@@ -108,7 +108,7 @@ public class PgpHelper {
|
||||
}
|
||||
|
||||
public static String getPgpPublicKeyContent(@NonNull CharSequence input) {
|
||||
Log.dEscaped(Constants.TAG, "input: " + input);
|
||||
Timber.d("input: %s", input);
|
||||
|
||||
Matcher matcher = PgpHelper.PGP_PUBLIC_KEY.matcher(input);
|
||||
if (!matcher.matches()) {
|
||||
@@ -165,7 +165,7 @@ public class PgpHelper {
|
||||
|
||||
Matcher matcher = KEYDATA_START_PATTERN.matcher(text);
|
||||
if (!matcher.find()) {
|
||||
Log.e(Constants.TAG, "Could not find start of key data!");
|
||||
Timber.e("Could not find start of key data!");
|
||||
break;
|
||||
}
|
||||
int indexOfPubkeyMaterial = matcher.start(1);
|
||||
|
||||
@@ -90,10 +90,11 @@ import org.sufficientlysecure.keychain.service.input.RequiredInputParcel.Securit
|
||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel.SecurityTokenSignOperationsBuilder;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
import org.sufficientlysecure.keychain.util.IterableIterator;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||
import org.sufficientlysecure.keychain.util.Primes;
|
||||
import org.sufficientlysecure.keychain.util.ProgressScaler;
|
||||
import timber.log.Timber;
|
||||
|
||||
|
||||
/**
|
||||
* This class is the single place where ALL operations that actually modify a PGP public or secret
|
||||
@@ -286,7 +287,7 @@ public class PgpKeyOperation {
|
||||
log.add(LogType.MSG_CR_ERROR_UNKNOWN_ALGO, indent);
|
||||
return null;
|
||||
} catch(PGPException e) {
|
||||
Log.e(Constants.TAG, "internal pgp error", e);
|
||||
Timber.e(e, "internal pgp error");
|
||||
log.add(LogType.MSG_CR_ERROR_INTERNAL_PGP, indent);
|
||||
return null;
|
||||
}
|
||||
@@ -364,10 +365,10 @@ public class PgpKeyOperation {
|
||||
|
||||
} catch (PGPException e) {
|
||||
log.add(LogType.MSG_CR_ERROR_INTERNAL_PGP, indent);
|
||||
Log.e(Constants.TAG, "pgp error encoding key", e);
|
||||
Timber.e(e, "pgp error encoding key");
|
||||
return new PgpEditKeyResult(PgpEditKeyResult.RESULT_ERROR, log, null);
|
||||
} catch (IOException e) {
|
||||
Log.e(Constants.TAG, "io error encoding key", e);
|
||||
Timber.e(e, "io error encoding key");
|
||||
return new PgpEditKeyResult(PgpEditKeyResult.RESULT_ERROR, log, null);
|
||||
}
|
||||
|
||||
@@ -1137,15 +1138,15 @@ public class PgpKeyOperation {
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
Log.e(Constants.TAG, "encountered IOException while modifying key", e);
|
||||
Timber.e(e, "encountered IOException while modifying key");
|
||||
log.add(LogType.MSG_MF_ERROR_ENCODE, indent+1);
|
||||
return new PgpEditKeyResult(PgpEditKeyResult.RESULT_ERROR, log, null);
|
||||
} catch (PGPException e) {
|
||||
Log.e(Constants.TAG, "encountered pgp error while modifying key", e);
|
||||
Timber.e(e, "encountered pgp error while modifying key");
|
||||
log.add(LogType.MSG_MF_ERROR_PGP, indent+1);
|
||||
return new PgpEditKeyResult(PgpEditKeyResult.RESULT_ERROR, log, null);
|
||||
} catch (SignatureException e) {
|
||||
Log.e(Constants.TAG, "encountered SignatureException while modifying key", e);
|
||||
Timber.e(e, "encountered SignatureException while modifying key");
|
||||
log.add(LogType.MSG_MF_ERROR_SIG, indent+1);
|
||||
return new PgpEditKeyResult(PgpEditKeyResult.RESULT_ERROR, log, null);
|
||||
}
|
||||
|
||||
@@ -72,9 +72,12 @@ import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
import org.sufficientlysecure.keychain.util.FileHelper;
|
||||
import org.sufficientlysecure.keychain.util.InputData;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||
import org.sufficientlysecure.keychain.util.ProgressScaler;
|
||||
import timber.log.Timber;
|
||||
|
||||
import static java.lang.String.format;
|
||||
|
||||
|
||||
/**
|
||||
* This class supports a single, low-level, sign/encrypt operation.
|
||||
@@ -98,7 +101,7 @@ public class PgpSignEncryptOperation extends BaseOperation<PgpSignEncryptInputPa
|
||||
try {
|
||||
NEW_LINE = "\r\n".getBytes("UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
Log.e(Constants.TAG, "UnsupportedEncodingException", e);
|
||||
Timber.e(e, "UnsupportedEncodingException");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,7 +189,7 @@ public class PgpSignEncryptOperation extends BaseOperation<PgpSignEncryptInputPa
|
||||
compressionAlgorithm = PgpSecurityConstants.DEFAULT_COMPRESSION_ALGORITHM;
|
||||
}
|
||||
|
||||
Log.d(Constants.TAG, data.toString());
|
||||
Timber.d(data.toString());
|
||||
|
||||
ArmoredOutputStream armorOut = null;
|
||||
OutputStream out;
|
||||
@@ -576,7 +579,7 @@ public class PgpSignEncryptOperation extends BaseOperation<PgpSignEncryptInputPa
|
||||
}
|
||||
|
||||
opTime = System.currentTimeMillis() - startTime;
|
||||
Log.d(Constants.TAG, "sign/encrypt time taken: " + String.format("%.2f", opTime / 1000.0) + "s");
|
||||
Timber.d("sign/encrypt time taken: " + format("%.2f", opTime / 1000.0) + "s");
|
||||
|
||||
// closing outputs
|
||||
// NOTE: closing needs to be done in the correct order!
|
||||
@@ -635,7 +638,7 @@ public class PgpSignEncryptOperation extends BaseOperation<PgpSignEncryptInputPa
|
||||
// construct micalg parameter according to https://tools.ietf.org/html/rfc3156#section-5
|
||||
result.setMicAlgDigestName("pgp-" + digestName.toLowerCase());
|
||||
} catch (PGPException e) {
|
||||
Log.e(Constants.TAG, "error setting micalg parameter!", e);
|
||||
Timber.e(e, "error setting micalg parameter!");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -41,7 +41,7 @@ import org.sufficientlysecure.keychain.pgp.SecurityProblem.KeySecurityProblem;
|
||||
import org.sufficientlysecure.keychain.provider.KeyRepository;
|
||||
import org.sufficientlysecure.keychain.provider.KeyWritableRepository;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
import timber.log.Timber;
|
||||
|
||||
|
||||
/** This class is used to track the state of a single signature verification.
|
||||
@@ -172,7 +172,7 @@ class PgpSignatureChecker {
|
||||
onePassSignature = sigList.get(i);
|
||||
return;
|
||||
} catch (KeyWritableRepository.NotFoundException e) {
|
||||
Log.d(Constants.TAG, "key not found, trying next signature...");
|
||||
Timber.d("key not found, trying next signature...");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -195,7 +195,7 @@ class PgpSignatureChecker {
|
||||
signature = sigList.get(i);
|
||||
return;
|
||||
} catch (KeyWritableRepository.NotFoundException e) {
|
||||
Log.d(Constants.TAG, "key not found, trying next signature...");
|
||||
Timber.d("key not found, trying next signature...");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,8 +67,9 @@ import org.sufficientlysecure.keychain.operations.results.OperationResult.Operat
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
import org.sufficientlysecure.keychain.util.IterableIterator;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
import org.sufficientlysecure.keychain.util.Utf8Util;
|
||||
import timber.log.Timber;
|
||||
|
||||
|
||||
/** Wrapper around PGPKeyRing class, to be constructed from bytes.
|
||||
*
|
||||
@@ -217,10 +218,9 @@ public class UncachedKeyRing {
|
||||
// go through all objects in this block
|
||||
Object obj;
|
||||
while ((obj = mObjectFactory.nextObject()) != null) {
|
||||
Log.d(Constants.TAG, "Found class: " + obj.getClass());
|
||||
Timber.d("Found class: " + obj.getClass());
|
||||
if (!(obj instanceof PGPKeyRing)) {
|
||||
Log.i(Constants.TAG,
|
||||
"Skipping object of bad type " + obj.getClass().getName() + " in stream");
|
||||
Timber.i("Skipping object of bad type " + obj.getClass().getName() + " in stream");
|
||||
// skip object
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,14 @@
|
||||
|
||||
package org.sufficientlysecure.keychain.pgp;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bouncycastle.bcpg.ECPublicBCPGKey;
|
||||
import org.bouncycastle.bcpg.SignatureSubpacketTags;
|
||||
import org.bouncycastle.openpgp.PGPPublicKey;
|
||||
@@ -26,15 +34,8 @@ import org.bouncycastle.openpgp.PGPUserAttributeSubpacketVector;
|
||||
import org.bouncycastle.openpgp.operator.jcajce.JcaPGPContentVerifierBuilderProvider;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.util.IterableIterator;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
import org.sufficientlysecure.keychain.util.Utf8Util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Iterator;
|
||||
import timber.log.Timber;
|
||||
|
||||
public class UncachedPublicKey {
|
||||
protected final PGPPublicKey mPublicKey;
|
||||
@@ -374,7 +375,7 @@ public class UncachedPublicKey {
|
||||
long valid = mPublicKey.getValidSeconds();
|
||||
|
||||
if (valid > Integer.MAX_VALUE) {
|
||||
Log.e(Constants.TAG, "error, expiry time too large");
|
||||
Timber.e("error, expiry time too large");
|
||||
return null;
|
||||
}
|
||||
if (valid == 0) {
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.bouncycastle.openpgp.operator.jcajce.JcaKeyFingerprintCalculator;
|
||||
import org.bouncycastle.openpgp.operator.jcajce.JcaPGPContentVerifierBuilderProvider;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
import timber.log.Timber;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -103,7 +103,7 @@ public class WrappedSignature {
|
||||
}
|
||||
} catch (PGPException e) {
|
||||
// no matter
|
||||
Log.e(Constants.TAG, "exception reading embedded signatures", e);
|
||||
Timber.e(e, "exception reading embedded signatures");
|
||||
}
|
||||
return sigs;
|
||||
}
|
||||
@@ -229,11 +229,11 @@ public class WrappedSignature {
|
||||
PGPSignatureList signatures = null;
|
||||
try {
|
||||
if ((signatures = (PGPSignatureList) factory.nextObject()) == null || signatures.isEmpty()) {
|
||||
Log.e(Constants.TAG, "No signatures given!");
|
||||
Timber.e("No signatures given!");
|
||||
return null;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.e(Constants.TAG, "Error while converting to PGPSignature!", e);
|
||||
Timber.e(e, "Error while converting to PGPSignature!");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user