From 09c776fd7e29e3e915e018abb26fbaebf0daa688 Mon Sep 17 00:00:00 2001 From: J-Jamet Date: Thu, 31 May 2018 11:53:45 +0200 Subject: [PATCH] Remove "Rounds fix" setting no more used --- .../kunzisoft/keepass/database/Database.java | 32 ++----- .../keepass/database/PwDatabaseV4.java | 11 --- .../keepass/database/load/Importer.java | 2 +- .../keepass/database/load/ImporterV3.java | 4 +- .../database/load/ImporterV3Debug.java | 5 +- .../keepass/database/load/ImporterV4.java | 6 +- .../settings/MainPreferenceFragment.java | 18 ---- ...undsFixPreferenceDialogFragmentCompat.java | 92 ------------------- .../ic_filter_tilt_shift_pref_24dp.xml | 9 -- app/src/main/res/values-de/strings.xml | 3 - app/src/main/res/values-fr/strings.xml | 3 - app/src/main/res/values-it/strings.xml | 2 - app/src/main/res/values-pl/strings.xml | 2 - app/src/main/res/values-ru/strings.xml | 2 - app/src/main/res/values/donottranslate.xml | 3 - app/src/main/res/values/strings.xml | 3 - app/src/main/res/xml/preferences.xml | 10 +- 17 files changed, 15 insertions(+), 192 deletions(-) delete mode 100644 app/src/main/java/com/kunzisoft/keepass/settings/preferenceDialogFragment/RoundsFixPreferenceDialogFragmentCompat.java delete mode 100644 app/src/main/res/drawable/ic_filter_tilt_shift_pref_24dp.xml diff --git a/app/src/main/java/com/kunzisoft/keepass/database/Database.java b/app/src/main/java/com/kunzisoft/keepass/database/Database.java index be56e0ac2..58960c431 100644 --- a/app/src/main/java/com/kunzisoft/keepass/database/Database.java +++ b/app/src/main/java/com/kunzisoft/keepass/database/Database.java @@ -20,18 +20,14 @@ package com.kunzisoft.keepass.database; import android.content.Context; -import android.content.SharedPreferences; import android.content.res.Resources; import android.net.Uri; -import android.preference.PreferenceManager; import android.util.Log; -import com.kunzisoft.keepass.R; import com.kunzisoft.keepass.crypto.keyDerivation.KdfEngine; import com.kunzisoft.keepass.crypto.keyDerivation.KdfFactory; import com.kunzisoft.keepass.database.exception.ContentFileNotFoundException; import com.kunzisoft.keepass.database.exception.InvalidDBException; -import com.kunzisoft.keepass.database.exception.InvalidPasswordException; import com.kunzisoft.keepass.database.exception.PwDbOutputException; import com.kunzisoft.keepass.database.load.Importer; import com.kunzisoft.keepass.database.load.ImporterFactory; @@ -118,26 +114,10 @@ public class Database { readOnly = !file.canWrite(); } - try { - passUrisAsInputStreams(ctx, uri, password, keyfile, status, debug, 0); - } catch (InvalidPasswordException e) { - // Retry with rounds fix - try { - passUrisAsInputStreams(ctx, uri, password, keyfile, status, debug, getFixRounds(ctx)); - } catch (Exception e2) { - // Rethrow original exception - throw e; - } - } + passUrisAsInputStreams(ctx, uri, password, keyfile, status, debug); } - private long getFixRounds(Context ctx) { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx); - return prefs.getLong(ctx.getString(R.string.roundsFix_key), ctx.getResources().getInteger(R.integer.roundsFix_default)); - } - - - private void passUrisAsInputStreams(Context ctx, Uri uri, String password, Uri keyfile, ProgressTaskUpdater status, boolean debug, long roundsFix) throws IOException, FileNotFoundException, InvalidDBException { + private void passUrisAsInputStreams(Context ctx, Uri uri, String password, Uri keyfile, ProgressTaskUpdater status, boolean debug) throws IOException, FileNotFoundException, InvalidDBException { InputStream is, kfIs; try { is = UriUtil.getUriInputStream(ctx, uri); @@ -152,14 +132,14 @@ public class Database { Log.e("KPD", "Database::loadData", e); throw ContentFileNotFoundException.getInstance(keyfile); } - loadData(ctx, is, password, kfIs, status, debug, roundsFix); + loadData(ctx, is, password, kfIs, status, debug); } public void loadData(Context ctx, InputStream is, String password, InputStream keyFileInputStream, boolean debug) throws IOException, InvalidDBException { - loadData(ctx, is, password, keyFileInputStream, null, debug, 0); + loadData(ctx, is, password, keyFileInputStream, null, debug); } - private void loadData(Context ctx, InputStream is, String password, InputStream keyFileInputStream, ProgressTaskUpdater progressTaskUpdater, boolean debug, long roundsFix) throws IOException, InvalidDBException { + private void loadData(Context ctx, InputStream is, String password, InputStream keyFileInputStream, ProgressTaskUpdater progressTaskUpdater, boolean debug) throws IOException, InvalidDBException { BufferedInputStream bis = new BufferedInputStream(is); if ( ! bis.markSupported() ) { @@ -173,7 +153,7 @@ public class Database { bis.reset(); // Return to the start - pm = databaseImporter.openDatabase(bis, password, keyFileInputStream, progressTaskUpdater, roundsFix); + pm = databaseImporter.openDatabase(bis, password, keyFileInputStream, progressTaskUpdater); if ( pm != null ) { try { switch (pm.getVersion()) { diff --git a/app/src/main/java/com/kunzisoft/keepass/database/PwDatabaseV4.java b/app/src/main/java/com/kunzisoft/keepass/database/PwDatabaseV4.java index d8794d66b..ce93e1869 100644 --- a/app/src/main/java/com/kunzisoft/keepass/database/PwDatabaseV4.java +++ b/app/src/main/java/com/kunzisoft/keepass/database/PwDatabaseV4.java @@ -26,7 +26,6 @@ import com.kunzisoft.keepass.collections.VariantDictionary; import com.kunzisoft.keepass.crypto.CryptoUtil; import com.kunzisoft.keepass.crypto.engine.AesEngine; import com.kunzisoft.keepass.crypto.engine.CipherEngine; -import com.kunzisoft.keepass.crypto.keyDerivation.AesKdf; import com.kunzisoft.keepass.crypto.keyDerivation.KdfEngine; import com.kunzisoft.keepass.crypto.keyDerivation.KdfFactory; import com.kunzisoft.keepass.crypto.keyDerivation.KdfParameters; @@ -403,19 +402,9 @@ public class PwDatabaseV4 extends PwDatabase { } public void makeFinalKey(byte[] masterSeed) throws IOException { - makeFinalKey(masterSeed, 0); - } - - public void makeFinalKey(byte[] masterSeed, long roundsFix) throws IOException { KdfEngine kdfEngine = KdfFactory.getEngineV4(kdfParameters); - // Set to 6000 rounds to open corrupted database - if (roundsFix > 0 && kdfParameters.getUUID().equals(AesKdf.CIPHER_UUID)) { - kdfParameters.setUInt32(AesKdf.ParamRounds, roundsFix); - numKeyEncRounds = roundsFix; - } - byte[] transformedMasterKey = kdfEngine.transform(masterKey, kdfParameters); if (transformedMasterKey.length != 32) { transformedMasterKey = CryptoUtil.hashSha256(transformedMasterKey); diff --git a/app/src/main/java/com/kunzisoft/keepass/database/load/Importer.java b/app/src/main/java/com/kunzisoft/keepass/database/load/Importer.java index 2c56f2122..36c82ab3e 100644 --- a/app/src/main/java/com/kunzisoft/keepass/database/load/Importer.java +++ b/app/src/main/java/com/kunzisoft/keepass/database/load/Importer.java @@ -33,7 +33,7 @@ public abstract class Importer { public abstract PwDatabase openDatabase(InputStream inStream, String password, InputStream keyInputStream) throws IOException, InvalidDBException; - public abstract PwDatabase openDatabase(InputStream inStream, String password, InputStream keyInputStream, ProgressTaskUpdater updater, long roundsFix) + public abstract PwDatabase openDatabase(InputStream inStream, String password, InputStream keyInputStream, ProgressTaskUpdater updater) throws IOException, InvalidDBException; } diff --git a/app/src/main/java/com/kunzisoft/keepass/database/load/ImporterV3.java b/app/src/main/java/com/kunzisoft/keepass/database/load/ImporterV3.java index ea4bcea9a..2d0a33744 100644 --- a/app/src/main/java/com/kunzisoft/keepass/database/load/ImporterV3.java +++ b/app/src/main/java/com/kunzisoft/keepass/database/load/ImporterV3.java @@ -126,11 +126,11 @@ public class ImporterV3 extends Importer { @Override public PwDatabaseV3 openDatabase( InputStream inStream, String password, InputStream kfIs) throws IOException, InvalidDBException { - return openDatabase(inStream, password, kfIs, null, 0); + return openDatabase(inStream, password, kfIs, null); } @Override - public PwDatabaseV3 openDatabase(InputStream inStream, String password, InputStream kfIs, ProgressTaskUpdater progressTaskUpdater, long roundsFix) + public PwDatabaseV3 openDatabase(InputStream inStream, String password, InputStream kfIs, ProgressTaskUpdater progressTaskUpdater) throws IOException, InvalidDBException { PwDatabaseV3 databaseToOpen; diff --git a/app/src/main/java/com/kunzisoft/keepass/database/load/ImporterV3Debug.java b/app/src/main/java/com/kunzisoft/keepass/database/load/ImporterV3Debug.java index 2ad980ed3..9984892db 100644 --- a/app/src/main/java/com/kunzisoft/keepass/database/load/ImporterV3Debug.java +++ b/app/src/main/java/com/kunzisoft/keepass/database/load/ImporterV3Debug.java @@ -35,10 +35,9 @@ public class ImporterV3Debug extends ImporterV3 { @Override public PwDatabaseV3Debug openDatabase(InputStream inStream, String password, - InputStream keyInputStream, ProgressTaskUpdater status, long roundsFix) throws IOException, + InputStream keyInputStream, ProgressTaskUpdater status) throws IOException, InvalidDBException { - return (PwDatabaseV3Debug) super.openDatabase(inStream, password, keyInputStream, status, - roundsFix); + return (PwDatabaseV3Debug) super.openDatabase(inStream, password, keyInputStream, status); } } diff --git a/app/src/main/java/com/kunzisoft/keepass/database/load/ImporterV4.java b/app/src/main/java/com/kunzisoft/keepass/database/load/ImporterV4.java index 30458f4bd..3983740f3 100644 --- a/app/src/main/java/com/kunzisoft/keepass/database/load/ImporterV4.java +++ b/app/src/main/java/com/kunzisoft/keepass/database/load/ImporterV4.java @@ -92,12 +92,12 @@ public class ImporterV4 extends Importer { public PwDatabaseV4 openDatabase(InputStream inStream, String password, InputStream keyInputStream) throws IOException, InvalidDBException { - return openDatabase(inStream, password, keyInputStream, null, 0); + return openDatabase(inStream, password, keyInputStream, null); } @Override public PwDatabaseV4 openDatabase(InputStream inStream, String password, - InputStream keyInputStream, ProgressTaskUpdater progressTaskUpdater, long roundsFix) throws IOException, + InputStream keyInputStream, ProgressTaskUpdater progressTaskUpdater) throws IOException, InvalidDBException { if (progressTaskUpdater != null) @@ -114,7 +114,7 @@ public class ImporterV4 extends Importer { pbHeader = hh.header; db.retrieveMasterKey(password, keyInputStream); - db.makeFinalKey(header.masterSeed, roundsFix); + db.makeFinalKey(header.masterSeed); if (progressTaskUpdater != null) progressTaskUpdater.updateMessage(R.string.decrypting_db); diff --git a/app/src/main/java/com/kunzisoft/keepass/settings/MainPreferenceFragment.java b/app/src/main/java/com/kunzisoft/keepass/settings/MainPreferenceFragment.java index 6f09e43a9..68110e9f1 100644 --- a/app/src/main/java/com/kunzisoft/keepass/settings/MainPreferenceFragment.java +++ b/app/src/main/java/com/kunzisoft/keepass/settings/MainPreferenceFragment.java @@ -21,15 +21,12 @@ package com.kunzisoft.keepass.settings; import android.content.Context; import android.os.Bundle; -import android.support.v4.app.DialogFragment; import android.support.v7.preference.Preference; import android.support.v7.preference.PreferenceFragmentCompat; import com.kunzisoft.keepass.R; import com.kunzisoft.keepass.app.App; import com.kunzisoft.keepass.database.Database; -import com.kunzisoft.keepass.settings.preferenceDialogFragment.RoundsFixPreferenceDialogFragmentCompat; -import com.kunzisoft.keepass.settings.preference.InputNumberPreference; public class MainPreferenceFragment extends PreferenceFragmentCompat implements Preference.OnPreferenceClickListener { @@ -68,21 +65,6 @@ public class MainPreferenceFragment extends PreferenceFragmentCompat implements } } - @Override - public void onDisplayPreferenceDialog(Preference preference) { - // Try if the preference is one of our custom Preferences - if (preference instanceof InputNumberPreference) { - assert getFragmentManager() != null; - DialogFragment dialogFragment = RoundsFixPreferenceDialogFragmentCompat.newInstance(preference.getKey()); - dialogFragment.setTargetFragment(this, 0); - dialogFragment.show(getFragmentManager(), null); - } - // Could not be handled here. Try with the super method. - else { - super.onDisplayPreferenceDialog(preference); - } - } - @Override public boolean onPreferenceClick(Preference preference) { // here you should use the same keys as you used in the xml-file diff --git a/app/src/main/java/com/kunzisoft/keepass/settings/preferenceDialogFragment/RoundsFixPreferenceDialogFragmentCompat.java b/app/src/main/java/com/kunzisoft/keepass/settings/preferenceDialogFragment/RoundsFixPreferenceDialogFragmentCompat.java deleted file mode 100644 index 5e196a173..000000000 --- a/app/src/main/java/com/kunzisoft/keepass/settings/preferenceDialogFragment/RoundsFixPreferenceDialogFragmentCompat.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2018 Jeremy Jamet / Kunzisoft. - * - * This file is part of KeePass DX. - * - * KeePass DX is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * KeePass DX is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with KeePass DX. If not, see . - * - */ -package com.kunzisoft.keepass.settings.preferenceDialogFragment; - -import android.os.Bundle; -import android.support.v7.preference.DialogPreference; -import android.view.View; -import android.widget.EditText; -import android.widget.Toast; - -import com.kunzisoft.keepass.R; -import com.kunzisoft.keepass.settings.preference.InputNumberPreference; - -public class RoundsFixPreferenceDialogFragmentCompat extends InputPreferenceDialogFragmentCompat { - - private EditText inputTextView; - - public static RoundsFixPreferenceDialogFragmentCompat newInstance( - String key) { - final RoundsFixPreferenceDialogFragmentCompat - fragment = new RoundsFixPreferenceDialogFragmentCompat(); - final Bundle b = new Bundle(1); - b.putString(ARG_KEY, key); - fragment.setArguments(b); - - return fragment; - } - - @Override - protected void onBindDialogView(View view) { - super.onBindDialogView(view); - - inputTextView = view.findViewById(R.id.input_text); - - DialogPreference preference = getPreference(); - if (preference instanceof InputNumberPreference) { - setExplanationText(((InputNumberPreference) preference).getExplanation()); - long numRounds = ((InputNumberPreference) preference).getNumber(); - setInputText(String.valueOf(numRounds)); - } - } - - @Override - public void onDialogClosed(boolean positiveResult) { - if ( positiveResult ) { - long rounds; - try { - String strRounds = getInputText(); - rounds = Long.valueOf(strRounds); - } catch (NumberFormatException e) { - Toast.makeText(getContext(), R.string.error_rounds_not_number, Toast.LENGTH_LONG).show(); - return; - } - - DialogPreference preference = getPreference(); - if (preference instanceof InputNumberPreference) { - InputNumberPreference roundsPreference = (InputNumberPreference) preference; - // This allows the client to ignore the user value. - if (roundsPreference.callChangeListener(rounds)) { - // Save the value - roundsPreference.setNumber(rounds); - } - } - } - } - - public String getInputText() { - return this.inputTextView.getText().toString(); - } - - public void setInputText(String inputText) { - this.inputTextView.setText(inputText); - this.inputTextView.setSelection(this.inputTextView.getText().length()); - } -} diff --git a/app/src/main/res/drawable/ic_filter_tilt_shift_pref_24dp.xml b/app/src/main/res/drawable/ic_filter_tilt_shift_pref_24dp.xml deleted file mode 100644 index 7910fb778..000000000 --- a/app/src/main/res/drawable/ic_filter_tilt_shift_pref_24dp.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 4f749b6cc..e037cfd79 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -149,9 +149,6 @@ Schlüsseltransformationen Je höher die Anzahl der Schlüsseltransformationen, desto besser ist der Schutz gegen Wörterbuch- oder Brute-Force-Angriffe. Allerdings dauert dann auch das Laden und Speichern der Datenbank entsprechend länger. Schlüsseltransformationen - Datenbank reparieren - Schlüsseltransformationen vor Datenbankkorruption - Falls ihre Datenbank beschädigt wurde, können Sie die Anzahl der Schlüsseltransformationen welche verwendet wurden eingeben um ihre Datenbank wieder zu öffnen. Speichere Datenbank\u2026 Leerzeichen Suchen diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index a96302767..7c863de66 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -157,9 +157,6 @@ Tours de transformation Un niveau de chiffrement supérieur assure une protection supplémentaire contre les attaques de force brute, mais peut considérablement ralentir l\'ouverture et l\'enregistrement. niveaux - Résolution de la base de données - Clé de niveau de chiffrement avant corruption - Si votre base de données a été corrompue, entrez le nombre de tours utilisés précédemment pour essayer d\'ouvrir votre base de données. Utilisation de la Mémoire Quantité de mémoire (en octets binaires) à utiliser par la fonction de dérivation de clé. Parallélisme diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index be2d1ee0b..4d5babafe 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -143,8 +143,6 @@ Root Livello cifratura Un livello di cifratura elevato fornisce una protezione maggiore contro attacchi di tipo "forza brutta", ma può veramente rallentare il caricamento e il salvataggio. - Livello di cifratura prima della malformazione - Se il database si è rovinato, inserisci il numero di livello usato precedentemente e il database potrà essere aperto. livello Salvataggio database… Spazio diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 249497071..3697dc7bb 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -124,8 +124,6 @@ along with KeePass DX. If not, see . Root Złożoność szyfrowania Większa złożoność szyfrowania zapewnia dodatkowe zabezpieczenie przed atakiem brute force, ale może spowolnić wczytywanie i zapisywanie bazy danych. - Kluczowe rundy szyfrowania przed zniszczeniem - Jeśli twoja baza danych została uszkodzona przez KeePassDroid w wersji 2.2.0.0 do 2.2.0.6, wprowadź liczbę rund użytych poprzednio, a to pozwoli ci otworzyć twoją bazę danych. złożoność Zapisywanie bazy danych… Spacja diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 937ec550f..2ef0ca43d 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -143,8 +143,6 @@ База Проходы шифрования Больше проходов – выше стойкость базы к подбору пароля, но медленнее открытие и сохранение - Проходы до поломки базы - Если база была повреждена в KeePassDroid 2.2.0.0–2.2.0.6, введите ранее используемое количество проходов шифрования, чтобы открыть её проходы Сохранение базы… П р о б е л diff --git a/app/src/main/res/values/donottranslate.xml b/app/src/main/res/values/donottranslate.xml index 32f0c8ca1..31a0ef50a 100644 --- a/app/src/main/res/values/donottranslate.xml +++ b/app/src/main/res/values/donottranslate.xml @@ -45,7 +45,6 @@ clip_timeout_key db transform_rounds_key - roundsFix memory_usage_key parallelism_key keyfile @@ -95,8 +94,6 @@ settings_appearance_key magic_keyboard_key - - 100000 true true true diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fa1e8e7be..c7d2e8e5c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -160,9 +160,6 @@ In order to generate the key for the encryption algorithm, the compressed master key (SHA-256) is transformed using a key derivation function (with a random salt). Transform Rounds Higher encryption rounds provide additional protection against brute force attacks, but can really slow down loading and saving. - Fix of database - Key encryption rounds before corruption - If your database was corrupted, enter the number of rounds used previously to try to open your database. rounds Memory Usage Amount of memory (in binary bytes) to be used by the key derivation function. diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 2ff0a745f..7d076611a 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -17,8 +17,7 @@ You should have received a copy of the GNU General Public License along with KeePass DX. If not, see . --> - + @@ -46,13 +45,6 @@ android:title="@string/menu_db_settings" android:icon="@drawable/ic_data_usage_prefs_24dp" android:persistent="false" /> -