Dont write version header by default

This commit is contained in:
Dominik Schürmann 2014-08-14 11:44:47 +02:00
parent f941431d63
commit d0987edab9
18 changed files with 62 additions and 45 deletions

View File

@ -67,7 +67,7 @@ public final class Constants {
public static final String FORCE_V3_SIGNATURES = "forceV3Signatures"; public static final String FORCE_V3_SIGNATURES = "forceV3Signatures";
public static final String KEY_SERVERS = "keyServers"; public static final String KEY_SERVERS = "keyServers";
public static final String KEY_SERVERS_DEFAULT_VERSION = "keyServersDefaultVersion"; 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"; public static final String FIRST_TIME = "firstTime";
} }

View File

@ -205,13 +205,13 @@ public class Preferences {
} }
} }
public void setConcealPgpApplication(boolean conceal) { public void setWriteVersionHeader(boolean conceal) {
SharedPreferences.Editor editor = mSharedPreferences.edit(); SharedPreferences.Editor editor = mSharedPreferences.edit();
editor.putBoolean(Constants.Pref.CONCEAL_PGP_APPLICATION, conceal); editor.putBoolean(Constants.Pref.WRITE_VERSION_HEADER, conceal);
editor.commit(); editor.commit();
} }
public boolean getConcealPgpApplication() { public boolean getWriteVersionHeader() {
return mSharedPreferences.getBoolean(Constants.Pref.CONCEAL_PGP_APPLICATION, false); return mSharedPreferences.getBoolean(Constants.Pref.WRITE_VERSION_HEADER, false);
} }
} }

View File

@ -60,11 +60,11 @@ public class PgpHelper {
} }
} }
public static String getFullVersion(Context context) { public static String getVersionForHeader(Context context) {
if(Preferences.getPreferences(context).getConcealPgpApplication()){ if(Preferences.getPreferences(context).getWriteVersionHeader()){
return "";
} else {
return "OpenKeychain v" + getVersion(context); return "OpenKeychain v" + getVersion(context);
} else {
return null;
} }
} }

View File

@ -230,7 +230,10 @@ public class PgpImportExport {
progress++; progress++;
// Create an output stream // Create an output stream
ArmoredOutputStream arOutStream = new ArmoredOutputStream(outStream); 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); updateProgress(progress * 100 / masterKeyIdsSize, 100);
@ -258,7 +261,10 @@ public class PgpImportExport {
progress++; progress++;
// Create an output stream // Create an output stream
ArmoredOutputStream arOutStream = new ArmoredOutputStream(outStream); 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); updateProgress(progress * 100 / masterKeyIdsSize, 100);

View File

