mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-24 01:32:16 -05:00
backward compatible extras, restructuring
This commit is contained in:
parent
4130123e77
commit
1e78dd165a
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package org.thialfihar.android.apg;
|
package org.thialfihar.android.apg;
|
||||||
|
|
||||||
import org.thialfihar.android.apg.passphrase.PassphraseCacheService;
|
import org.thialfihar.android.apg.service.PassphraseCacheService;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
|
|
||||||
|
@ -34,10 +34,10 @@ import org.thialfihar.android.apg.R.string;
|
|||||||
import org.thialfihar.android.apg.helper.PGPHelper;
|
import org.thialfihar.android.apg.helper.PGPHelper;
|
||||||
import org.thialfihar.android.apg.helper.PGPMain;
|
import org.thialfihar.android.apg.helper.PGPMain;
|
||||||
import org.thialfihar.android.apg.helper.Preferences;
|
import org.thialfihar.android.apg.helper.Preferences;
|
||||||
import org.thialfihar.android.apg.passphrase.PassphraseCacheService;
|
|
||||||
import org.thialfihar.android.apg.provider.KeyRings;
|
import org.thialfihar.android.apg.provider.KeyRings;
|
||||||
import org.thialfihar.android.apg.provider.Keys;
|
import org.thialfihar.android.apg.provider.Keys;
|
||||||
import org.thialfihar.android.apg.provider.UserIds;
|
import org.thialfihar.android.apg.provider.UserIds;
|
||||||
|
import org.thialfihar.android.apg.service.PassphraseCacheService;
|
||||||
import org.thialfihar.android.apg.util.InputData;
|
import org.thialfihar.android.apg.util.InputData;
|
||||||
|
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.thialfihar.android.apg.passphrase;
|
package org.thialfihar.android.apg.deprecated;
|
||||||
|
|
||||||
import org.spongycastle.jce.provider.BouncyCastleProvider;
|
import org.spongycastle.jce.provider.BouncyCastleProvider;
|
||||||
import org.spongycastle.openpgp.PGPException;
|
import org.spongycastle.openpgp.PGPException;
|
||||||
@ -38,6 +38,13 @@ import android.widget.EditText;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO:
|
||||||
|
*
|
||||||
|
* - Use new PassphraseDialogFragment!
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class AskForPassphrase {
|
public class AskForPassphrase {
|
||||||
public static interface PassPhraseCallbackInterface {
|
public static interface PassPhraseCallbackInterface {
|
||||||
void passPhraseCallback(long keyId, String passPhrase);
|
void passPhraseCallback(long keyId, String passPhrase);
|
@ -71,13 +71,13 @@ import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyEncryptorBuilder;
|
|||||||
import org.spongycastle.openpgp.operator.jcajce.JcePGPDataEncryptorBuilder;
|
import org.spongycastle.openpgp.operator.jcajce.JcePGPDataEncryptorBuilder;
|
||||||
import org.spongycastle.openpgp.operator.jcajce.JcePublicKeyDataDecryptorFactoryBuilder;
|
import org.spongycastle.openpgp.operator.jcajce.JcePublicKeyDataDecryptorFactoryBuilder;
|
||||||
import org.spongycastle.openpgp.operator.jcajce.JcePublicKeyKeyEncryptionMethodGenerator;
|
import org.spongycastle.openpgp.operator.jcajce.JcePublicKeyKeyEncryptionMethodGenerator;
|
||||||
import org.thialfihar.android.apg.passphrase.CachedPassPhrase;
|
|
||||||
import org.thialfihar.android.apg.provider.DataProvider;
|
import org.thialfihar.android.apg.provider.DataProvider;
|
||||||
import org.thialfihar.android.apg.provider.Database;
|
import org.thialfihar.android.apg.provider.Database;
|
||||||
import org.thialfihar.android.apg.provider.KeyRings;
|
import org.thialfihar.android.apg.provider.KeyRings;
|
||||||
import org.thialfihar.android.apg.provider.Keys;
|
import org.thialfihar.android.apg.provider.Keys;
|
||||||
import org.thialfihar.android.apg.provider.UserIds;
|
import org.thialfihar.android.apg.provider.UserIds;
|
||||||
import org.thialfihar.android.apg.service.ApgService;
|
import org.thialfihar.android.apg.service.ApgService;
|
||||||
|
import org.thialfihar.android.apg.service.CachedPassphrase;
|
||||||
import org.thialfihar.android.apg.util.HkpKeyServer;
|
import org.thialfihar.android.apg.util.HkpKeyServer;
|
||||||
import org.thialfihar.android.apg.util.InputData;
|
import org.thialfihar.android.apg.util.InputData;
|
||||||
import org.thialfihar.android.apg.util.PositionAwareInputStream;
|
import org.thialfihar.android.apg.util.PositionAwareInputStream;
|
||||||
@ -185,7 +185,7 @@ public class PGPMain {
|
|||||||
".*?(-----BEGIN PGP PUBLIC KEY BLOCK-----.*?-----END PGP PUBLIC KEY BLOCK-----).*",
|
".*?(-----BEGIN PGP PUBLIC KEY BLOCK-----.*?-----END PGP PUBLIC KEY BLOCK-----).*",
|
||||||
Pattern.DOTALL);
|
Pattern.DOTALL);
|
||||||
|
|
||||||
private static HashMap<Long, CachedPassPhrase> mPassPhraseCache = new HashMap<Long, CachedPassPhrase>();
|
private static HashMap<Long, CachedPassphrase> mPassPhraseCache = new HashMap<Long, CachedPassphrase>();
|
||||||
private static String mEditPassPhrase = null;
|
private static String mEditPassPhrase = null;
|
||||||
|
|
||||||
private static Database mDatabase = null;
|
private static Database mDatabase = null;
|
||||||
@ -225,7 +225,7 @@ public class PGPMain {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setCachedPassPhrase(long keyId, String passPhrase) {
|
public static void setCachedPassPhrase(long keyId, String passPhrase) {
|
||||||
mPassPhraseCache.put(keyId, new CachedPassPhrase(new Date().getTime(), passPhrase));
|
mPassPhraseCache.put(keyId, new CachedPassphrase(new Date().getTime(), passPhrase));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getCachedPassPhrase(long keyId) {
|
public static String getCachedPassPhrase(long keyId) {
|
||||||
@ -241,7 +241,7 @@ public class PGPMain {
|
|||||||
}
|
}
|
||||||
realId = masterKey.getKeyID();
|
realId = masterKey.getKeyID();
|
||||||
}
|
}
|
||||||
CachedPassPhrase cpp = mPassPhraseCache.get(realId);
|
CachedPassphrase cpp = mPassPhraseCache.get(realId);
|
||||||
if (cpp == null) {
|
if (cpp == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -255,7 +255,7 @@ public class PGPMain {
|
|||||||
long realTtl = ttl * 1000;
|
long realTtl = ttl * 1000;
|
||||||
long now = new Date().getTime();
|
long now = new Date().getTime();
|
||||||
Vector<Long> oldKeys = new Vector<Long>();
|
Vector<Long> oldKeys = new Vector<Long>();
|
||||||
for (Map.Entry<Long, CachedPassPhrase> pair : mPassPhraseCache.entrySet()) {
|
for (Map.Entry<Long, CachedPassphrase> pair : mPassPhraseCache.entrySet()) {
|
||||||
long lived = now - pair.getValue().timestamp;
|
long lived = now - pair.getValue().timestamp;
|
||||||
if (lived >= realTtl) {
|
if (lived >= realTtl) {
|
||||||
oldKeys.add(pair.getKey());
|
oldKeys.add(pair.getKey());
|
||||||
@ -1516,7 +1516,7 @@ public class PGPMain {
|
|||||||
if (dataChunk instanceof PGPOnePassSignatureList) {
|
if (dataChunk instanceof PGPOnePassSignatureList) {
|
||||||
if (progress != null)
|
if (progress != null)
|
||||||
progress.setProgress(R.string.progress_processingSignature, currentProgress, 100);
|
progress.setProgress(R.string.progress_processingSignature, currentProgress, 100);
|
||||||
returnData.putBoolean(ApgService.EXTRA_SIGNATURE, true);
|
returnData.putBoolean(ApgService.RESULT_SIGNATURE, true);
|
||||||
PGPOnePassSignatureList sigList = (PGPOnePassSignatureList) dataChunk;
|
PGPOnePassSignatureList sigList = (PGPOnePassSignatureList) dataChunk;
|
||||||
for (int i = 0; i < sigList.size(); ++i) {
|
for (int i = 0; i < sigList.size(); ++i) {
|
||||||
signature = sigList.get(i);
|
signature = sigList.get(i);
|
||||||
@ -1534,12 +1534,12 @@ public class PGPMain {
|
|||||||
if (sigKeyRing != null) {
|
if (sigKeyRing != null) {
|
||||||
userId = PGPHelper.getMainUserId(PGPHelper.getMasterKey(sigKeyRing));
|
userId = PGPHelper.getMainUserId(PGPHelper.getMasterKey(sigKeyRing));
|
||||||
}
|
}
|
||||||
returnData.putString(ApgService.EXTRA_SIGNATURE_USER_ID, userId);
|
returnData.putString(ApgService.RESULT_SIGNATURE_USER_ID, userId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
returnData.putLong(ApgService.EXTRA_SIGNATURE_KEY_ID, signatureKeyId);
|
returnData.putLong(ApgService.RESULT_SIGNATURE_KEY_ID, signatureKeyId);
|
||||||
|
|
||||||
if (signature != null) {
|
if (signature != null) {
|
||||||
JcaPGPContentVerifierBuilderProvider contentVerifierBuilderProvider = new JcaPGPContentVerifierBuilderProvider()
|
JcaPGPContentVerifierBuilderProvider contentVerifierBuilderProvider = new JcaPGPContentVerifierBuilderProvider()
|
||||||
@ -1550,7 +1550,7 @@ public class PGPMain {
|
|||||||
// deprecated method:
|
// deprecated method:
|
||||||
// signature.initVerify(signatureKey, new BouncyCastleProvider());
|
// signature.initVerify(signatureKey, new BouncyCastleProvider());
|
||||||
} else {
|
} else {
|
||||||
returnData.putBoolean(ApgService.EXTRA_SIGNATURE_UNKNOWN, true);
|
returnData.putBoolean(ApgService.RESULT_SIGNATURE_UNKNOWN, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
dataChunk = plainFact.nextObject();
|
dataChunk = plainFact.nextObject();
|
||||||
@ -1587,7 +1587,7 @@ public class PGPMain {
|
|||||||
try {
|
try {
|
||||||
signature.update(buffer, 0, n);
|
signature.update(buffer, 0, n);
|
||||||
} catch (SignatureException e) {
|
} catch (SignatureException e) {
|
||||||
returnData.putBoolean(ApgService.EXTRA_SIGNATURE_SUCCESS, false);
|
returnData.putBoolean(ApgService.RESULT_SIGNATURE_SUCCESS, false);
|
||||||
signature = null;
|
signature = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1610,9 +1610,9 @@ public class PGPMain {
|
|||||||
PGPSignatureList signatureList = (PGPSignatureList) plainFact.nextObject();
|
PGPSignatureList signatureList = (PGPSignatureList) plainFact.nextObject();
|
||||||
PGPSignature messageSignature = signatureList.get(signatureIndex);
|
PGPSignature messageSignature = signatureList.get(signatureIndex);
|
||||||
if (signature.verify(messageSignature)) {
|
if (signature.verify(messageSignature)) {
|
||||||
returnData.putBoolean(ApgService.EXTRA_SIGNATURE_SUCCESS, true);
|
returnData.putBoolean(ApgService.RESULT_SIGNATURE_SUCCESS, true);
|
||||||
} else {
|
} else {
|
||||||
returnData.putBoolean(ApgService.EXTRA_SIGNATURE_SUCCESS, false);
|
returnData.putBoolean(ApgService.RESULT_SIGNATURE_SUCCESS, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1667,7 +1667,7 @@ public class PGPMain {
|
|||||||
byte[] clearText = out.toByteArray();
|
byte[] clearText = out.toByteArray();
|
||||||
outStream.write(clearText);
|
outStream.write(clearText);
|
||||||
|
|
||||||
returnData.putBoolean(ApgService.EXTRA_SIGNATURE, true);
|
returnData.putBoolean(ApgService.RESULT_SIGNATURE, true);
|
||||||
|
|
||||||
if (progress != null)
|
if (progress != null)
|
||||||
progress.setProgress(R.string.progress_processingSignature, 60, 100);
|
progress.setProgress(R.string.progress_processingSignature, 60, 100);
|
||||||
@ -1709,15 +1709,15 @@ public class PGPMain {
|
|||||||
if (sigKeyRing != null) {
|
if (sigKeyRing != null) {
|
||||||
userId = PGPHelper.getMainUserId(PGPHelper.getMasterKey(sigKeyRing));
|
userId = PGPHelper.getMainUserId(PGPHelper.getMasterKey(sigKeyRing));
|
||||||
}
|
}
|
||||||
returnData.putString(ApgService.EXTRA_SIGNATURE_USER_ID, userId);
|
returnData.putString(ApgService.RESULT_SIGNATURE_USER_ID, userId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
returnData.putLong(ApgService.EXTRA_SIGNATURE_KEY_ID, signatureKeyId);
|
returnData.putLong(ApgService.RESULT_SIGNATURE_KEY_ID, signatureKeyId);
|
||||||
|
|
||||||
if (signature == null) {
|
if (signature == null) {
|
||||||
returnData.putBoolean(ApgService.EXTRA_SIGNATURE_UNKNOWN, true);
|
returnData.putBoolean(ApgService.RESULT_SIGNATURE_UNKNOWN, true);
|
||||||
if (progress != null)
|
if (progress != null)
|
||||||
progress.setProgress(R.string.progress_done, 100, 100);
|
progress.setProgress(R.string.progress_done, 100, 100);
|
||||||
return returnData;
|
return returnData;
|
||||||
@ -1748,7 +1748,7 @@ public class PGPMain {
|
|||||||
} while (lookAhead != -1);
|
} while (lookAhead != -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
returnData.putBoolean(ApgService.EXTRA_SIGNATURE_SUCCESS, signature.verify());
|
returnData.putBoolean(ApgService.RESULT_SIGNATURE_SUCCESS, signature.verify());
|
||||||
|
|
||||||
if (progress != null)
|
if (progress != null)
|
||||||
progress.setProgress(R.string.progress_done, 100, 100);
|
progress.setProgress(R.string.progress_done, 100, 100);
|
||||||
|
@ -21,10 +21,6 @@ import org.spongycastle.bcpg.HashAlgorithmTags;
|
|||||||
import org.spongycastle.openpgp.PGPEncryptedData;
|
import org.spongycastle.openpgp.PGPEncryptedData;
|
||||||
import org.thialfihar.android.apg.Constants;
|
import org.thialfihar.android.apg.Constants;
|
||||||
import org.thialfihar.android.apg.Id;
|
import org.thialfihar.android.apg.Id;
|
||||||
import org.thialfihar.android.apg.Constants.defaults;
|
|
||||||
import org.thialfihar.android.apg.Constants.pref;
|
|
||||||
import org.thialfihar.android.apg.Id.choice;
|
|
||||||
import org.thialfihar.android.apg.Id.choice.compression;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
@ -75,40 +75,40 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
|
|||||||
// keys for data bundle
|
// keys for data bundle
|
||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
public static final String SECRET_KEY_ID = "secret_key_id";
|
public static final String SECRET_KEY_ID = "secretKeyId";
|
||||||
public static final String USE_ASCII_AMOR = "use_ascii_amor";
|
public static final String USE_ASCII_AMOR = "useAsciiAmor";
|
||||||
public static final String ENCRYPTION_KEYS_IDS = "encryption_keys_ids";
|
public static final String ENCRYPTION_KEYS_IDS = "encryptionKeysIds";
|
||||||
public static final String SIGNATURE_KEY_ID = "signature_key_id";
|
public static final String SIGNATURE_KEY_ID = "signatureKeyId";
|
||||||
public static final String COMPRESSION_ID = "compression_id";
|
public static final String COMPRESSION_ID = "compressionId";
|
||||||
public static final String GENERATE_SIGNATURE = "generate_signature";
|
public static final String GENERATE_SIGNATURE = "generateSignature";
|
||||||
public static final String SIGN_ONLY = "sign_only";
|
public static final String SIGN_ONLY = "signOnly";
|
||||||
public static final String MESSAGE_BYTES = "message_bytes";
|
public static final String MESSAGE_BYTES = "messageBytes";
|
||||||
public static final String INPUT_FILE = "input_file";
|
public static final String INPUT_FILE = "inputFile";
|
||||||
public static final String OUTPUT_FILE = "output_file";
|
public static final String OUTPUT_FILE = "outputFile";
|
||||||
public static final String PROVIDER_URI = "provider_uri";
|
public static final String PROVIDER_URI = "providerUri";
|
||||||
|
|
||||||
// decrypt
|
// decrypt
|
||||||
public static final String SIGNED_ONLY = "signed_only";
|
public static final String SIGNED_ONLY = "signedOnly";
|
||||||
public static final String RETURN_BYTES = "return_binary";
|
public static final String RETURN_BYTES = "returnBinary";
|
||||||
public static final String CIPHERTEXT_BYTES = "ciphertext_bytes";
|
public static final String CIPHERTEXT_BYTES = "ciphertextBytes";
|
||||||
public static final String ASSUME_SYMMETRIC = "assume_symmetric";
|
public static final String ASSUME_SYMMETRIC = "assumeSymmetric";
|
||||||
|
|
||||||
// edit keys
|
// edit keys
|
||||||
public static final String NEW_PASSPHRASE = "new_passphrase";
|
public static final String NEW_PASSPHRASE = "newPassphrase";
|
||||||
public static final String CURRENT_PASSPHRASE = "current_passphrase";
|
public static final String CURRENT_PASSPHRASE = "currentPassphrase";
|
||||||
public static final String USER_IDS = "user_ids";
|
public static final String USER_IDS = "userIds";
|
||||||
public static final String KEYS = "keys";
|
public static final String KEYS = "keys";
|
||||||
public static final String KEYS_USAGES = "keys_usages";
|
public static final String KEYS_USAGES = "keysUsages";
|
||||||
public static final String MASTER_KEY_ID = "master_key_id";
|
public static final String MASTER_KEY_ID = "masterKeyId";
|
||||||
|
|
||||||
// generate key
|
// generate key
|
||||||
public static final String ALGORITHM = "algorithm";
|
public static final String ALGORITHM = "algorithm";
|
||||||
public static final String KEY_SIZE = "key_size";
|
public static final String KEY_SIZE = "key_size";
|
||||||
public static final String SYMMETRIC_PASSPHRASE = "passphrase";
|
public static final String SYMMETRIC_PASSPHRASE = "passphrase";
|
||||||
public static final String MASTER_KEY = "master_key";
|
public static final String MASTER_KEY = "masterKey";
|
||||||
|
|
||||||
// delete file securely
|
// delete file securely
|
||||||
public static final String DELETE_FILE = "delete_file";
|
public static final String DELETE_FILE = "deleteFile";
|
||||||
|
|
||||||
// possible EXTRA_ACTIONs
|
// possible EXTRA_ACTIONs
|
||||||
public static final int ACTION_ENCRYPT_SIGN_BYTES = 10;
|
public static final int ACTION_ENCRYPT_SIGN_BYTES = 10;
|
||||||
@ -127,24 +127,24 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
|
|||||||
|
|
||||||
// possible data keys as result
|
// possible data keys as result
|
||||||
// keys
|
// keys
|
||||||
public static final String RESULT_NEW_KEY = "new_key";
|
public static final String RESULT_NEW_KEY = "newKey";
|
||||||
public static final String RESULT_NEW_KEY2 = "new_key2";
|
public static final String RESULT_NEW_KEY2 = "newKey2";
|
||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
public static final String RESULT_SIGNATURE_DATA = "signature_data";
|
public static final String RESULT_SIGNATURE_DATA = "signatureData";
|
||||||
public static final String RESULT_SIGNATURE_TEXT = "signature_text";
|
public static final String RESULT_SIGNATURE_TEXT = "signatureText";
|
||||||
public static final String RESULT_ENCRYPTED_MESSAGE = "encrypted_message";
|
public static final String RESULT_ENCRYPTED_MESSAGE = "encryptedMessage";
|
||||||
public static final String RESULT_ENCRYPTED_DATA = "encrypted_data";
|
public static final String RESULT_ENCRYPTED_DATA = "encryptedData";
|
||||||
public static final String RESULT_URI = "result_uri";
|
public static final String RESULT_URI = "resultUri";
|
||||||
|
|
||||||
// decrypt
|
// decrypt
|
||||||
public static final String RESULT_DECRYPTED_MESSAGE = "decrypted_message";
|
public static final String RESULT_DECRYPTED_MESSAGE = "decryptedMessage";
|
||||||
public static final String RESULT_DECRYPTED_DATA = "decrypted_data";
|
public static final String RESULT_DECRYPTED_DATA = "decryptedData";
|
||||||
public static final String EXTRA_SIGNATURE = "signature";
|
public static final String RESULT_SIGNATURE = "signature";
|
||||||
public static final String EXTRA_SIGNATURE_KEY_ID = "signature_key_id";
|
public static final String RESULT_SIGNATURE_KEY_ID = "signatureKeyId";
|
||||||
public static final String EXTRA_SIGNATURE_USER_ID = "signature_user_id";
|
public static final String RESULT_SIGNATURE_USER_ID = "signatureUserId";
|
||||||
public static final String EXTRA_SIGNATURE_SUCCESS = "signature_success";
|
public static final String RESULT_SIGNATURE_SUCCESS = "signatureSuccess";
|
||||||
public static final String EXTRA_SIGNATURE_UNKNOWN = "signature_unknown";
|
public static final String RESULT_SIGNATURE_UNKNOWN = "signatureUnknown";
|
||||||
|
|
||||||
Messenger mMessenger;
|
Messenger mMessenger;
|
||||||
|
|
||||||
@ -197,8 +197,8 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
|
|||||||
long masterKeyId = data.getLong(MASTER_KEY_ID);
|
long masterKeyId = data.getLong(MASTER_KEY_ID);
|
||||||
|
|
||||||
/* Operation */
|
/* Operation */
|
||||||
PGPMain.buildSecretKey(this, userIds, keys, keysUsages, masterKeyId,
|
PGPMain.buildSecretKey(this, userIds, keys, keysUsages, masterKeyId, oldPassPhrase,
|
||||||
oldPassPhrase, newPassPhrase, this);
|
newPassPhrase, this);
|
||||||
PGPMain.setCachedPassPhrase(masterKeyId, newPassPhrase);
|
PGPMain.setCachedPassPhrase(masterKeyId, newPassPhrase);
|
||||||
|
|
||||||
/* Output */
|
/* Output */
|
||||||
@ -429,8 +429,7 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
|
|||||||
while (true) {
|
while (true) {
|
||||||
streamFilename = PGPMain.generateRandomString(32);
|
streamFilename = PGPMain.generateRandomString(32);
|
||||||
if (streamFilename == null) {
|
if (streamFilename == null) {
|
||||||
throw new PGPMain.GeneralException(
|
throw new PGPMain.GeneralException("couldn't generate random file name");
|
||||||
"couldn't generate random file name");
|
|
||||||
}
|
}
|
||||||
openFileInput(streamFilename).close();
|
openFileInput(streamFilename).close();
|
||||||
}
|
}
|
||||||
@ -613,8 +612,7 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
|
|||||||
while (true) {
|
while (true) {
|
||||||
streamFilename = PGPMain.generateRandomString(32);
|
streamFilename = PGPMain.generateRandomString(32);
|
||||||
if (streamFilename == null) {
|
if (streamFilename == null) {
|
||||||
throw new PGPMain.GeneralException(
|
throw new PGPMain.GeneralException("couldn't generate random file name");
|
||||||
"couldn't generate random file name");
|
|
||||||
}
|
}
|
||||||
openFileInput(streamFilename).close();
|
openFileInput(streamFilename).close();
|
||||||
}
|
}
|
||||||
|
@ -12,13 +12,13 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.thialfihar.android.apg.passphrase;
|
package org.thialfihar.android.apg.service;
|
||||||
|
|
||||||
public class CachedPassPhrase {
|
public class CachedPassphrase {
|
||||||
public final long timestamp;
|
public final long timestamp;
|
||||||
public final String passPhrase;
|
public final String passPhrase;
|
||||||
|
|
||||||
public CachedPassPhrase(long timestamp, String passPhrase) {
|
public CachedPassphrase(long timestamp, String passPhrase) {
|
||||||
super();
|
super();
|
||||||
this.timestamp = timestamp;
|
this.timestamp = timestamp;
|
||||||
this.passPhrase = passPhrase;
|
this.passPhrase = passPhrase;
|
||||||
@ -33,11 +33,11 @@ public class CachedPassPhrase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
if (!(other instanceof CachedPassPhrase)) {
|
if (!(other instanceof CachedPassphrase)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CachedPassPhrase o = (CachedPassPhrase) other;
|
CachedPassphrase o = (CachedPassphrase) other;
|
||||||
if (timestamp != o.timestamp) {
|
if (timestamp != o.timestamp) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
@ -12,7 +12,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.thialfihar.android.apg.passphrase;
|
package org.thialfihar.android.apg.service;
|
||||||
|
|
||||||
import org.thialfihar.android.apg.helper.PGPMain;
|
import org.thialfihar.android.apg.helper.PGPMain;
|
||||||
import org.thialfihar.android.apg.helper.Preferences;
|
import org.thialfihar.android.apg.helper.Preferences;
|
@ -17,25 +17,20 @@
|
|||||||
package org.thialfihar.android.apg.ui;
|
package org.thialfihar.android.apg.ui;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.thialfihar.android.apg.R;
|
import org.thialfihar.android.apg.R;
|
||||||
import org.thialfihar.android.apg.Constants;
|
import org.thialfihar.android.apg.Constants;
|
||||||
import org.thialfihar.android.apg.Id;
|
import org.thialfihar.android.apg.Id;
|
||||||
import org.thialfihar.android.apg.ProgressDialogUpdater;
|
import org.thialfihar.android.apg.ProgressDialogUpdater;
|
||||||
|
import org.thialfihar.android.apg.deprecated.AskForPassphrase;
|
||||||
import org.thialfihar.android.apg.deprecated.PausableThread;
|
import org.thialfihar.android.apg.deprecated.PausableThread;
|
||||||
import org.thialfihar.android.apg.helper.PGPMain;
|
import org.thialfihar.android.apg.helper.PGPMain;
|
||||||
import org.thialfihar.android.apg.helper.Preferences;
|
import org.thialfihar.android.apg.helper.Preferences;
|
||||||
import org.thialfihar.android.apg.passphrase.AskForPassphrase;
|
|
||||||
import org.thialfihar.android.apg.passphrase.PassphraseCacheService;
|
|
||||||
|
|
||||||
import com.actionbarsherlock.app.ActionBar;
|
import com.actionbarsherlock.app.ActionBar;
|
||||||
import com.actionbarsherlock.app.SherlockActivity;
|
|
||||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||||
import com.actionbarsherlock.view.MenuItem;
|
import com.actionbarsherlock.view.MenuItem;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
@ -45,9 +40,6 @@ import android.os.Bundle;
|
|||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.support.v4.app.DialogFragment;
|
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
public class BaseActivity extends SherlockFragmentActivity implements Runnable,
|
public class BaseActivity extends SherlockFragmentActivity implements Runnable,
|
||||||
ProgressDialogUpdater, AskForPassphrase.PassPhraseCallbackInterface {
|
ProgressDialogUpdater, AskForPassphrase.PassPhraseCallbackInterface {
|
||||||
|
@ -770,9 +770,9 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.getBoolean(ApgService.EXTRA_SIGNATURE)) {
|
if (data.getBoolean(ApgService.RESULT_SIGNATURE)) {
|
||||||
String userId = data.getString(ApgService.EXTRA_SIGNATURE_USER_ID);
|
String userId = data.getString(ApgService.RESULT_SIGNATURE_USER_ID);
|
||||||
mSignatureKeyId = data.getLong(ApgService.EXTRA_SIGNATURE_KEY_ID);
|
mSignatureKeyId = data.getLong(ApgService.RESULT_SIGNATURE_KEY_ID);
|
||||||
mUserIdRest
|
mUserIdRest
|
||||||
.setText("id: " + PGPHelper.getSmallFingerPrint(mSignatureKeyId));
|
.setText("id: " + PGPHelper.getSmallFingerPrint(mSignatureKeyId));
|
||||||
if (userId == null) {
|
if (userId == null) {
|
||||||
@ -785,9 +785,9 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
|||||||
}
|
}
|
||||||
mUserId.setText(userId);
|
mUserId.setText(userId);
|
||||||
|
|
||||||
if (data.getBoolean(ApgService.EXTRA_SIGNATURE_SUCCESS)) {
|
if (data.getBoolean(ApgService.RESULT_SIGNATURE_SUCCESS)) {
|
||||||
mSignatureStatusImage.setImageResource(R.drawable.overlay_ok);
|
mSignatureStatusImage.setImageResource(R.drawable.overlay_ok);
|
||||||
} else if (data.getBoolean(ApgService.EXTRA_SIGNATURE_UNKNOWN)) {
|
} else if (data.getBoolean(ApgService.RESULT_SIGNATURE_UNKNOWN)) {
|
||||||
mSignatureStatusImage.setImageResource(R.drawable.overlay_error);
|
mSignatureStatusImage.setImageResource(R.drawable.overlay_error);
|
||||||
Toast.makeText(DecryptActivity.this,
|
Toast.makeText(DecryptActivity.this,
|
||||||
R.string.unknownSignatureKeyTouchToLookUp, Toast.LENGTH_LONG)
|
R.string.unknownSignatureKeyTouchToLookUp, Toast.LENGTH_LONG)
|
||||||
|
@ -23,7 +23,6 @@ import org.thialfihar.android.apg.Constants;
|
|||||||
import org.thialfihar.android.apg.Id;
|
import org.thialfihar.android.apg.Id;
|
||||||
import org.thialfihar.android.apg.helper.PGPHelper;
|
import org.thialfihar.android.apg.helper.PGPHelper;
|
||||||
import org.thialfihar.android.apg.helper.PGPMain;
|
import org.thialfihar.android.apg.helper.PGPMain;
|
||||||
import org.thialfihar.android.apg.helper.OtherHelper;
|
|
||||||
import org.thialfihar.android.apg.helper.PGPConversionHelper;
|
import org.thialfihar.android.apg.helper.PGPConversionHelper;
|
||||||
import org.thialfihar.android.apg.service.ApgHandler;
|
import org.thialfihar.android.apg.service.ApgHandler;
|
||||||
import org.thialfihar.android.apg.service.ApgService;
|
import org.thialfihar.android.apg.service.ApgService;
|
||||||
|
@ -21,7 +21,6 @@ import org.thialfihar.android.apg.R;
|
|||||||
import org.thialfihar.android.apg.Constants;
|
import org.thialfihar.android.apg.Constants;
|
||||||
import org.thialfihar.android.apg.Id;
|
import org.thialfihar.android.apg.Id;
|
||||||
import org.thialfihar.android.apg.helper.PGPHelper;
|
import org.thialfihar.android.apg.helper.PGPHelper;
|
||||||
import org.thialfihar.android.apg.helper.PGPMain;
|
|
||||||
import org.thialfihar.android.apg.util.HkpKeyServer;
|
import org.thialfihar.android.apg.util.HkpKeyServer;
|
||||||
import org.thialfihar.android.apg.util.KeyServer.InsufficientQuery;
|
import org.thialfihar.android.apg.util.KeyServer.InsufficientQuery;
|
||||||
import org.thialfihar.android.apg.util.KeyServer.KeyInfo;
|
import org.thialfihar.android.apg.util.KeyServer.KeyInfo;
|
||||||
|
@ -22,7 +22,6 @@ import java.security.Security;
|
|||||||
import org.spongycastle.jce.provider.BouncyCastleProvider;
|
import org.spongycastle.jce.provider.BouncyCastleProvider;
|
||||||
import org.thialfihar.android.apg.Id;
|
import org.thialfihar.android.apg.Id;
|
||||||
import org.thialfihar.android.apg.R;
|
import org.thialfihar.android.apg.R;
|
||||||
import org.thialfihar.android.apg.helper.PGPMain;
|
|
||||||
|
|
||||||
import com.actionbarsherlock.app.ActionBar;
|
import com.actionbarsherlock.app.ActionBar;
|
||||||
import com.actionbarsherlock.app.SherlockActivity;
|
import com.actionbarsherlock.app.SherlockActivity;
|
||||||
|
@ -20,9 +20,8 @@ import org.spongycastle.bcpg.HashAlgorithmTags;
|
|||||||
import org.spongycastle.openpgp.PGPEncryptedData;
|
import org.spongycastle.openpgp.PGPEncryptedData;
|
||||||
import org.thialfihar.android.apg.Constants;
|
import org.thialfihar.android.apg.Constants;
|
||||||
import org.thialfihar.android.apg.Id;
|
import org.thialfihar.android.apg.Id;
|
||||||
import org.thialfihar.android.apg.helper.PGPMain;
|
|
||||||
import org.thialfihar.android.apg.helper.Preferences;
|
import org.thialfihar.android.apg.helper.Preferences;
|
||||||
import org.thialfihar.android.apg.passphrase.PassphraseCacheService;
|
import org.thialfihar.android.apg.service.PassphraseCacheService;
|
||||||
import org.thialfihar.android.apg.ui.widget.IntegerListPreference;
|
import org.thialfihar.android.apg.ui.widget.IntegerListPreference;
|
||||||
import org.thialfihar.android.apg.R;
|
import org.thialfihar.android.apg.R;
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ import java.util.Vector;
|
|||||||
|
|
||||||
import org.thialfihar.android.apg.Id;
|
import org.thialfihar.android.apg.Id;
|
||||||
import org.thialfihar.android.apg.R;
|
import org.thialfihar.android.apg.R;
|
||||||
import org.thialfihar.android.apg.helper.PGPMain;
|
|
||||||
import org.thialfihar.android.apg.ui.widget.Editor;
|
import org.thialfihar.android.apg.ui.widget.Editor;
|
||||||
import org.thialfihar.android.apg.ui.widget.KeyServerEditor;
|
import org.thialfihar.android.apg.ui.widget.KeyServerEditor;
|
||||||
import org.thialfihar.android.apg.ui.widget.Editor.EditorListener;
|
import org.thialfihar.android.apg.ui.widget.Editor.EditorListener;
|
||||||
|
@ -26,7 +26,6 @@ import org.thialfihar.android.apg.helper.PGPMain;
|
|||||||
import com.actionbarsherlock.view.Menu;
|
import com.actionbarsherlock.view.Menu;
|
||||||
import com.actionbarsherlock.view.MenuItem;
|
import com.actionbarsherlock.view.MenuItem;
|
||||||
|
|
||||||
import android.app.ListActivity;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
|
@ -19,9 +19,9 @@ package org.thialfihar.android.apg.ui;
|
|||||||
import org.thialfihar.android.apg.R;
|
import org.thialfihar.android.apg.R;
|
||||||
import org.thialfihar.android.apg.Constants;
|
import org.thialfihar.android.apg.Constants;
|
||||||
import org.thialfihar.android.apg.Id;
|
import org.thialfihar.android.apg.Id;
|
||||||
|
import org.thialfihar.android.apg.deprecated.AskForPassphrase;
|
||||||
import org.thialfihar.android.apg.helper.PGPHelper;
|
import org.thialfihar.android.apg.helper.PGPHelper;
|
||||||
import org.thialfihar.android.apg.helper.PGPMain;
|
import org.thialfihar.android.apg.helper.PGPMain;
|
||||||
import org.thialfihar.android.apg.passphrase.AskForPassphrase;
|
|
||||||
|
|
||||||
import com.actionbarsherlock.view.Menu;
|
import com.actionbarsherlock.view.Menu;
|
||||||
import com.actionbarsherlock.view.MenuItem;
|
import com.actionbarsherlock.view.MenuItem;
|
||||||
|
@ -21,7 +21,6 @@ import java.util.Vector;
|
|||||||
import org.thialfihar.android.apg.Constants;
|
import org.thialfihar.android.apg.Constants;
|
||||||
import org.thialfihar.android.apg.R;
|
import org.thialfihar.android.apg.R;
|
||||||
import org.thialfihar.android.apg.Id;
|
import org.thialfihar.android.apg.Id;
|
||||||
import org.thialfihar.android.apg.helper.PGPMain;
|
|
||||||
import org.thialfihar.android.apg.ui.widget.SelectPublicKeyListAdapter;
|
import org.thialfihar.android.apg.ui.widget.SelectPublicKeyListAdapter;
|
||||||
|
|
||||||
import com.actionbarsherlock.app.ActionBar;
|
import com.actionbarsherlock.app.ActionBar;
|
||||||
|
@ -19,7 +19,6 @@ package org.thialfihar.android.apg.ui;
|
|||||||
import org.thialfihar.android.apg.Constants;
|
import org.thialfihar.android.apg.Constants;
|
||||||
import org.thialfihar.android.apg.R;
|
import org.thialfihar.android.apg.R;
|
||||||
import org.thialfihar.android.apg.Id;
|
import org.thialfihar.android.apg.Id;
|
||||||
import org.thialfihar.android.apg.helper.PGPMain;
|
|
||||||
import org.thialfihar.android.apg.ui.widget.SelectSecretKeyListAdapter;
|
import org.thialfihar.android.apg.ui.widget.SelectSecretKeyListAdapter;
|
||||||
|
|
||||||
import com.actionbarsherlock.app.ActionBar;
|
import com.actionbarsherlock.app.ActionBar;
|
||||||
|
@ -20,7 +20,6 @@ import org.spongycastle.openpgp.PGPPublicKey;
|
|||||||
import org.spongycastle.openpgp.PGPSecretKey;
|
import org.spongycastle.openpgp.PGPSecretKey;
|
||||||
import org.thialfihar.android.apg.Id;
|
import org.thialfihar.android.apg.Id;
|
||||||
import org.thialfihar.android.apg.helper.PGPHelper;
|
import org.thialfihar.android.apg.helper.PGPHelper;
|
||||||
import org.thialfihar.android.apg.helper.PGPMain;
|
|
||||||
import org.thialfihar.android.apg.util.Choice;
|
import org.thialfihar.android.apg.util.Choice;
|
||||||
import org.thialfihar.android.apg.R;
|
import org.thialfihar.android.apg.R;
|
||||||
|
|
||||||
|
@ -193,13 +193,6 @@ public class ApgIntentHelper {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
apgData.setEncryptedData(data.getStringExtra(Constants.EXTRA_ENCRYPTED_MESSAGE));
|
apgData.setEncryptedData(data.getStringExtra(Constants.EXTRA_ENCRYPTED_MESSAGE));
|
||||||
// this was a stupid bug in an earlier version, just gonna leave this in for an APG
|
|
||||||
// version or two
|
|
||||||
if (apgData.getEncryptedData() == null) {
|
|
||||||
apgData.setEncryptedData(data.getStringExtra(Constants.EXTRA_DECRYPTED_MESSAGE));
|
|
||||||
}
|
|
||||||
if (apgData.getEncryptedData() != null) {
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Constants.DECRYPT_MESSAGE:
|
case Constants.DECRYPT_MESSAGE:
|
||||||
@ -215,7 +208,6 @@ public class ApgIntentHelper {
|
|||||||
false));
|
false));
|
||||||
|
|
||||||
apgData.setDecryptedData(data.getStringExtra(Constants.EXTRA_DECRYPTED_MESSAGE));
|
apgData.setDecryptedData(data.getStringExtra(Constants.EXTRA_DECRYPTED_MESSAGE));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user