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. 10
      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. \return TRUE if the creation was successfull, otherwise FALSE.
*/ */
virtual bool createKeyFile(const QString& filename,int length=32, bool Hex=false)=0; virtual bool createKeyFile(const QString& filename,int length=32, bool Hex=false)=0;
virtual bool isKeyError()=0;
}; };
class IKdbSettings{ class IKdbSettings{

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

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

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