Added pronounceable password generator

Improved RNG seeding on Windows
Updated AES implementation
Removed SHA1 implementation, replaced by QCryptographicHash
Replaced ARC4 implementation by the one from KeePass 1.11
Some cleanup

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@216 b624d157-de02-0410-bad0-e51aec6abb33
This commit is contained in:
sniperbeamer
2008-08-01 18:57:18 +00:00
parent 455e68ff60
commit 636f3b8af6
46 changed files with 5192 additions and 2662 deletions

View File

@@ -18,11 +18,6 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifdef Q_WS_X11
#include <sys/mman.h>
#include <limits.h>
#endif
using namespace std;
CArcFour SecString::RC4;
@@ -54,7 +49,7 @@ void SecString::unlock(){
if(!crypt.length())
return;
const unsigned char* buffer = new unsigned char[crypt.length()];
SecString::RC4.decrypt( (byte*)crypt.data(), (unsigned char*)buffer, crypt.length() );
RC4.decrypt( (byte*)crypt.data(), (unsigned char*)buffer, crypt.length() );
plain = QString::fromUtf8((const char*)buffer, crypt.size());
overwrite((unsigned char*)buffer, crypt.size());
delete [] buffer;
@@ -69,7 +64,7 @@ void SecString::setString(QString& str, bool DeleteSource){
QByteArray StrData = str.toUtf8();
int len = StrData.size();
unsigned char* buffer = new unsigned char[len];
SecString::RC4.encrypt((const unsigned char*)StrData.data(), buffer, len);
RC4.encrypt((const unsigned char*)StrData.data(), buffer, len);
crypt = QByteArray((const char*)buffer, len);
overwrite(buffer, len);
overwrite((unsigned char*)StrData.data(), len);
@@ -98,20 +93,8 @@ void SecString::overwrite(QString& str){
}
void SecString::generateSessionKey(){
CArcFour arc;
unsigned char sessionkey[32];
#ifdef Q_WS_X11
#ifdef PAGESIZE
mlock(sessionkey - sessionkey%PAGESIZE, 32);
#else
mlock(sessionkey, 32);
#endif
#endif // Q_WS_X11
randomize(sessionkey,32);
RC4.setKey(sessionkey,32);
overwrite(sessionkey,32);
quint8* sessionkey = new quint8[32];
lockPage(sessionkey, 32);
randomize(sessionkey, 32);
RC4.setKey(sessionkey, 32);
}