@ -109,11 +109,11 @@ public class PgpSignEncrypt {
public static class Builder { public static class Builder {
// mandatory parameter // mandatory parameter
private ProviderHelper mProviderHelper; private ProviderHelper mProviderHelper;
private String mVersionHeader;
private InputData mData; private InputData mData;
private OutputStream mOutStream; private OutputStream mOutStream;
// optional // optional
private String mVersionHeader = null;
private Progressable mProgressable = null; private Progressable mProgressable = null;
private boolean mEnableAsciiArmorOutput = false; private boolean mEnableAsciiArmorOutput = false;
private int mCompressionId = CompressionAlgorithmTags.UNCOMPRESSED; private int mCompressionId = CompressionAlgorithmTags.UNCOMPRESSED;
@ -128,13 +128,17 @@ public class PgpSignEncrypt {
private boolean mCleartextInput = false; private boolean mCleartextInput = false;
private String mOriginalFilename = ""; private String mOriginalFilename = "";
public Builder(ProviderHelper providerHelper, String versionHeader, InputData data, OutputStream outStream) { public Builder(ProviderHelper providerHelper, InputData data, OutputStream outStream) {
mProviderHelper = providerHelper; mProviderHelper = providerHelper;
mVersionHeader = versionHeader;
mData = data; mData = data;
mOutStream = outStream; mOutStream = outStream;
} }
public Builder setVersionHeader(String versionHeader) {
mVersionHeader = versionHeader;
return this;
}
public Builder setProgressable(Progressable progressable) { public Builder setProgressable(Progressable progressable) {
mProgressable = progressable; mProgressable = progressable;
return this; return this;
@ -271,7 +275,9 @@ public class PgpSignEncrypt {
OutputStream out; OutputStream out;
if (mEnableAsciiArmorOutput) { if (mEnableAsciiArmorOutput) {
armorOut = new ArmoredOutputStream(mOutStream); armorOut = new ArmoredOutputStream(mOutStream);
if (mVersionHeader != null) {
armorOut.setHeader("Version", mVersionHeader); armorOut.setHeader("Version", mVersionHeader);
}
out = armorOut; out = armorOut;
} else { } else {
out = mOutStream; out = mOutStream;

View File

@ -204,7 +204,9 @@ public class UncachedKeyRing {
public void encodeArmored(OutputStream out, String version) throws IOException { public void encodeArmored(OutputStream out, String version) throws IOException {
ArmoredOutputStream aos = new ArmoredOutputStream(out); ArmoredOutputStream aos = new ArmoredOutputStream(out);
if (version != null) {
aos.setHeader("Version", version); aos.setHeader("Version", version);
}
aos.write(mRing.getEncoded()); aos.write(mRing.getEncoded());
aos.close(); aos.close();
} }

View File

@ -862,7 +862,10 @@ public class ProviderHelper {
UncachedKeyRing keyRing = UncachedKeyRing.decodeFromData(data); UncachedKeyRing keyRing = UncachedKeyRing.decodeFromData(data);
ByteArrayOutputStream bos = new ByteArrayOutputStream(); 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"); String armoredKey = bos.toString("UTF-8");
Log.d(Constants.TAG, "armoredKey:" + armoredKey); Log.d(Constants.TAG, "armoredKey:" + armoredKey);

View File

@ -187,9 +187,9 @@ public class OpenPgpService extends RemoteService {
// sign-only // sign-only
PgpSignEncrypt.Builder builder = new PgpSignEncrypt.Builder( PgpSignEncrypt.Builder builder = new PgpSignEncrypt.Builder(
new ProviderHelper(getContext()), new ProviderHelper(getContext()),
PgpHelper.getFullVersion(getContext()),
inputData, os); inputData, os);
builder.setEnableAsciiArmorOutput(asciiArmor) builder.setEnableAsciiArmorOutput(asciiArmor)
.setVersionHeader(PgpHelper.getVersionForHeader(this))
.setSignatureHashAlgorithm(accSettings.getHashAlgorithm()) .setSignatureHashAlgorithm(accSettings.getHashAlgorithm())
.setSignatureForceV3(false) .setSignatureForceV3(false)
.setSignatureMasterKeyId(accSettings.getKeyId()) .setSignatureMasterKeyId(accSettings.getKeyId())
@ -276,9 +276,9 @@ public class OpenPgpService extends RemoteService {
PgpSignEncrypt.Builder builder = new PgpSignEncrypt.Builder( PgpSignEncrypt.Builder builder = new PgpSignEncrypt.Builder(
new ProviderHelper(getContext()), new ProviderHelper(getContext()),
PgpHelper.getFullVersion(getContext()),
inputData, os); inputData, os);
builder.setEnableAsciiArmorOutput(asciiArmor) builder.setEnableAsciiArmorOutput(asciiArmor)
.setVersionHeader(PgpHelper.getVersionForHeader(this))
.setCompressionId(accSettings.getCompression()) .setCompressionId(accSettings.getCompression())
.setSymmetricEncryptionAlgorithm(accSettings.getEncryptionAlgorithm()) .setSymmetricEncryptionAlgorithm(accSettings.getEncryptionAlgorithm())
.setEncryptionMasterKeyIds(keyIds) .setEncryptionMasterKeyIds(keyIds)

View File

@ -249,11 +249,11 @@ public class KeychainIntentService extends IntentService
PgpSignEncrypt.Builder builder = PgpSignEncrypt.Builder builder =
new PgpSignEncrypt.Builder( new PgpSignEncrypt.Builder(
new ProviderHelper(this), new ProviderHelper(this),
PgpHelper.getFullVersion(this),
inputData, outStream); inputData, outStream);
builder.setProgressable(this); builder.setProgressable(this);
builder.setEnableAsciiArmorOutput(useAsciiArmor) builder.setEnableAsciiArmorOutput(useAsciiArmor)
.setVersionHeader(PgpHelper.getVersionForHeader(this))
.setCompressionId(compressionId) .setCompressionId(compressionId)
.setSymmetricEncryptionAlgorithm( .setSymmetricEncryptionAlgorithm(
Preferences.getPreferences(this).getDefaultEncryptionAlgorithm()) Preferences.getPreferences(this).getDefaultEncryptionAlgorithm())

View File

@ -122,8 +122,8 @@ public class PreferencesActivity extends PreferenceActivity {
initializeForceV3Signatures( initializeForceV3Signatures(
(CheckBoxPreference) findPreference(Constants.Pref.FORCE_V3_SIGNATURES)); (CheckBoxPreference) findPreference(Constants.Pref.FORCE_V3_SIGNATURES));
initializeConcealPgpApplication( initializeWriteVersionHeader(
(CheckBoxPreference) findPreference(Constants.Pref.CONCEAL_PGP_APPLICATION)); (CheckBoxPreference) findPreference(Constants.Pref.WRITE_VERSION_HEADER));
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
// Load the legacy preferences headers // Load the legacy preferences headers
@ -269,8 +269,8 @@ public class PreferencesActivity extends PreferenceActivity {
initializeForceV3Signatures( initializeForceV3Signatures(
(CheckBoxPreference) findPreference(Constants.Pref.FORCE_V3_SIGNATURES)); (CheckBoxPreference) findPreference(Constants.Pref.FORCE_V3_SIGNATURES));
initializeConcealPgpApplication( initializeWriteVersionHeader(
(CheckBoxPreference) findPreference(Constants.Pref.CONCEAL_PGP_APPLICATION)); (CheckBoxPreference) findPreference(Constants.Pref.WRITE_VERSION_HEADER));
} }
} }
@ -404,12 +404,12 @@ public class PreferencesActivity extends PreferenceActivity {
}); });
} }
private static void initializeConcealPgpApplication(final CheckBoxPreference mConcealPgpApplication) { private static void initializeWriteVersionHeader(final CheckBoxPreference mWriteVersionHeader) {
mConcealPgpApplication.setChecked(sPreferences.getConcealPgpApplication()); mWriteVersionHeader.setChecked(sPreferences.getWriteVersionHeader());
mConcealPgpApplication.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { mWriteVersionHeader.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
mConcealPgpApplication.setChecked((Boolean) newValue); mWriteVersionHeader.setChecked((Boolean) newValue);
sPreferences.setConcealPgpApplication((Boolean) newValue); sPreferences.setWriteVersionHeader((Boolean) newValue);
return false; return false;
} }
}); });

View File

@ -81,8 +81,8 @@
<string name="label_passphrase_again">Passwort wiederholen</string> <string name="label_passphrase_again">Passwort wiederholen</string>
<string name="label_algorithm">Algorithmus</string> <string name="label_algorithm">Algorithmus</string>
<string name="label_file_ascii_armor">Datei: ASCII Armor</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_write_version_header">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_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_asymmetric_from">Von:</string>
<string name="label_to">An:</string> <string name="label_to">An:</string>
<string name="label_delete_after_encryption">Dateien: Nach Verschlüsselung löschen</string> <string name="label_delete_after_encryption">Dateien: Nach Verschlüsselung löschen</string>

View File

@ -84,8 +84,8 @@
<string name="label_algorithm">Algoritmo</string> <string name="label_algorithm">Algoritmo</string>
<string name="label_ascii_armor">Armadura ASCII del fichero</string> <string name="label_ascii_armor">Armadura ASCII del fichero</string>
<string name="label_file_ascii_armor">Ficheros: Armadura ASCII</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_write_version_header">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_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_asymmetric_from">Desde:</string>
<string name="label_to">Hacia:</string> <string name="label_to">Hacia:</string>
<string name="label_delete_after_encryption">Ficheros: Borrar después del cifrado</string> <string name="label_delete_after_encryption">Ficheros: Borrar después del cifrado</string>

View File

@ -84,8 +84,8 @@
<string name="label_algorithm">Algorithme</string> <string name="label_algorithm">Algorithme</string>
<string name="label_ascii_armor">Fichier ASCII Armor</string> <string name="label_ascii_armor">Fichier ASCII Armor</string>
<string name="label_file_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_write_version_header">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_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_asymmetric_from">De :</string>
<string name="label_to">À :</string> <string name="label_to">À :</string>
<string name="label_delete_after_encryption">Fichier : supprimer après chiffrement</string> <string name="label_delete_after_encryption">Fichier : supprimer après chiffrement</string>

View File

@ -69,8 +69,8 @@
<string name="label_passphrase">Frase di Accesso</string> <string name="label_passphrase">Frase di Accesso</string>
<string name="label_passphrase_again">Ripeti Frase di Accesso</string> <string name="label_passphrase_again">Ripeti Frase di Accesso</string>
<string name="label_algorithm">Algortimo</string> <string name="label_algorithm">Algortimo</string>
<string name="label_conceal_pgp_application">Fai sapere agli altri che utilizzi OpenKeychain</string> <string name="label_write_version_header">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_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_delete_after_decryption">Cancella Dopo Decodifica</string>
<string name="label_encryption_algorithm">Algoritmo di Codifica</string> <string name="label_encryption_algorithm">Algoritmo di Codifica</string>
<string name="label_hash_algorithm">Algoritmo di Hash</string> <string name="label_hash_algorithm">Algoritmo di Hash</string>

View File

@ -84,8 +84,8 @@
<string name="label_algorithm">アルゴリズム</string> <string name="label_algorithm">アルゴリズム</string>
<string name="label_ascii_armor">アスキー形式ファイル</string> <string name="label_ascii_armor">アスキー形式ファイル</string>
<string name="label_file_ascii_armor">ファイル: アスキー形式</string> <string name="label_file_ascii_armor">ファイル: アスキー形式</string>
<string name="label_conceal_pgp_application">他の人にあなたがOpenKeychain使用していることを知ってもらいましょう</string> <string name="label_write_version_header">他の人にあなたがOpenKeychain使用していることを知ってもらいましょう</string>
<string name="label_conceal_pgp_application_summary">OpenPGPの 署名、暗号文、そしてエクスポートした鍵に \'OpenKeychain v2.7\' と書くようになりました</string> <string name="label_write_version_header_summary">OpenPGPの 署名、暗号文、そしてエクスポートした鍵に \'OpenKeychain v2.7\' と書くようになりました</string>
<string name="label_asymmetric_from">差出人:</string> <string name="label_asymmetric_from">差出人:</string>
<string name="label_to">宛先</string> <string name="label_to">宛先</string>
<string name="label_delete_after_encryption">ファイル: 暗号化後に削除</string> <string name="label_delete_after_encryption">ファイル: 暗号化後に削除</string>

View File

@ -90,8 +90,8 @@
<string name="label_algorithm">Algorithm</string> <string name="label_algorithm">Algorithm</string>
<string name="label_ascii_armor">File 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_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_write_version_header">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_summary">Writes \'OpenKeychain v2.7\' to OpenPGP signatures, ciphertext, and exported keys</string>
<string name="label_asymmetric_from">From:</string> <string name="label_asymmetric_from">From:</string>
<string name="label_to">To:</string> <string name="label_to">To:</string>
<string name="label_delete_after_encryption">Files: Delete After Encryption</string> <string name="label_delete_after_encryption">Files: Delete After Encryption</string>

View File

@ -40,10 +40,10 @@
android:title="@string/label_ascii_armor" /> android:title="@string/label_ascii_armor" />
<CheckBoxPreference <CheckBoxPreference
android:key="concealPgpApplication" android:key="writeVersionHeader"
android:persistent="false" android:persistent="false"
android:title="@string/label_conceal_pgp_application" android:title="@string/label_write_version_header"
android:summary="@string/label_conceal_pgp_application_summary" /> android:summary="@string/label_write_version_header_summary" />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/section_advanced" > <PreferenceCategory android:title="@string/section_advanced" >
<CheckBoxPreference <CheckBoxPreference

2
extern/spongycastle vendored

@ -1 +1 @@
Subproject commit 9e4fb80c4f8efb8a0f8fd0c1cc1e74a421d1eb7e Subproject commit 918340cbc6d5396764bfe94fdba07aca11cd8168