mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-23 17:22:16 -05:00
Use CompressionAlgorithmTags instead of homebrew constants
This commit is contained in:
parent
f4802157dd
commit
e4974ac409
@ -19,7 +19,6 @@ package org.sufficientlysecure.keychain;
|
||||
|
||||
import android.os.Environment;
|
||||
|
||||
import org.spongycastle.bcpg.CompressionAlgorithmTags;
|
||||
import org.spongycastle.jce.provider.BouncyCastleProvider;
|
||||
import org.sufficientlysecure.keychain.remote.ui.AppsListActivity;
|
||||
import org.sufficientlysecure.keychain.ui.DecryptActivity;
|
||||
@ -50,7 +49,7 @@ public final class Constants {
|
||||
|
||||
public static final String CUSTOM_CONTACT_DATA_MIME_TYPE = "vnd.android.cursor.item/vnd.org.sufficientlysecure.keychain.key";
|
||||
|
||||
public static int TEMPFILE_TTL = 24*60*60*1000; // 1 day
|
||||
public static int TEMPFILE_TTL = 24 * 60 * 60 * 1000; // 1 day
|
||||
|
||||
public static final class Path {
|
||||
public static final File APP_DIR = new File(Environment.getExternalStorageDirectory(), "OpenKeychain");
|
||||
@ -90,16 +89,6 @@ public final class Constants {
|
||||
};
|
||||
}
|
||||
|
||||
public static final class choice {
|
||||
public static final class compression {
|
||||
// TODO: legacy reasons :/ better: CompressionAlgorithmTags.UNCOMPRESSED
|
||||
public static final int none = 0x21070001;
|
||||
public static final int zlib = CompressionAlgorithmTags.ZLIB;
|
||||
public static final int bzip2 = CompressionAlgorithmTags.BZIP2;
|
||||
public static final int zip = CompressionAlgorithmTags.ZIP;
|
||||
}
|
||||
}
|
||||
|
||||
public static final class key {
|
||||
public static final int none = 0;
|
||||
public static final int symmetric = -1;
|
||||
|
@ -84,7 +84,7 @@ public class KeychainApplication extends Application {
|
||||
setupAccountAsNeeded(this);
|
||||
|
||||
// Update keyserver list as needed
|
||||
Preferences.getPreferences(this).updateKeyServers();
|
||||
Preferences.getPreferences(this).updatePreferences();
|
||||
|
||||
TlsHelper.addStaticCA("pool.sks-keyservers.net", getAssets(), "sks-keyservers.netCA.cer");
|
||||
|
||||
|
@ -21,6 +21,7 @@ package org.sufficientlysecure.keychain.helper;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import org.spongycastle.bcpg.CompressionAlgorithmTags;
|
||||
import org.spongycastle.bcpg.HashAlgorithmTags;
|
||||
import org.spongycastle.openpgp.PGPEncryptedData;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
@ -99,7 +100,7 @@ public class Preferences {
|
||||
|
||||
public int getDefaultMessageCompression() {
|
||||
return mSharedPreferences.getInt(Constants.Pref.DEFAULT_MESSAGE_COMPRESSION,
|
||||
Constants.choice.compression.zlib);
|
||||
CompressionAlgorithmTags.ZLIB);
|
||||
}
|
||||
|
||||
public void setDefaultMessageCompression(int value) {
|
||||
@ -110,7 +111,7 @@ public class Preferences {
|
||||
|
||||
public int getDefaultFileCompression() {
|
||||
return mSharedPreferences.getInt(Constants.Pref.DEFAULT_FILE_COMPRESSION,
|
||||
Constants.choice.compression.none);
|
||||
CompressionAlgorithmTags.UNCOMPRESSED);
|
||||
}
|
||||
|
||||
public void setDefaultFileCompression(int value) {
|
||||
@ -180,7 +181,8 @@ public class Preferences {
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
public void updateKeyServers() {
|
||||
public void updatePreferences() {
|
||||
// migrate keyserver to hkps
|
||||
if (mSharedPreferences.getInt(Constants.Pref.KEY_SERVERS_DEFAULT_VERSION, 0) !=
|
||||
Constants.Defaults.KEY_SERVERS_VERSION) {
|
||||
String[] servers = getKeyServers();
|
||||
@ -196,6 +198,11 @@ public class Preferences {
|
||||
.putInt(Constants.Pref.KEY_SERVERS_DEFAULT_VERSION, Constants.Defaults.KEY_SERVERS_VERSION)
|
||||
.commit();
|
||||
}
|
||||
|
||||
// migrate old uncompressed constant to new one
|
||||
if (mSharedPreferences.getInt(Constants.Pref.DEFAULT_FILE_COMPRESSION, 0) == 0x21070001) {
|
||||
setDefaultFileCompression(CompressionAlgorithmTags.UNCOMPRESSED);
|
||||
}
|
||||
}
|
||||
|
||||
public void setConcealPgpApplication(boolean conceal) {
|
||||
|
@ -20,6 +20,7 @@ package org.sufficientlysecure.keychain.pgp;
|
||||
|
||||
import org.spongycastle.bcpg.ArmoredOutputStream;
|
||||
import org.spongycastle.bcpg.BCPGOutputStream;
|
||||
import org.spongycastle.bcpg.CompressionAlgorithmTags;
|
||||
import org.spongycastle.openpgp.PGPCompressedDataGenerator;
|
||||
import org.spongycastle.openpgp.PGPEncryptedDataGenerator;
|
||||
import org.spongycastle.openpgp.PGPException;
|
||||
@ -112,7 +113,7 @@ public class PgpSignEncrypt {
|
||||
// optional
|
||||
private Progressable mProgressable = null;
|
||||
private boolean mEnableAsciiArmorOutput = false;
|
||||
private int mCompressionId = Constants.choice.compression.none;
|
||||
private int mCompressionId = CompressionAlgorithmTags.UNCOMPRESSED;
|
||||
private long[] mEncryptionMasterKeyIds = null;
|
||||
private String mSymmetricPassphrase = null;
|
||||
private int mSymmetricEncryptionAlgorithm = 0;
|
||||
@ -242,7 +243,7 @@ public class PgpSignEncrypt {
|
||||
boolean enableSignature = mSignatureMasterKeyId != Constants.key.none;
|
||||
boolean enableEncryption = ((mEncryptionMasterKeyIds != null && mEncryptionMasterKeyIds.length > 0)
|
||||
|| mSymmetricPassphrase != null);
|
||||
boolean enableCompression = (mCompressionId != Constants.choice.compression.none);
|
||||
boolean enableCompression = (mCompressionId != CompressionAlgorithmTags.UNCOMPRESSED);
|
||||
|
||||
Log.d(Constants.TAG, "enableSignature:" + enableSignature
|
||||
+ "\nenableEncryption:" + enableEncryption
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package org.sufficientlysecure.keychain.remote;
|
||||
|
||||
import org.spongycastle.bcpg.CompressionAlgorithmTags;
|
||||
import org.spongycastle.bcpg.HashAlgorithmTags;
|
||||
import org.spongycastle.openpgp.PGPEncryptedData;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
@ -39,7 +40,7 @@ public class AccountSettings {
|
||||
// defaults:
|
||||
this.mEncryptionAlgorithm = PGPEncryptedData.AES_256;
|
||||
this.mHashAlgorithm = HashAlgorithmTags.SHA512;
|
||||
this.mCompression = Constants.choice.compression.zlib;
|
||||
this.mCompression = CompressionAlgorithmTags.ZLIB;
|
||||
}
|
||||
|
||||
public String getAccountName() {
|
||||
|
@ -27,6 +27,7 @@ import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceScreen;
|
||||
|
||||
import org.spongycastle.bcpg.CompressionAlgorithmTags;
|
||||
import org.spongycastle.bcpg.HashAlgorithmTags;
|
||||
import org.spongycastle.openpgp.PGPEncryptedData;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
@ -88,10 +89,10 @@ public class PreferencesActivity extends PreferenceActivity {
|
||||
(IntegerListPreference) findPreference(Constants.Pref.DEFAULT_ENCRYPTION_ALGORITHM));
|
||||
|
||||
int[] valueIds = new int[]{
|
||||
Constants.choice.compression.none,
|
||||
Constants.choice.compression.zip,
|
||||
Constants.choice.compression.zlib,
|
||||
Constants.choice.compression.bzip2,
|
||||
CompressionAlgorithmTags.UNCOMPRESSED,
|
||||
CompressionAlgorithmTags.ZIP,
|
||||
CompressionAlgorithmTags.ZLIB,
|
||||
CompressionAlgorithmTags.BZIP2,
|
||||
};
|
||||
String[] entries = new String[]{
|
||||
getString(R.string.choice_none) + " (" + getString(R.string.compression_fast) + ")",
|
||||
@ -232,10 +233,10 @@ public class PreferencesActivity extends PreferenceActivity {
|
||||
(IntegerListPreference) findPreference(Constants.Pref.DEFAULT_ENCRYPTION_ALGORITHM));
|
||||
|
||||
int[] valueIds = new int[]{
|
||||
Constants.choice.compression.none,
|
||||
Constants.choice.compression.zip,
|
||||
Constants.choice.compression.zlib,
|
||||
Constants.choice.compression.bzip2,
|
||||
CompressionAlgorithmTags.UNCOMPRESSED,
|
||||
CompressionAlgorithmTags.ZIP,
|
||||
CompressionAlgorithmTags.ZLIB,
|
||||
CompressionAlgorithmTags.BZIP2,
|
||||
};
|
||||
|
||||
String[] entries = new String[]{
|
||||
|
@ -20,6 +20,7 @@ package org.sufficientlysecure.keychain.util;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
|
||||
import org.spongycastle.bcpg.CompressionAlgorithmTags;
|
||||
import org.spongycastle.bcpg.HashAlgorithmTags;
|
||||
import org.spongycastle.openpgp.PGPEncryptedData;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
@ -57,13 +58,13 @@ public class AlgorithmNames {
|
||||
mHashNames.put(HashAlgorithmTags.SHA384, "SHA-384");
|
||||
mHashNames.put(HashAlgorithmTags.SHA512, "SHA-512");
|
||||
|
||||
mCompressionNames.put(Constants.choice.compression.none, mActivity.getString(R.string.choice_none)
|
||||
mCompressionNames.put(CompressionAlgorithmTags.UNCOMPRESSED, mActivity.getString(R.string.choice_none)
|
||||
+ " (" + mActivity.getString(R.string.compression_fast) + ")");
|
||||
mCompressionNames.put(Constants.choice.compression.zip,
|
||||
mCompressionNames.put(CompressionAlgorithmTags.ZIP,
|
||||
"ZIP (" + mActivity.getString(R.string.compression_fast) + ")");
|
||||
mCompressionNames.put(Constants.choice.compression.zlib,
|
||||
mCompressionNames.put(CompressionAlgorithmTags.ZLIB,
|
||||
"ZLIB (" + mActivity.getString(R.string.compression_fast) + ")");
|
||||
mCompressionNames.put(Constants.choice.compression.bzip2,
|
||||
mCompressionNames.put(CompressionAlgorithmTags.BZIP2,
|
||||
"BZIP2 (" + mActivity.getString(R.string.compression_very_slow) + ")");
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@
|
||||
<string name="label_passphrase">Passphrase</string>
|
||||
<string name="label_passphrase_again">Repeat Passphrase</string>
|
||||
<string name="label_algorithm">Algorithm</string>
|
||||
<string name="label_ascii_armor">ASCII Armor</string>
|
||||
<string name="label_ascii_armor">File ASCII Armor</string>
|
||||
<string name="label_file_ascii_armor">Files: ASCII Armor</string>
|
||||
<string name="label_conceal_pgp_application">Let others know that you\'re using OpenKeychain</string>
|
||||
<string name="label_conceal_pgp_application_summary">Writes \'OpenKeychain v2.7\' to OpenPGP signatures, ciphertext, and exported keys</string>
|
||||
|
Loading…
Reference in New Issue
Block a user