mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Change progress dialog title, and remove code
This commit is contained in:
@@ -100,25 +100,6 @@ public abstract class PwDatabase<PwGroupDB extends PwGroup<PwGroupDB, PwGroupDB,
|
||||
return finalKey;
|
||||
}
|
||||
|
||||
public void makeFinalKey(byte[] masterSeed, byte[] masterSeed2, long numRounds) throws IOException {
|
||||
|
||||
// Write checksum Checksum
|
||||
MessageDigest md;
|
||||
try {
|
||||
md = MessageDigest.getInstance("SHA-256");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new IOException("SHA-256 not implemented here.");
|
||||
}
|
||||
NullOutputStream nos = new NullOutputStream();
|
||||
DigestOutputStream dos = new DigestOutputStream(nos, md);
|
||||
|
||||
byte[] transformedMasterKey = transformMasterKey(masterSeed2, masterKey, numRounds);
|
||||
dos.write(masterSeed);
|
||||
dos.write(transformedMasterKey);
|
||||
|
||||
finalKey = md.digest();
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypt the master key a few times to make brute-force key-search harder
|
||||
* @throws IOException
|
||||
|
||||
@@ -47,9 +47,13 @@ package com.kunzisoft.keepass.database;
|
||||
|
||||
import com.kunzisoft.keepass.crypto.keyDerivation.AesKdf;
|
||||
import com.kunzisoft.keepass.database.exception.InvalidKeyFileException;
|
||||
import com.kunzisoft.keepass.stream.NullOutputStream;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.security.DigestOutputStream;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
@@ -250,6 +254,25 @@ public class PwDatabaseV3 extends PwDatabase<PwGroupV3, PwEntryV3> {
|
||||
}
|
||||
}
|
||||
|
||||
public void makeFinalKey(byte[] masterSeed, byte[] masterSeed2, long numRounds) throws IOException {
|
||||
|
||||
// Write checksum Checksum
|
||||
MessageDigest md;
|
||||
try {
|
||||
md = MessageDigest.getInstance("SHA-256");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new IOException("SHA-256 not implemented here.");
|
||||
}
|
||||
NullOutputStream nos = new NullOutputStream();
|
||||
DigestOutputStream dos = new DigestOutputStream(nos, md);
|
||||
|
||||
byte[] transformedMasterKey = transformMasterKey(masterSeed2, masterKey, numRounds);
|
||||
dos.write(masterSeed);
|
||||
dos.write(transformedMasterKey);
|
||||
|
||||
finalKey = md.digest();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPasswordEncoding() {
|
||||
return "ISO-8859-1";
|
||||
|
||||
@@ -359,28 +359,6 @@ public class PwDatabaseV4 extends PwDatabase<PwGroupV4, PwEntryV4> {
|
||||
return md.digest(fKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void makeFinalKey(byte[] masterSeed, byte[] masterSeed2, long numRounds) throws IOException {
|
||||
|
||||
byte[] transformedMasterKey = transformMasterKey(masterSeed2, masterKey, numRounds);
|
||||
|
||||
|
||||
byte[] cmpKey = new byte[65];
|
||||
System.arraycopy(masterSeed, 0, cmpKey, 0, 32);
|
||||
System.arraycopy(transformedMasterKey, 0, cmpKey, 32, 32);
|
||||
finalKey = CryptoUtil.resizeKey(cmpKey, 0, 64, dataEngine.keyLength());
|
||||
|
||||
MessageDigest md;
|
||||
try {
|
||||
md = MessageDigest.getInstance("SHA-512");
|
||||
cmpKey[64] = 1;
|
||||
hmacKey = md.digest(cmpKey);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new IOException("No SHA-512 implementation");
|
||||
} finally {
|
||||
Arrays.fill(cmpKey, (byte)0);
|
||||
}
|
||||
}
|
||||
public void makeFinalKey(byte[] masterSeed, KdfParameters kdfP) throws IOException {
|
||||
makeFinalKey(masterSeed, kdfP, 0);
|
||||
}
|
||||
|
||||
@@ -47,13 +47,14 @@ public class ProgressTaskDialogFragment extends DialogFragment implements Progre
|
||||
private @StringRes int title = UNDEFINED;
|
||||
private @StringRes int message = UNDEFINED;
|
||||
|
||||
private TextView titleView;
|
||||
private TextView messageView;
|
||||
private ProgressBar progressView;
|
||||
|
||||
public static ProgressTaskDialogFragment start(FragmentManager fragmentManager, @StringRes int titleId) {
|
||||
// Create an instance of the dialog fragment and show it
|
||||
ProgressTaskDialogFragment dialog = new ProgressTaskDialogFragment();
|
||||
dialog.setTitle(titleId);
|
||||
dialog.updateTitle(titleId);
|
||||
dialog.show(fragmentManager, PROGRESS_TASK_DIALOG_TAG);
|
||||
return dialog;
|
||||
}
|
||||
@@ -71,12 +72,12 @@ public class ProgressTaskDialogFragment extends DialogFragment implements Progre
|
||||
@SuppressLint("InflateParams")
|
||||
View root = inflater.inflate(R.layout.progress_dialog, null);
|
||||
builder.setView(root);
|
||||
if (title != UNDEFINED)
|
||||
builder.setTitle(title);
|
||||
|
||||
titleView = root.findViewById(R.id.progress_dialog_title);
|
||||
messageView = root.findViewById(R.id.progress_dialog_message);
|
||||
progressView = root.findViewById(R.id.progress_dialog_bar);
|
||||
|
||||
updateTitle(title);
|
||||
updateMessage(message);
|
||||
|
||||
setCancelable(false);
|
||||
@@ -119,16 +120,25 @@ public class ProgressTaskDialogFragment extends DialogFragment implements Progre
|
||||
this.title = titleId;
|
||||
}
|
||||
|
||||
private void updateView(TextView textView, @StringRes int resId) {
|
||||
if (textView != null) {
|
||||
if (resId == UNDEFINED) {
|
||||
textView.setVisibility(View.GONE);
|
||||
} else {
|
||||
textView.setText(resId);
|
||||
textView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTitle(int resId) {
|
||||
this.title = resId;
|
||||
updateView(titleView, title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMessage(int resId) {
|
||||
this.message = resId;
|
||||
if (messageView != null) {
|
||||
if (message == UNDEFINED) {
|
||||
messageView.setVisibility(View.GONE);
|
||||
} else {
|
||||
messageView.setText(message);
|
||||
messageView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
updateView(messageView, message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ public class SaveDatabaseProgressTaskDialogFragment extends ProgressTaskDialogFr
|
||||
public static SaveDatabaseProgressTaskDialogFragment start(FragmentManager fragmentManager) {
|
||||
// Create an instance of the dialog fragment and show it
|
||||
SaveDatabaseProgressTaskDialogFragment dialog = new SaveDatabaseProgressTaskDialogFragment();
|
||||
dialog.setTitle(R.string.saving_database);
|
||||
dialog.updateTitle(R.string.saving_database);
|
||||
dialog.show(fragmentManager, PROGRESS_TASK_DIALOG_TAG);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@@ -3,11 +3,27 @@
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/progress_dialog_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginRight="20dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
style="@style/KeepassDXStyle.TextAppearance.Title"
|
||||
android:textColor="?android:attr/textColor"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/progress_dialog_message"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="20dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginRight="20dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
style="@style/KeepassDXStyle.TextAppearance.SmallTitle"/>
|
||||
|
||||
<ProgressBar
|
||||
@@ -15,6 +31,7 @@
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:indeterminate="true"
|
||||
android:max="100"/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user