diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-08-14 11:44:47 +0200 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-08-14 11:44:47 +0200 |
commit | d0987edab96573b210ce14432432248f609b14f0 (patch) | |
tree | 785f3cc803a34f94fc7964e9bc4fe0ebd69c1055 /OpenKeychain/src | |
parent | f941431d634b1e008726ce5501ffed55cb6899de (diff) | |
download | open-keychain-d0987edab96573b210ce14432432248f609b14f0.tar.gz open-keychain-d0987edab96573b210ce14432432248f609b14f0.tar.bz2 open-keychain-d0987edab96573b210ce14432432248f609b14f0.zip |
Dont write version header by default
Diffstat (limited to 'OpenKeychain/src')
17 files changed, 61 insertions, 44 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java index 05676c5d0..f240b5cc2 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java @@ -67,7 +67,7 @@ public final class Constants { public static final String FORCE_V3_SIGNATURES = "forceV3Signatures"; public static final String KEY_SERVERS = "keyServers"; public static final String KEY_SERVERS_DEFAULT_VERSION = "keyServersDefaultVersion"; - public static final String CONCEAL_PGP_APPLICATION = "concealPgpApplication"; + public static final String WRITE_VERSION_HEADER = "writeVersionHeader"; public static final String FIRST_TIME = "firstTime"; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java index 00f6b6715..a0bac80aa 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java @@ -205,13 +205,13 @@ public class Preferences { } } - public void setConcealPgpApplication(boolean conceal) { + public void setWriteVersionHeader(boolean conceal) { SharedPreferences.Editor editor = mSharedPreferences.edit(); - editor.putBoolean(Constants.Pref.CONCEAL_PGP_APPLICATION, conceal); + editor.putBoolean(Constants.Pref.WRITE_VERSION_HEADER, conceal); editor.commit(); } - public boolean getConcealPgpApplication() { - return mSharedPreferences.getBoolean(Constants.Pref.CONCEAL_PGP_APPLICATION, false); + public boolean getWriteVersionHeader() { + return mSharedPreferences.getBoolean(Constants.Pref.WRITE_VERSION_HEADER, false); } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpHelper.java index 0ceefc4d9..1cf027721 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpHelper.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpHelper.java @@ -60,11 +60,11 @@ public class PgpHelper { } } - public static String getFullVersion(Context context) { - if(Preferences.getPreferences(context).getConcealPgpApplication()){ - return ""; - } else { + public static String getVersionForHeader(Context context) { + if(Preferences.getPreferences(context).getWriteVersionHeader()){ return "OpenKeychain v" + getVersion(context); + } else { + return null; } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java index 846b00ef2..f14eacda2 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java @@ -230,7 +230,10 @@ public class PgpImportExport { progress++; // Create an output stream ArmoredOutputStream arOutStream = new ArmoredOutputStream(outStream); - arOutStream.setHeader("Version", PgpHelper.getFullVersion(mContext)); + String version = PgpHelper.getVersionForHeader(mContext); + if (version != null) { + arOutStream.setHeader("Version", version); + } updateProgress(progress * 100 / masterKeyIdsSize, 100); @@ -258,7 +261,10 @@ public class PgpImportExport { progress++; // Create an output stream ArmoredOutputStream arOutStream = new ArmoredOutputStream(outStream); - arOutStream.setHeader("Version", PgpHelper.getFullVersion(mContext)); + String version = PgpHelper.getVersionForHeader(mContext); + if (version != null) { + arOutStream.setHeader("Version", version); + } updateProgress(progress * 100 / masterKeyIdsSize, 100); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java index 4973f64bb..b0e546662 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java @@ -109,11 +109,11 @@ public class PgpSignEncrypt { public static class Builder { // mandatory parameter private ProviderHelper mProviderHelper; - private String mVersionHeader; private InputData mData; private OutputStream mOutStream; // optional + private String mVersionHeader = null; private Progressable mProgressable = null; private boolean mEnableAsciiArmorOutput = false; private int mCompressionId = CompressionAlgorithmTags.UNCOMPRESSED; @@ -128,13 +128,17 @@ public class PgpSignEncrypt { private boolean mCleartextInput = false; private String mOriginalFilename = ""; - public Builder(ProviderHelper providerHelper, String versionHeader, InputData data, OutputStream outStream) { + public Builder(ProviderHelper providerHelper, InputData data, OutputStream outStream) { mProviderHelper = providerHelper; - mVersionHeader = versionHeader; mData = data; mOutStream = outStream; } + public Builder setVersionHeader(String versionHeader) { + mVersionHeader = versionHeader; + return this; + } + public Builder setProgressable(Progressable progressable) { mProgressable = progressable; return this; @@ -271,7 +275,9 @@ public class PgpSignEncrypt { OutputStream out; if (mEnableAsciiArmorOutput) { armorOut = new ArmoredOutputStream(mOutStream); - armorOut.setHeader("Version", mVersionHeader); + if (mVersionHeader != null) { + armorOut.setHeader("Version", mVersionHeader); + } out = armorOut; } else { out = mOutStream; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java index 18ddaa0ec..73a51942d 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java @@ -204,7 +204,9 @@ public class UncachedKeyRing { public void encodeArmored(OutputStream out, String version) throws IOException { ArmoredOutputStream aos = new ArmoredOutputStream(out); - aos.setHeader("Version", version); + if (version != null) { + aos.setHeader("Version", version); + } aos.write(mRing.getEncoded()); aos.close(); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java index 99b622f69..a13bb9c98 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java @@ -862,7 +862,10 @@ public class ProviderHelper { UncachedKeyRing keyRing = UncachedKeyRing.decodeFromData(data); ByteArrayOutputStream bos = new ByteArrayOutputStream(); - keyRing.encodeArmored(bos, PgpHelper.getFullVersion(mContext)); + String version = PgpHelper.getVersionForHeader(mContext); + if (version != null) { + keyRing.encodeArmored(bos, version); + } String armoredKey = bos.toString("UTF-8"); Log.d(Constants.TAG, "armoredKey:" + armoredKey); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java index 2f07f9785..3c2f7ebda 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java @@ -187,9 +187,9 @@ public class OpenPgpService extends RemoteService { // sign-only PgpSignEncrypt.Builder builder = new PgpSignEncrypt.Builder( new ProviderHelper(getContext()), - PgpHelper.getFullVersion(getContext()), inputData, os); builder.setEnableAsciiArmorOutput(asciiArmor) + .setVersionHeader(PgpHelper.getVersionForHeader(this)) .setSignatureHashAlgorithm(accSettings.getHashAlgorithm()) .setSignatureForceV3(false) .setSignatureMasterKeyId(accSettings.getKeyId()) @@ -276,9 +276,9 @@ public class OpenPgpService extends RemoteService { PgpSignEncrypt.Builder builder = new PgpSignEncrypt.Builder( new ProviderHelper(getContext()), - PgpHelper.getFullVersion(getContext()), inputData, os); builder.setEnableAsciiArmorOutput(asciiArmor) + .setVersionHeader(PgpHelper.getVersionForHeader(this)) .setCompressionId(accSettings.getCompression()) .setSymmetricEncryptionAlgorithm(accSettings.getEncryptionAlgorithm()) .setEncryptionMasterKeyIds(keyIds) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 443f66d58..d1d848066 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -249,11 +249,11 @@ public class KeychainIntentService extends IntentService PgpSignEncrypt.Builder builder = new PgpSignEncrypt.Builder( new ProviderHelper(this), - PgpHelper.getFullVersion(this), inputData, outStream); builder.setProgressable(this); builder.setEnableAsciiArmorOutput(useAsciiArmor) + .setVersionHeader(PgpHelper.getVersionForHeader(this)) .setCompressionId(compressionId) .setSymmetricEncryptionAlgorithm( Preferences.getPreferences(this).getDefaultEncryptionAlgorithm()) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java index e0261730d..5bef6cc9f 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java @@ -122,8 +122,8 @@ public class PreferencesActivity extends PreferenceActivity { initializeForceV3Signatures( (CheckBoxPreference) findPreference(Constants.Pref.FORCE_V3_SIGNATURES)); - initializeConcealPgpApplication( - (CheckBoxPreference) findPreference(Constants.Pref.CONCEAL_PGP_APPLICATION)); + initializeWriteVersionHeader( + (CheckBoxPreference) findPreference(Constants.Pref.WRITE_VERSION_HEADER)); } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { // Load the legacy preferences headers @@ -269,8 +269,8 @@ public class PreferencesActivity extends PreferenceActivity { initializeForceV3Signatures( (CheckBoxPreference) findPreference(Constants.Pref.FORCE_V3_SIGNATURES)); - initializeConcealPgpApplication( - (CheckBoxPreference) findPreference(Constants.Pref.CONCEAL_PGP_APPLICATION)); + initializeWriteVersionHeader( + (CheckBoxPreference) findPreference(Constants.Pref.WRITE_VERSION_HEADER)); } } @@ -404,12 +404,12 @@ public class PreferencesActivity extends PreferenceActivity { }); } - private static void initializeConcealPgpApplication(final CheckBoxPreference mConcealPgpApplication) { - mConcealPgpApplication.setChecked(sPreferences.getConcealPgpApplication()); - mConcealPgpApplication.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + private static void initializeWriteVersionHeader(final CheckBoxPreference mWriteVersionHeader) { + mWriteVersionHeader.setChecked(sPreferences.getWriteVersionHeader()); + mWriteVersionHeader.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { - mConcealPgpApplication.setChecked((Boolean) newValue); - sPreferences.setConcealPgpApplication((Boolean) newValue); + mWriteVersionHeader.setChecked((Boolean) newValue); + sPreferences.setWriteVersionHeader((Boolean) newValue); return false; } }); diff --git a/OpenKeychain/src/main/res/values-de/strings.xml b/OpenKeychain/src/main/res/values-de/strings.xml index c563267cc..a843a154a 100644 --- a/OpenKeychain/src/main/res/values-de/strings.xml +++ b/OpenKeychain/src/main/res/values-de/strings.xml @@ -81,8 +81,8 @@ <string name="label_passphrase_again">Passwort wiederholen</string> <string name="label_algorithm">Algorithmus</string> <string name="label_file_ascii_armor">Datei: ASCII Armor</string> - <string name="label_conceal_pgp_application">Lass andere wissen dass du OpenKeychain nutzt</string> - <string name="label_conceal_pgp_application_summary">Fügt \'OpenKeychain v2.7\' zu OpenPGP Signaturen, Daten und exportierten Schlüsseln hinzu</string> + <string name="label_write_version_header">Lass andere wissen dass du OpenKeychain nutzt</string> + <string name="label_write_version_header_summary">Fügt \'OpenKeychain v2.7\' zu OpenPGP Signaturen, Daten und exportierten Schlüsseln hinzu</string> <string name="label_asymmetric_from">Von:</string> <string name="label_to">An:</string> <string name="label_delete_after_encryption">Dateien: Nach Verschlüsselung löschen</string> diff --git a/OpenKeychain/src/main/res/values-es/strings.xml b/OpenKeychain/src/main/res/values-es/strings.xml index eddfb4593..80c2060d1 100644 --- a/OpenKeychain/src/main/res/values-es/strings.xml +++ b/OpenKeychain/src/main/res/values-es/strings.xml @@ -84,8 +84,8 @@ <string name="label_algorithm">Algoritmo</string> <string name="label_ascii_armor">Armadura ASCII del fichero</string> <string name="label_file_ascii_armor">Ficheros: Armadura ASCII</string> - <string name="label_conceal_pgp_application">Permitir a otros saber que está usando OpenKeychain</string> - <string name="label_conceal_pgp_application_summary">Escribe \'OpenKeychain v2.7\' en las firmas OpenPGP, el texto cifrado, y las claves exportadas</string> + <string name="label_write_version_header">Permitir a otros saber que está usando OpenKeychain</string> + <string name="label_write_version_header_summary">Escribe \'OpenKeychain v2.7\' en las firmas OpenPGP, el texto cifrado, y las claves exportadas</string> <string name="label_asymmetric_from">Desde:</string> <string name="label_to">Hacia:</string> <string name="label_delete_after_encryption">Ficheros: Borrar después del cifrado</string> diff --git a/OpenKeychain/src/main/res/values-fr/strings.xml b/OpenKeychain/src/main/res/values-fr/strings.xml index d2a13ef2d..e30ebb883 100644 --- a/OpenKeychain/src/main/res/values-fr/strings.xml +++ b/OpenKeychain/src/main/res/values-fr/strings.xml @@ -84,8 +84,8 @@ <string name="label_algorithm">Algorithme</string> <string name="label_ascii_armor">Fichier ASCII Armor</string> <string name="label_file_ascii_armor">Fichier : ASCII Armor</string> - <string name="label_conceal_pgp_application">Informez les autres de votre utilisation d\'OpenKeychain</string> - <string name="label_conceal_pgp_application_summary">Ajoute « OpenKeychain v2.7 » aux signatures OpenPGP, aux cryptogrammes, et aux clefs exportées</string> + <string name="label_write_version_header">Informez les autres de votre utilisation d\'OpenKeychain</string> + <string name="label_write_version_header_summary">Ajoute « OpenKeychain v2.7 » aux signatures OpenPGP, aux cryptogrammes, et aux clefs exportées</string> <string name="label_asymmetric_from">De :</string> <string name="label_to">À :</string> <string name="label_delete_after_encryption">Fichier : supprimer après chiffrement</string> diff --git a/OpenKeychain/src/main/res/values-it/strings.xml b/OpenKeychain/src/main/res/values-it/strings.xml index a3941e147..89e09783b 100644 --- a/OpenKeychain/src/main/res/values-it/strings.xml +++ b/OpenKeychain/src/main/res/values-it/strings.xml @@ -69,8 +69,8 @@ <string name="label_passphrase">Frase di Accesso</string> <string name="label_passphrase_again">Ripeti Frase di Accesso</string> <string name="label_algorithm">Algortimo</string> - <string name="label_conceal_pgp_application">Fai sapere agli altri che utilizzi OpenKeychain</string> - <string name="label_conceal_pgp_application_summary">Scrive \'OpenKeychain v2.7\' nelle firme OpenPGP, testi cifrati e chiavi esportate</string> + <string name="label_write_version_header">Fai sapere agli altri che utilizzi OpenKeychain</string> + <string name="label_write_version_header_summary">Scrive \'OpenKeychain v2.7\' nelle firme OpenPGP, testi cifrati e chiavi esportate</string> <string name="label_delete_after_decryption">Cancella Dopo Decodifica</string> <string name="label_encryption_algorithm">Algoritmo di Codifica</string> <string name="label_hash_algorithm">Algoritmo di Hash</string> diff --git a/OpenKeychain/src/main/res/values-ja/strings.xml b/OpenKeychain/src/main/res/values-ja/strings.xml index d4fc5f976..dbb52d208 100644 --- a/OpenKeychain/src/main/res/values-ja/strings.xml +++ b/OpenKeychain/src/main/res/values-ja/strings.xml @@ -84,8 +84,8 @@ <string name="label_algorithm">アルゴリズム</string> <string name="label_ascii_armor">アスキー形式ファイル</string> <string name="label_file_ascii_armor">ファイル: アスキー形式</string> - <string name="label_conceal_pgp_application">他の人にあなたがOpenKeychain使用していることを知ってもらいましょう</string> - <string name="label_conceal_pgp_application_summary">OpenPGPの 署名、暗号文、そしてエクスポートした鍵に \'OpenKeychain v2.7\' と書くようになりました</string> + <string name="label_write_version_header">他の人にあなたがOpenKeychain使用していることを知ってもらいましょう</string> + <string name="label_write_version_header_summary">OpenPGPの 署名、暗号文、そしてエクスポートした鍵に \'OpenKeychain v2.7\' と書くようになりました</string> <string name="label_asymmetric_from">差出人:</string> <string name="label_to">宛先</string> <string name="label_delete_after_encryption">ファイル: 暗号化後に削除</string> diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml index 352ca951c..8ccb92854 100644 --- a/OpenKeychain/src/main/res/values/strings.xml +++ b/OpenKeychain/src/main/res/values/strings.xml @@ -90,8 +90,8 @@ <string name="label_algorithm">Algorithm</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> + <string name="label_write_version_header">Let others know that you\'re using OpenKeychain</string> + <string name="label_write_version_header_summary">Writes \'OpenKeychain v2.7\' to OpenPGP signatures, ciphertext, and exported keys</string> <string name="label_asymmetric_from">From:</string> <string name="label_to">To:</string> <string name="label_delete_after_encryption">Files: Delete After Encryption</string> diff --git a/OpenKeychain/src/main/res/xml/adv_preferences.xml b/OpenKeychain/src/main/res/xml/adv_preferences.xml index a07ae06bb..588a6e62d 100644 --- a/OpenKeychain/src/main/res/xml/adv_preferences.xml +++ b/OpenKeychain/src/main/res/xml/adv_preferences.xml @@ -40,10 +40,10 @@ android:title="@string/label_ascii_armor" /> <CheckBoxPreference - android:key="concealPgpApplication" + android:key="writeVersionHeader" android:persistent="false" - android:title="@string/label_conceal_pgp_application" - android:summary="@string/label_conceal_pgp_application_summary" /> + android:title="@string/label_write_version_header" + android:summary="@string/label_write_version_header_summary" /> </PreferenceCategory> <PreferenceCategory android:title="@string/section_advanced" > <CheckBoxPreference |