show key dialog again if hash test fails

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@116 b624d157-de02-0410-bad0-e51aec6abb33
master
tarek_saidi 18 years ago
parent a8d60588cc
commit f4efea7849
  1. 1
      src/Database.h
  2. 12
      src/StandardDatabase.cpp
  3. 2
      src/StandardDatabase.h
  4. 3
      src/mainwindow.cpp

@ -394,6 +394,7 @@ public:
\return TRUE if the creation was successfull, otherwise FALSE.
*/
virtual bool createKeyFile(const QString& filename,int length=32, bool Hex=false)=0;
virtual bool isKeyError()=0;
};
class IKdbSettings{

@ -421,6 +421,7 @@ SHA256::hashBuffer(buffer+DB_HEADER_SIZE,FinalKey,crypto_size);
if(memcmp(ContentsHash, FinalKey, 32) != 0){
error=tr("Hash test failed.\nThe key is wrong or the file is damaged.");
KeyError=true;
return false;}
unsigned long tmp_id=0;
@ -1359,7 +1360,16 @@ void StandardDatabase::create(){
RootGroup.Handle=NULL;
Algorithm=Rijndael_Cipher;
KeyTransfRounds=6000;
KeyError=false;
}
bool StandardDatabase::isKeyError(){
if(KeyError){
KeyError=false;
return true;
}
else
return false;
}
IEntryHandle* StandardDatabase::cloneEntry(const IEntryHandle* entry){

@ -146,6 +146,7 @@ public:
virtual int numEntries();
virtual int numGroups();
virtual QString getError();
virtual bool isKeyError();
virtual void cleanUpHandles();
virtual QPixmap& icon(int index);
virtual int numIcons();
@ -227,6 +228,7 @@ private:
QList<QPixmap>CustomIcons;
QFile* File;
QString error;
bool KeyError;
QList<StdEntry> UnknownMetaStreams;
unsigned int KeyTransfRounds;
CryptAlgorithm Algorithm;

@ -336,11 +336,14 @@ void KeepassMainWindow::openDatabase(QString filename,bool IsAuto){
else{
StatusBarGeneral->setText(tr("Loading Failed"));
QString error=db->getError();
bool KeyError=auth->isKeyError();
delete db;
if(error==QString())error=tr("Unknown error while loading database.");
QMessageBox::critical(this,tr("Error")
,tr("The following error occured while opening the database:\n%1")
.arg(error),tr("OK"));
if(KeyError)
openDatabase(filename,IsAuto);
}
StatusBarGeneral->setText(tr("Ready"));
}