Skip to content

Commit

Permalink
Merge pull request #6532 from moneymanagerex/multi_cipher
Browse files Browse the repository at this point in the history
switch default cipher to SQLCipher4(AES256) from AES128
  • Loading branch information
vomikan committed May 4, 2024
2 parents 73b58b2 + e3a1e15 commit 6ba60be
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
7 changes: 5 additions & 2 deletions src/dbwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,16 @@ wxSharedPtr<wxSQLite3Database> mmDBWrapper::Open(const wxString &dbpath, const w

int err = SQLITE_OK;
wxString errStr=wxEmptyString;
wxSQLite3CipherSQLCipher cipher;
cipher.InitializeVersionDefault(4);
cipher.SetLegacy(true);
try
{
if (debug)
// open and disable flag SQLITE_CorruptRdOnly = 0x200000000
db->Open(dbpath, password, (WXSQLITE_OPEN_READWRITE | WXSQLITE_OPEN_CREATE) & ~0x200000000);
db->Open(dbpath, cipher, password, (WXSQLITE_OPEN_READWRITE | WXSQLITE_OPEN_CREATE) & ~0x200000000);
else
db->Open(dbpath, password);
db->Open(dbpath, cipher, password);
// Ensure that an existing mmex database is not encrypted.
if ((db->IsOpen()) && (db->TableExists("INFOTABLE_V1")))
{
Expand Down
23 changes: 18 additions & 5 deletions src/mmframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2368,8 +2368,12 @@ void mmGUIFrame::OnConvertEncryptedDB(wxCommandEvent& /*event*/)
wxCopyFile(encFileName, fileName);

wxSQLite3Database db;
db.Open(fileName, password);
db.ReKey(wxEmptyString);
wxSQLite3CipherSQLCipher cipher;
cipher.InitializeVersionDefault(4);
cipher.SetLegacy(true);

db.Open(fileName, cipher, password);
db.ReKey(cipher, wxEmptyString);
db.Close();

mmErrorDialogs::MessageError(this, _("Converted database!"), _("MMEX message"));
Expand Down Expand Up @@ -2397,7 +2401,11 @@ void mmGUIFrame::OnChangeEncryptPassword(wxCommandEvent& /*event*/)
wxString confirm_password = confirm_dlg.GetValue();
if (!confirm_password.IsEmpty() && (new_password == confirm_password))
{
m_db->ReKey(confirm_password);
wxSQLite3CipherSQLCipher cipher;
cipher.InitializeVersionDefault(4);
cipher.SetLegacy(true);

m_db->ReKey(cipher, confirm_password);
wxMessageBox(_("Password change completed"), password_change_heading);
}
else
Expand Down Expand Up @@ -2551,8 +2559,13 @@ void mmGUIFrame::OnSaveAs(wxCommandEvent& /*event*/)
if (rekey) // encrypt or reset encryption
{
wxSQLite3Database dbx;
dbx.Open(newFileName.GetFullPath(), m_password);
dbx.ReKey(new_password); // empty password resets encryption

wxSQLite3CipherSQLCipher cipher;
cipher.InitializeVersionDefault(4);
cipher.SetLegacy(true);

dbx.Open(newFileName.GetFullPath(), cipher, m_password);
dbx.ReKey(cipher, new_password); // empty password resets encryption
dbx.Close();
}

Expand Down

0 comments on commit 6ba60be

Please sign in to comment.