git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@5 b624d157-de02-0410-bad0-e51aec6abb33
master
tariq 19 years ago
parent 192dbba0e4
commit 28c71dfe1e
  1. 38
      src/Database.h
  2. 52
      src/ListViews.cpp
  3. 42
      src/ListViews.h
  4. 114
      src/PwManager.cpp
  5. 14
      src/PwManager.h
  6. 52
      src/PwmConfig.cpp
  7. 388
      src/crypto/rijndael.cpp
  8. 22
      src/crypto/rijndael.h
  9. 522
      src/crypto/sha1.cpp
  10. 198
      src/crypto/sha1.h
  11. 56
      src/crypto/sha256.c
  12. 40
      src/crypto/twoclass.cpp
  13. 8
      src/crypto/twoclass.h
  14. 18
      src/crypto/twofish.cpp
  15. 8
      src/dialogs/AboutDlg.cpp
  16. 2
      src/dialogs/AboutDlg.h
  17. 18
      src/dialogs/ChangeKeyDlg.cpp
  18. 6
      src/dialogs/ChangeKeyDlg.h
  19. 4
      src/dialogs/DatabaseSettingsDlg.cpp
  20. 4
      src/dialogs/DatabaseSettingsDlg.h
  21. 20
      src/dialogs/EditEntryDlg.cpp
  22. 5
      src/dialogs/EditEntryDlg.h
  23. 4
      src/dialogs/EditGroupDlg.cpp
  24. 4
      src/dialogs/EditGroupDlg.h
  25. 32
      src/dialogs/LanguageDlg.cpp
  26. 10
      src/dialogs/LanguageDlg.h
  27. 12
      src/dialogs/PasswordDlg.cpp
  28. 6
      src/dialogs/PasswordDlg.h
  29. 18
      src/dialogs/PasswordGenDlg.cpp
  30. 2
      src/dialogs/PasswordGenDlg.h
  31. 2
      src/dialogs/SearchDlg.cpp
  32. 2
      src/dialogs/SearchDlg.h
  33. 8
      src/dialogs/SettingsDlg.cpp
  34. 2
      src/dialogs/SettingsDlg.h
  35. 2
      src/dialogs/SimplePasswordDlg.cpp
  36. 2
      src/dialogs/SimplePasswordDlg.h
  37. 8
      src/import/Import_KWalletXml.cpp
  38. 4
      src/import/Import_PwManager.cpp
  39. 20
      src/lib/PwmTime.cpp
  40. 18
      src/lib/PwmTime.h
  41. 4
      src/lib/SecString.cpp
  42. 4
      src/lib/SecString.h
  43. 9
      src/lib/UrlLabel.cpp
  44. 6
      src/lib/UrlLabel.h
  45. 8
      src/lib/random.cpp
  46. 2
      src/main.cpp
  47. 71
      src/mainwindow.cpp
  48. 20
      src/mainwindow.h
  49. 2
      src/pwsafe.cpp
  50. 4
      src/pwsafe.h
  51. 5
      src/src.pro

@ -28,10 +28,10 @@ class CEntry{
public:
CEntry();
~CEntry();
UINT8 ID[16];
UINT32 sID;
UINT32 GroupID;
UINT32 ImageID;
Q_UINT8 ID[16];
Q_UINT32 sID;
Q_UINT32 GroupID;
Q_UINT32 ImageID;
QString Title;
QString URL;
QString UserName;
@ -42,10 +42,10 @@ CPwmTime Creation;
CPwmTime LastMod;
CPwmTime LastAccess;
CPwmTime Expire;
UINT8 *pBinaryData;
UINT32 BinaryDataLength;
UINT32 PasswordLength;
bool ReadEntryField(UINT16 FieldType, UINT32 FieldSize, UINT8 *pData);
Q_UINT8 *pBinaryData;
Q_UINT32 BinaryDataLength;
Q_UINT32 PasswordLength;
bool ReadEntryField(Q_UINT16 FieldType, Q_UINT32 FieldSize, Q_UINT8 *pData);
};
@ -53,17 +53,17 @@ class CGroup{
public:
CGroup();
~CGroup();
UINT32 ID;
UINT32 ImageID;
UINT32 NumEntries;
Q_UINT32 ID;
Q_UINT32 ImageID;
Q_UINT32 NumEntries;
QString Name;
CPwmTime Creation;
CPwmTime LastMod;
CPwmTime LastAccess;
CPwmTime Expire;
UINT16 Level;
UINT32 Flags;
bool ReadGroupField(UINT16 FieldType, UINT32 FieldSize, UINT8 *pData);
Q_UINT16 Level;
Q_UINT32 Flags;
bool ReadGroupField(Q_UINT16 FieldType, Q_UINT32 FieldSize, Q_UINT8 *pData);
bool UI_ItemIsExpanded;
static bool UI_ExpandByDefault;
@ -85,15 +85,15 @@ public:
class Database:public AbstractDatabase{
public:
UINT32 CryptoAlgorithmus;
UINT32 KeyEncRounds;
Q_UINT32 CryptoAlgorithmus;
Q_UINT32 KeyEncRounds;
QString filename;
bool modflag;
int SearchGroupID;
protected:
UINT8 MasterKey[32];
UINT8 TransformedMasterKey[32];
Q_UINT8 MasterKey[32];
Q_UINT8 TransformedMasterKey[32];
};
#endif
#endif

@ -20,61 +20,61 @@
#include "ListViews.h"
#include "PwManager.h"
#include <qstring.h>
#include <qlistview.h>
#include <q3listview.h>
GroupItem::GroupItem(CGroup* group, QListView * parent ) : QListViewItem(parent)
GroupItem::GroupItem(CGroup* group, Q3ListView * parent ) : Q3ListViewItem(parent)
{
pGroup=group;
setDropEnabled(true);
}
GroupItem::GroupItem(CGroup* group, QListViewItem * parent ): QListViewItem(parent)
GroupItem::GroupItem(CGroup* group, Q3ListViewItem * parent ): Q3ListViewItem(parent)
{
pGroup=group;
setDropEnabled(true);
}
GroupItem::GroupItem(CGroup* group, QListView * parent, QListViewItem * after ): QListViewItem(parent,after)
GroupItem::GroupItem(CGroup* group, Q3ListView * parent, Q3ListViewItem * after ): Q3ListViewItem(parent,after)
{
pGroup=group;
setDropEnabled(true);
}
GroupItem::GroupItem(CGroup* group, QListViewItem * parent, QListViewItem * after ): QListViewItem(parent,after)
GroupItem::GroupItem(CGroup* group, Q3ListViewItem * parent, Q3ListViewItem * after ): Q3ListViewItem(parent,after)
{
pGroup=group;
setDropEnabled(true);
}
GroupItem::GroupItem(CGroup* group, QListView* parent, QString l1,QString l2,QString l3,QString l4,
GroupItem::GroupItem(CGroup* group, Q3ListView* parent, QString l1,QString l2,QString l3,QString l4,
QString l5,QString l6,QString l7,QString l8)
:QListViewItem(parent,l1,l2,l3,l4,l5,l6,l7,l8)
:Q3ListViewItem(parent,l1,l2,l3,l4,l5,l6,l7,l8)
{
pGroup=group;
setDropEnabled(true);
}
GroupItem::GroupItem(CGroup* group, QListViewItem* parent, QString l1,QString l2,QString l3,QString l4,
GroupItem::GroupItem(CGroup* group, Q3ListViewItem* parent, QString l1,QString l2,QString l3,QString l4,
QString l5,QString l6,QString l7,QString l8)
:QListViewItem(parent,l1,l2,l3,l4,l5,l6,l7,l8)
:Q3ListViewItem(parent,l1,l2,l3,l4,l5,l6,l7,l8)
{
pGroup=group;
setDropEnabled(true);
}
GroupItem::GroupItem(CGroup* group, QListView* parent,QListViewItem* after, QString l1,QString l2,QString l3,QString l4,
GroupItem::GroupItem(CGroup* group, Q3ListView* parent,Q3ListViewItem* after, QString l1,QString l2,QString l3,QString l4,
QString l5,QString l6,QString l7,QString l8)
:QListViewItem(parent,after,l1,l2,l3,l4,l5,l6,l7,l8)
:Q3ListViewItem(parent,after,l1,l2,l3,l4,l5,l6,l7,l8)
{
pGroup=group;
setDropEnabled(true);
}
GroupItem::GroupItem(CGroup* group, QListViewItem* parent,QListViewItem* after, QString l1,QString l2,QString l3,QString l4,
GroupItem::GroupItem(CGroup* group, Q3ListViewItem* parent,Q3ListViewItem* after, QString l1,QString l2,QString l3,QString l4,
QString l5,QString l6,QString l7,QString l8)
:QListViewItem(parent,after,l1,l2,l3,l4,l5,l6,l7,l8)
:Q3ListViewItem(parent,after,l1,l2,l3,l4,l5,l6,l7,l8)
{
pGroup=group;
setDropEnabled(true);
@ -91,57 +91,57 @@ return true;
///////////////////////////////
EntryItem::EntryItem(CEntry* entry, QListView * parent ) : QListViewItem(parent)
EntryItem::EntryItem(CEntry* entry, Q3ListView * parent ) : Q3ListViewItem(parent)
{
pEntry=entry;
setDragEnabled(true);
}
EntryItem::EntryItem(CEntry* entry, QListViewItem * parent ): QListViewItem(parent)
EntryItem::EntryItem(CEntry* entry, Q3ListViewItem * parent ): Q3ListViewItem(parent)
{
pEntry=entry;
setDragEnabled(true);
}
EntryItem::EntryItem(CEntry* entry, QListView * parent, QListViewItem * after ): QListViewItem(parent,after)
EntryItem::EntryItem(CEntry* entry, Q3ListView * parent, Q3ListViewItem * after ): Q3ListViewItem(parent,after)
{
pEntry=entry;
setDragEnabled(true);
}
EntryItem::EntryItem(CEntry* entry, QListViewItem * parent, QListViewItem * after ): QListViewItem(parent,after)
EntryItem::EntryItem(CEntry* entry, Q3ListViewItem * parent, Q3ListViewItem * after ): Q3ListViewItem(parent,after)
{
pEntry=entry;
setDragEnabled(true);
}
EntryItem::EntryItem(CEntry* entry, QListView* parent, QString l1,QString l2,QString l3,QString l4,
EntryItem::EntryItem(CEntry* entry, Q3ListView* parent, QString l1,QString l2,QString l3,QString l4,
QString l5,QString l6,QString l7,QString l8)
:QListViewItem(parent,l1,l2,l3,l4,l5,l6,l7,l8)
:Q3ListViewItem(parent,l1,l2,l3,l4,l5,l6,l7,l8)
{
pEntry=entry;
setDragEnabled(true);
}
EntryItem::EntryItem(CEntry* entry, QListViewItem* parent, QString l1,QString l2,QString l3,QString l4,
EntryItem::EntryItem(CEntry* entry, Q3ListViewItem* parent, QString l1,QString l2,QString l3,QString l4,
QString l5,QString l6,QString l7,QString l8)
:QListViewItem(parent,l1,l2,l3,l4,l5,l6,l7,l8)
:Q3ListViewItem(parent,l1,l2,l3,l4,l5,l6,l7,l8)
{
pEntry=entry;
setDragEnabled(true);
}
EntryItem::EntryItem(CEntry* entry, QListView* parent,QListViewItem* after, QString l1,QString l2,QString l3,QString l4,
EntryItem::EntryItem(CEntry* entry, Q3ListView* parent,Q3ListViewItem* after, QString l1,QString l2,QString l3,QString l4,
QString l5,QString l6,QString l7,QString l8)
:QListViewItem(parent,after,l1,l2,l3,l4,l5,l6,l7,l8)
:Q3ListViewItem(parent,after,l1,l2,l3,l4,l5,l6,l7,l8)
{
pEntry=entry;
setDragEnabled(true);
}
EntryItem::EntryItem(CEntry* entry, QListViewItem* parent,QListViewItem* after, QString l1,QString l2,QString l3,QString l4,
EntryItem::EntryItem(CEntry* entry, Q3ListViewItem* parent,Q3ListViewItem* after, QString l1,QString l2,QString l3,QString l4,
QString l5,QString l6,QString l7,QString l8)
:QListViewItem(parent,after,l1,l2,l3,l4,l5,l6,l7,l8)
:Q3ListViewItem(parent,after,l1,l2,l3,l4,l5,l6,l7,l8)
{
pEntry=entry;
setDragEnabled(true);
@ -150,6 +150,6 @@ setDragEnabled(true);
CGroupView::CGroupView(QWidget * parent, const char * name, WFlags f):QListView(parent,name,f){
CGroupView::CGroupView(QWidget * parent, const char * name, Qt::WFlags f):Q3ListView(parent,name,f){
};

@ -20,39 +20,39 @@
#ifndef _LISTVIEWS_H_
#define _LISTVIEWS_H_
#include <qlistview.h>
#include <q3listview.h>
#include <qmime.h>
#include "PwManager.h"
class GroupItem: public QListViewItem{
class GroupItem: public Q3ListViewItem{
public:
CGroup* pGroup;
virtual bool acceptDrop(const QMimeSource * mime);
///////////////////////////////////////////////////////////////////////
GroupItem(CGroup*, QListView * parent );
GroupItem(CGroup*, QListViewItem * parent );
GroupItem(CGroup*, QListView * parent, QListViewItem * after );
GroupItem(CGroup*, QListViewItem * parent, QListViewItem * after );
GroupItem(CGroup*, Q3ListView * parent );
GroupItem(CGroup*, Q3ListViewItem * parent );
GroupItem(CGroup*, Q3ListView * parent, Q3ListViewItem * after );
GroupItem(CGroup*, Q3ListViewItem * parent, Q3ListViewItem * after );
GroupItem(CGroup*, QListView * parent,
GroupItem(CGroup*, Q3ListView * parent,
QString, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null );
GroupItem(CGroup*, QListViewItem * parent,
GroupItem(CGroup*, Q3ListViewItem * parent,
QString, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null );
GroupItem(CGroup*, QListView * parent, QListViewItem * after,
GroupItem(CGroup*, Q3ListView * parent, Q3ListViewItem * after,
QString, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null );
GroupItem(CGroup*, QListViewItem * parent, QListViewItem * after,
GroupItem(CGroup*, Q3ListViewItem * parent, Q3ListViewItem * after,
QString, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null,
@ -62,34 +62,34 @@ virtual bool acceptDrop(const QMimeSource * mime);
};
class EntryItem: public QListViewItem{
class EntryItem: public Q3ListViewItem{
public:
CEntry* pEntry;
///////////////////////////////////////////////////////////////////////
EntryItem(CEntry*, QListView * parent );
EntryItem(CEntry*, QListViewItem * parent );
EntryItem(CEntry*, QListView * parent, QListViewItem * after );
EntryItem(CEntry*, QListViewItem * parent, QListViewItem * after );
EntryItem(CEntry*, Q3ListView * parent );
EntryItem(CEntry*, Q3ListViewItem * parent );
EntryItem(CEntry*, Q3ListView * parent, Q3ListViewItem * after );
EntryItem(CEntry*, Q3ListViewItem * parent, Q3ListViewItem * after );
EntryItem(CEntry*, QListView * parent,
EntryItem(CEntry*, Q3ListView * parent,
QString, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null );
EntryItem(CEntry*, QListViewItem * parent,
EntryItem(CEntry*, Q3ListViewItem * parent,
QString, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null );
EntryItem(CEntry*, QListView * parent, QListViewItem * after,
EntryItem(CEntry*, Q3ListView * parent, Q3ListViewItem * after,
QString, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null );
EntryItem(CEntry*, QListViewItem * parent, QListViewItem * after,
EntryItem(CEntry*, Q3ListViewItem * parent, Q3ListViewItem * after,
QString, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null,
@ -98,9 +98,9 @@ CEntry* pEntry;
};
class CGroupView: public QListView{
class CGroupView: public Q3ListView{
public:
CGroupView(QWidget * parent = 0, const char * name = 0, WFlags f = 0 );
CGroupView(QWidget * parent = 0, const char * name = 0, Qt::WFlags f = 0 );
};

@ -36,15 +36,15 @@
bool PwDatabase::loadDatabase(QString _filename, QString& err){
unsigned long total_size,crypto_size;
UINT32 Signature1,Signature2,Version,NumGroups,NumEntries,Flags;
UINT8 TrafoRandomSeed[32];
UINT8 FinalRandomSeed[16];
UINT8 ContentsHash[32];
UINT8 EncryptionIV[16];
Q_UINT32 Signature1,Signature2,Version,NumGroups,NumEntries,Flags;
Q_UINT8 TrafoRandomSeed[32];
Q_UINT8 FinalRandomSeed[16];
Q_UINT8 ContentsHash[32];
Q_UINT8 EncryptionIV[16];
filename=_filename;
QFile file(filename);
file.open(IO_ReadOnly);
file.open(QIODevice::ReadOnly);
total_size=file.size();
char* buffer = new char[total_size];
file.readBlock(buffer,total_size);
@ -83,7 +83,7 @@ else {
}
transformKey(MasterKey,TransformedMasterKey,TrafoRandomSeed,KeyEncRounds);
UINT8 FinalKey[32];
Q_UINT8 FinalKey[32];
sha256_context sha32;
sha256_starts(&sha32);
sha256_update(&sha32,FinalRandomSeed, 16);
@ -99,15 +99,15 @@ if(CryptoAlgorithmus == ALGO_AES)
{err=trUtf8("AES-Initialisierung fehlgeschlagen");
return false;}
// Decrypt! The first bytes aren't encrypted (that's the header)
crypto_size = (unsigned long)aes.padDecrypt((UINT8 *)buffer + DB_HEADER_SIZE,
total_size - DB_HEADER_SIZE, (UINT8 *)buffer + DB_HEADER_SIZE);
crypto_size = (unsigned long)aes.padDecrypt((Q_UINT8 *)buffer + DB_HEADER_SIZE,
total_size - DB_HEADER_SIZE, (Q_UINT8 *)buffer + DB_HEADER_SIZE);
}
else if(CryptoAlgorithmus == ALGO_TWOFISH)
{
CTwofish twofish;
if(twofish.init(FinalKey, 32, EncryptionIV) != true){return false;}
crypto_size = (unsigned long)twofish.padDecrypt((UINT8 *)buffer + DB_HEADER_SIZE,
total_size - DB_HEADER_SIZE, (UINT8 *)buffer + DB_HEADER_SIZE);
crypto_size = (unsigned long)twofish.padDecrypt((Q_UINT8 *)buffer + DB_HEADER_SIZE,
total_size - DB_HEADER_SIZE, (Q_UINT8 *)buffer + DB_HEADER_SIZE);
}
if((crypto_size > 2147483446) || (crypto_size == 0)){err=trUtf8("Unerwarteter Wert für 'crypto_size'"); return false;}
@ -127,8 +127,8 @@ Entries.resize(NumEntries);
unsigned long tmp_id=0;
unsigned long pos = DB_HEADER_SIZE;
UINT16 FieldType;
UINT32 FieldSize;
Q_UINT16 FieldType;
Q_UINT32 FieldSize;
char* pField;
bool bRet;
@ -147,7 +147,7 @@ bool bRet;
if(pos >= (total_size + FieldSize)) {
return false;}
bRet = Groups[CurGroup].ReadGroupField(FieldType, FieldSize, (UINT8 *)pField);
bRet = Groups[CurGroup].ReadGroupField(FieldType, FieldSize, (Q_UINT8 *)pField);
if((FieldType == 0xFFFF) && (bRet == true)){
CurGroup++;} // Now and ONLY now the counter gets increased
@ -171,7 +171,7 @@ bool bRet;
if(pos >= (total_size + FieldSize)) {
return false; }
bRet = Entries[CurEntry].ReadEntryField(FieldType,FieldSize,(UINT8*)pField);
bRet = Entries[CurEntry].ReadEntryField(FieldType,FieldSize,(Q_UINT8*)pField);
if((FieldType == 0xFFFF) && (bRet == true)){
Entries[CurEntry].sID=tmp_id++;
CurEntry++;} // Now and ONLY now the counter gets increased
@ -196,18 +196,18 @@ return true;
}
void PwDatabase::transformKey(UINT8* src,UINT8* dst,UINT8* KeySeed,int rounds){
UINT8* tmp=new UINT8[32];
void PwDatabase::transformKey(Q_UINT8* src,Q_UINT8* dst,Q_UINT8* KeySeed,int rounds){
Q_UINT8* tmp=new Q_UINT8[32];
Rijndael rijndael;
sha256_context sha2;
if(rijndael.init(Rijndael::ECB, Rijndael::Encrypt, (const UINT8 *)KeySeed,
if(rijndael.init(Rijndael::ECB, Rijndael::Encrypt, (const Q_UINT8 *)KeySeed,
Rijndael::Key32Bytes, 0) != RIJNDAEL_SUCCESS){
cout << QString("unexpected error in %1, line %2").arg(__FILE__).arg(__LINE__) << endl;
cout << QString("unexpected error in %1, line %2").arg(__FILE__).arg(__LINE__).ascii() << endl;
exit(1);}
memcpy(tmp,src,32);
for(int i=0;i<rounds;i++){
rijndael.blockEncrypt((const UINT8 *)tmp, 256, (UINT8 *)tmp);
rijndael.blockEncrypt((const Q_UINT8 *)tmp, 256, (Q_UINT8 *)tmp);
}
sha256_starts(&sha2);
@ -253,7 +253,7 @@ return true;
bool PwDatabase::CalcMasterKeyByFile(QString filename){
QFile file(filename);
if(file.open(IO_ReadOnly) == false) return false;
if(file.open(QIODevice::ReadOnly) == false) return false;
unsigned long FileSize=file.size();
if(FileSize == 32){
@ -314,14 +314,14 @@ return &Entries.back();
bool PwDatabase::CalcMasterKeyByFileAndPw(QString filename, QString& Password){
UINT8* FileKey;
UINT8* PasswordKey;
PasswordKey=new UINT8[32];
FileKey=new UINT8[32];
Q_UINT8* FileKey;
Q_UINT8* PasswordKey;
PasswordKey=new Q_UINT8[32];
FileKey=new Q_UINT8[32];
sha256_context sha32;
/////////////////////////
QFile file(filename);
if(file.open(IO_ReadOnly) == false) return false;
if(file.open(QIODevice::ReadOnly) == false) return false;
unsigned long FileSize=file.size();
if(FileSize == 32){
if(file.readBlock((char*)FileKey,32) != 32){
@ -381,14 +381,14 @@ return deleteEntry(getEntryIterator(entry));
bool PwDatabase::IsMetaStream(CEntry& p){
if(p.pBinaryData == NULL) return false;
if(p.Additional == NULL) return false;
if(p.BinaryDesc == NULL) return false;
if(p.Additional == "") return false;
if(p.BinaryDesc == "") return false;
if(p.BinaryDesc != "bin-stream") return false;
if(p.Title == NULL) return false;
if(p.Title == "") return false;
if(p.Title != "Meta-Info") return false;
if(p.UserName == NULL) return false;
if(p.UserName == "") return false;
if(p.UserName != "SYSTEM") return false;
if(p.URL == NULL) return false;
if(p.URL == "") return false;
if(p.URL != "$") return false;
if(p.ImageID != 0) return false;
return true;
@ -402,7 +402,7 @@ entry->GroupID=dst->ID;
bool CGroup::ReadGroupField(UINT16 FieldType, UINT32 FieldSize, UINT8 *pData)
bool CGroup::ReadGroupField(Q_UINT16 FieldType, Q_UINT32 FieldSize, Q_UINT8 *pData)
{
switch(FieldType)
@ -456,7 +456,7 @@ PwDatabase::~PwDatabase(){
}
bool CEntry::ReadEntryField(UINT16 FieldType, UINT32 FieldSize, UINT8 *pData){
bool CEntry::ReadEntryField(Q_UINT16 FieldType, Q_UINT32 FieldSize, Q_UINT8 *pData){
switch(FieldType)
@ -510,7 +510,7 @@ switch(FieldType)
{
///@TODO: im Destruktor löschen
///@TODO: im Konstruktor auf Null
pBinaryData = new UINT8[FieldSize];
pBinaryData = new Q_UINT8[FieldSize];
memcpy(pBinaryData, pData, FieldSize);
BinaryDataLength = FieldSize;
}
@ -535,11 +535,11 @@ return true;
bool PwDatabase::SaveDataBase(QString filename){
CGroup SearchGroup;
UINT32 NumGroups,NumEntries,Signature1,Signature2,Flags,Version;
UINT8 TrafoRandomSeed[32];
UINT8 FinalRandomSeed[16];
UINT8 ContentsHash[32];
UINT8 EncryptionIV[16];
Q_UINT32 NumGroups,NumEntries,Signature1,Signature2,Flags,Version;
Q_UINT8 TrafoRandomSeed[32];
Q_UINT8 FinalRandomSeed[16];
Q_UINT8 ContentsHash[32];
Q_UINT8 EncryptionIV[16];
if(SearchGroupID!=-1){
for(int i=0;i<Groups.size();i++){
@ -586,8 +586,8 @@ getRandomBytes(FinalRandomSeed,1,16,false);
getRandomBytes(TrafoRandomSeed,1,32,false);
getRandomBytes(EncryptionIV,1,16,false);
UINT16 FieldType;
UINT32 FieldSize;
Q_UINT16 FieldType;
Q_UINT32 FieldSize;
int pos=DB_HEADER_SIZE; // Skip the header, it will be written later
for(int i=0; i < Groups.size(); i++){
@ -743,7 +743,7 @@ memcpy(buffer+56,ContentsHash,32);
memcpy(buffer+88,TrafoRandomSeed,32);
memcpy(buffer+120,&KeyEncRounds,4);
transformKey(MasterKey,TransformedMasterKey,TrafoRandomSeed,KeyEncRounds);
UINT8 FinalKey[32];
Q_UINT8 FinalKey[32];
sha256_starts(&context);
sha256_update(&context,FinalRandomSeed, 16);
sha256_update(&context,TransformedMasterKey, 32);
@ -758,18 +758,18 @@ Rijndael aes;
//TODO:ERR_MSG
delete [] buffer;
return false;}
EncryptedPartSize = (unsigned long)aes.padEncrypt((UINT8*)buffer+DB_HEADER_SIZE,
EncryptedPartSize = (unsigned long)aes.padEncrypt((Q_UINT8*)buffer+DB_HEADER_SIZE,
pos - DB_HEADER_SIZE,
(UINT8*)buffer+DB_HEADER_SIZE);
(Q_UINT8*)buffer+DB_HEADER_SIZE);
}else if(CryptoAlgorithmus == ALGO_TWOFISH){
CTwofish twofish;
if(twofish.init(FinalKey, 32, EncryptionIV) == false){
//TODO:ERR_MSG
delete [] buffer;
return false;}
EncryptedPartSize = (unsigned long)twofish.padEncrypt((UINT8*)buffer+DB_HEADER_SIZE,
EncryptedPartSize = (unsigned long)twofish.padEncrypt((Q_UINT8*)buffer+DB_HEADER_SIZE,
pos - DB_HEADER_SIZE,
(UINT8*)buffer+DB_HEADER_SIZE);
(Q_UINT8*)buffer+DB_HEADER_SIZE);
}
if((EncryptedPartSize > 2147483446) || (EncryptedPartSize == 0)){
@ -778,7 +778,7 @@ delete [] buffer;
return false;
}
if(file.open(IO_ReadWrite | IO_Truncate)==false){
if(file.open(QIODevice::ReadWrite | QIODevice::Truncate)==false){
//TODO:ERR_MSG
delete [] buffer;
return false;
@ -889,14 +889,14 @@ for(int i=0;i<db->Groups.size();i++){
}
}
bool PwDatabase::isGroupIdInUse(UINT32 id){
bool PwDatabase::isGroupIdInUse(Q_UINT32 id){
for(int i=0;i<Groups.size();i++)
if(Groups[i].ID==id)return true;
return false;
}
bool PwDatabase::isEntrySidInUse(UINT32 sid){
bool PwDatabase::isEntrySidInUse(Q_UINT32 sid){
for(int i=0;i<Entries.size();i++)
if(Entries[i].sID==sid)return true;
@ -904,8 +904,8 @@ return false;
}
UINT32 PwDatabase::getNewGroupId(){
UINT32 id;
Q_UINT32 PwDatabase::getNewGroupId(){
Q_UINT32 id;
bool used;
while(1){
used=false;
@ -917,8 +917,8 @@ if(used==false)break;}
return id;
}
UINT32 PwDatabase::getNewEntrySid(){
UINT32 sid;
Q_UINT32 PwDatabase::getNewEntrySid(){
Q_UINT32 sid;
while(1){
getRandomBytes(&sid,4,1,false);
if(!sid)continue;
@ -931,7 +931,7 @@ bool PwDatabase::convHexToBinaryKey(char* HexKey, char* dst){
QString hex=QString::fromAscii(HexKey,64);
for(int i=0; i<64; i+=2){
bool err;
UINT8 bin;
Q_UINT8 bin;
bin=hex.mid(i,2).toUInt(&err,16);
if(!err){
qWarning("Invalid Hex Key\n");
@ -940,7 +940,7 @@ for(int i=0; i<64; i+=2){
}
}
void memcpyFromLEnd32(UINT32* dst,char* src){
void memcpyFromLEnd32(Q_UINT32* dst,char* src){
#ifdef KEEPASS_LITTLE_ENDIAN
memcpy(dst,src,4);
#endif
@ -952,7 +952,7 @@ void memcpyFromLEnd32(UINT32* dst,char* src){
#endif
}
void memcpyFromLEnd16(UINT16* dst,char* src){
void memcpyFromLEnd16(Q_UINT16* dst,char* src){
#ifdef KEEPASS_LITTLE_ENDIAN
memcpy(dst,src,2);
#endif
@ -960,4 +960,4 @@ void memcpyFromLEnd16(UINT16* dst,char* src){
memcpy(dst+1,src+0,1);
memcpy(dst+0,src+1,1);
#endif
}
}

@ -68,16 +68,16 @@ private:
EntryItr getEntryIterator(CEntry* pEntry);
GroupItr getGroupIterator(CGroup* pGroup);
bool IsMetaStream(CEntry& Entry);
void transformKey(UINT8* src,UINT8* dst,UINT8* seed,int rounds);
void transformKey(Q_UINT8* src,Q_UINT8* dst,Q_UINT8* seed,int rounds);
bool readHeader(char* raw);
bool isGroupIdInUse(UINT32 GroupID);
bool isEntrySidInUse(UINT32 sID);
UINT32 getNewGroupId();
UINT32 getNewEntrySid();
bool isGroupIdInUse(Q_UINT32 GroupID);
bool isEntrySidInUse(Q_UINT32 sID);
Q_UINT32 getNewGroupId();
Q_UINT32 getNewEntrySid();
bool convHexToBinaryKey(char* HexKey, char* dst);
};
void memcpyFromLEnd32(UINT32* dst,char* src);
void memcpyFromLEnd16(UINT16* dst,char* src);
void memcpyFromLEnd32(Q_UINT32* dst,char* src);
void memcpyFromLEnd16(Q_UINT16* dst,char* src);
#endif

@ -24,52 +24,52 @@
#include <iostream.h>
bool CConfig::loadFromIni(QString filename){
CIniFile ini(filename);
CIniFile ini((char*)filename.data());
ini.ReadFile();
ClipboardTimeOut=ini.GetValueI("Options","ClipboardTimeOut",20);
Toolbar=ini.GetValueB("UI","ShowToolbar",true);
EntryDetails=ini.GetValueB("UI","ShowEntryDetails",true);
OpenLast=ini.GetValueB("Options","OpenLast",true);
LastFile=ini.GetValue("Options","LastFile","");
ParseColumnString(ini.GetValue("UI","Columns","1111100000"),Columns);
BannerColor1=ParseColorString(ini.GetValue("Options","BannerColor1","0,104,176"));
BannerColor2=ParseColorString(ini.GetValue("Options","BannerColor2","213,239,255"));
BannerTextColor=ParseColorString(ini.GetValue("Options","BannerTextColor","4,0,80"));
LastFile=ini.GetValue("Options","LastFile","").c_str();
ParseColumnString(ini.GetValue("UI","Columns","1111100000").c_str(),Columns);
BannerColor1=ParseColorString(ini.GetValue("Options","BannerColor1","0,104,176").c_str());
BannerColor2=ParseColorString(ini.GetValue("Options","BannerColor2","213,239,255").c_str());
BannerTextColor=ParseColorString(ini.GetValue("Options","BannerTextColor","4,0,80").c_str());
ShowPasswords=ini.GetValueB("Options","ShowPasswords",false);
OpenUrlCommand=ini.GetValue("Options","UrlCmd","kfmclient openURL %1");
Language=ini.GetValue("Options","LangFile","");
ParseBoolString(ini.GetValue("Options","SearchOptions","00110111"),SearchOptions,8);
OpenUrlCommand=ini.GetValue("Options","UrlCmd","kfmclient openURL %1").c_str();
Language=ini.GetValue("Options","LangFile","").c_str();
ParseBoolString(ini.GetValue("Options","SearchOptions","00110111").c_str(),SearchOptions,8);
ListView_HidePasswords=ini.GetValueB("UI","HidePasswords",true);
ListView_HideUsernames=ini.GetValueB("UI","HideUsernames",false);
ParseBoolString(ini.GetValue("Options","PwGenOptions","1111100001"),PwGenOptions,10);
ParseBoolString(ini.GetValue("Options","PwGenOptions","1111100001").c_str(),PwGenOptions,10);
PwGenLength=ini.GetValueI("Options","PwGenLength",25);
PwGenCharList=ini.GetValue("Options","PwGenCharList","");
PwGenCharList=ini.GetValue("Options","PwGenCharList","").c_str();
ExpandGroupTree=ini.GetValueB("Options","ExpandGroupTree",true);
EnableKdePlugin=ini.GetValueB("KDE Plugin","Enabled",false);
return true;
}
bool CConfig::saveToIni(QString filename){
CIniFile ini(filename);
CIniFile ini((const char*)filename);
ini.ReadFile();
ini.SetValueI("Options","ClipboardTimeOut",ClipboardTimeOut);
ini.SetValueB("UI","ShowToolbar",Toolbar);
ini.SetValueB("UI","ShowEntryDetails",EntryDetails);
if(OpenLast)ini.SetValue("Options","LastFile",LastFile);
if(OpenLast)ini.SetValue("Options","LastFile",(const char*)LastFile);
else ini.SetValue("Options","LastFile","");
ini.SetValue("UI","Columns",CreateColumnString(),true);
ini.SetValue("Options","BannerColor1",CreateColorString(BannerColor1),true);
ini.SetValue("Options","BannerColor2",CreateColorString(BannerColor2),true);
ini.SetValue("Options","BannerTextColor",CreateColorString(BannerTextColor),true);
ini.SetValue("UI","Columns",(const char*)CreateColumnString(),true);
ini.SetValue("Options","BannerColor1",(const char*)CreateColorString(BannerColor1),true);
ini.SetValue("Options","BannerColor2",(const char*)CreateColorString(BannerColor2),true);
ini.SetValue("Options","BannerTextColor",(const char*)CreateColorString(BannerTextColor),true);
ini.SetValueB("Options","ShowPasswords",ShowPasswords,true);
ini.SetValue("Options","UrlCmd",OpenUrlCommand,true);
ini.SetValue("Options","LangFile",Language,true);
ini.SetValue("Options","SearchOptions",CreateBoolString(SearchOptions,8),true);
ini.SetValue("Options","UrlCmd",(const char*)OpenUrlCommand,true);
ini.SetValue("Options","LangFile",(const char*)Language,true);
ini.SetValue("Options","SearchOptions",(const char*)CreateBoolString(SearchOptions,8),true);
ini.SetValueB("UI","HidePasswords",ListView_HidePasswords);
ini.SetValueB("UI","HideUsernames",ListView_HideUsernames);
ini.SetValue("Options","PwGenOptions",CreateBoolString(PwGenOptions,10),true);
ini.SetValue("Options","PwGenOptions",(const char*)CreateBoolString(PwGenOptions,10),true);
ini.SetValueI("Options","PwGenLength",PwGenLength,true);
ini.SetValue("Options","PwGenCharList",PwGenCharList,true);
ini.SetValue("Options","PwGenCharList",(const char*)PwGenCharList,true);
ini.SetValueB("Options","ExpandGroupTree",ExpandGroupTree,true);
ini.SetValueB("KDE Plugin","Enabled",EnableKdePlugin,true);
if(!ini.WriteFile())return false;
@ -102,15 +102,15 @@ return str;
QColor CConfig::ParseColorString(QString str){
QStringList lst=QStringList::split(',',str);
if(lst.size()!=3){
cout << QObject::trUtf8("Warnung:")+" CConfig::ParseColorString(QString):"+QObject::trUtf8("ungültiger RGB-Farbwert: ") << str << endl;
return QColor(0,0,0);}
qWarning(QObject::trUtf8("Warnung:")+" CConfig::ParseColorString(QString):"+QObject::trUtf8("ungültiger RGB-Farbwert.\n"));
return QColor(0,0,0);}
bool err[3];
int r=lst[0].toUInt(err);
int g=lst[1].toUInt(err+1);
int b=lst[2].toUInt(err+2);
if(!err[0] || !err[1] || !err[2]){
cout << QObject::trUtf8("Warnung:")+" CConfig::ParseColorString(QString):"+QObject::trUtf8("ungültiger RGB-Farbwert: ") << str << endl;
return QColor(0,0,0);}
qWarning(QObject::trUtf8("Warnung:")+" CConfig::ParseColorString(QString):"+QObject::trUtf8("ungültiger RGB-Farbwert.\n"));
return QColor(0,0,0);}
return QColor(r,g,b);
}

@ -40,7 +40,7 @@
#include "rijndael.h"
static UINT8 S[256]=
static Q_UINT8 S[256]=
{
99, 124, 119, 123, 242, 107, 111, 197, 48, 1, 103, 43, 254, 215, 171, 118,
202, 130, 201, 125, 250, 89, 71, 240, 173, 212, 162, 175, 156, 164, 114, 192,
@ -61,7 +61,7 @@ static UINT8 S[256]=
};
static UINT8 T1[256][4]=
static Q_UINT8 T1[256][4]=
{
0xc6,0x63,0x63,0xa5, 0xf8,0x7c,0x7c,0x84, 0xee,0x77,0x77,0x99, 0xf6,0x7b,0x7b,0x8d,
0xff,0xf2,0xf2,0x0d, 0xd6,0x6b,0x6b,0xbd, 0xde,0x6f,0x6f,0xb1, 0x91,0xc5,0xc5,0x54,
@ -129,7 +129,7 @@ static UINT8 T1[256][4]=
0x7b,0xb0,0xb0,0xcb, 0xa8,0x54,0x54,0xfc, 0x6d,0xbb,0xbb,0xd6, 0x2c,0x16,0x16,0x3a
};
static UINT8 T2[256][4]=
static Q_UINT8 T2[256][4]=
{
0xa5,0xc6,0x63,0x63, 0x84,0xf8,0x7c,0x7c, 0x99,0xee,0x77,0x77, 0x8d,0xf6,0x7b,0x7b,
0x0d,0xff,0xf2,0xf2, 0xbd,0xd6,0x6b,0x6b, 0xb1,0xde,0x6f,0x6f, 0x54,0x91,0xc5,0xc5,
@ -197,7 +197,7 @@ static UINT8 T2[256][4]=
0xcb,0x7b,0xb0,0xb0, 0xfc,0xa8,0x54,0x54, 0xd6,0x6d,0xbb,0xbb, 0x3a,0x2c,0x16,0x16
};
static UINT8 T3[256][4]=
static Q_UINT8 T3[256][4]=
{
0x63,0xa5,0xc6,0x63, 0x7c,0x84,0xf8,0x7c, 0x77,0x99,0xee,0x77, 0x7b,0x8d,0xf6,0x7b,
0xf2,0x0d,0xff,0xf2, 0x6b,0xbd,0xd6,0x6b, 0x6f,0xb1,0xde,0x6f, 0xc5,0x54,0x91,0xc5,
@ -265,7 +265,7 @@ static UINT8 T3[256][4]=
0xb0,0xcb,0x7b,0xb0, 0x54,0xfc,0xa8,0x54, 0xbb,0xd6,0x6d,0xbb, 0x16,0x3a,0x2c,0x16
};
static UINT8 T4[256][4]=
static Q_UINT8 T4[256][4]=
{
0x63,0x63,0xa5,0xc6, 0x7c,0x7c,0x84,0xf8, 0x77,0x77,0x99,0xee, 0x7b,0x7b,0x8d,0xf6,
0xf2,0xf2,0x0d,0xff, 0x6b,0x6b,0xbd,0xd6, 0x6f,0x6f,0xb1,0xde, 0xc5,0xc5,0x54,0x91,
@ -333,7 +333,7 @@ static UINT8 T4[256][4]=
0xb0,0xb0,0xcb,0x7b, 0x54,0x54,0xfc,0xa8, 0xbb,0xbb,0xd6,0x6d, 0x16,0x16,0x3a,0x2c
};
static UINT8 T5[256][4]=
static Q_UINT8 T5[256][4]=
{
0x51,0xf4,0xa7,0x50, 0x7e,0x41,0x65,0x53, 0x1a,0x17,0xa4,0xc3, 0x3a,0x27,0x5e,0x96,
0x3b,0xab,0x6b,0xcb, 0x1f,0x9d,0x45,0xf1, 0xac,0xfa,0x58,0xab, 0x4b,0xe3,0x03,0x93,
@ -401,7 +401,7 @@ static UINT8 T5[256][4]=
0x7b,0xcb,0x84,0x61, 0xd5,0x32,0xb6,0x70, 0x48,0x6c,0x5c,0x74, 0xd0,0xb8,0x57,0x42
};
static UINT8 T6[256][4]=
static Q_UINT8 T6[256][4]=
{
0x50,0x51,0xf4,0xa7, 0x53,0x7e,0x41,0x65, 0xc3,0x1a,0x17,0xa4, 0x96,0x3a,0x27,0x5e,
0xcb,0x3b,0xab,0x6b, 0xf1,0x1f,0x9d,0x45, 0xab,0xac,0xfa,0x58, 0x93,0x4b,0xe3,0x03,
@ -469,7 +469,7 @@ static UINT8 T6[256][4]=
0x61,0x7b,0xcb,0x84, 0x70,0xd5,0x32,0xb6, 0x74,0x48,0x6c,0x5c, 0x42,0xd0,0xb8,0x57
};
static UINT8 T7[256][4]=
static Q_UINT8 T7[256][4]=
{
0xa7,0x50,0x51,0xf4, 0x65,0x53,0x7e,0x41, 0xa4,0xc3,0x1a,0x17, 0x5e,0x96,0x3a,0x27,
0x6b,0xcb,0x3b,0xab, 0x45,0xf1,0x1f,0x9d, 0x58,0xab,0xac,0xfa, 0x03,0x93,0x4b,0xe3,
@ -537,7 +537,7 @@ static UINT8 T7[256][4]=
0x84,0x61,0x7b,0xcb, 0xb6,0x70,0xd5,0x32, 0x5c,0x74,0x48,0x6c, 0x57,0x42,0xd0,0xb8
};
static UINT8 T8[256][4]=
static Q_UINT8 T8[256][4]=
{
0xf4,0xa7,0x50,0x51, 0x41,0x65,0x53,0x7e, 0x17,0xa4,0xc3,0x1a, 0x27,0x5e,0x96,0x3a,
0xab,0x6b,0xcb,0x3b, 0x9d,0x45,0xf1,0x1f, 0xfa,0x58,0xab,0xac, 0xe3,0x03,0x93,0x4b,
@ -605,7 +605,7 @@ static UINT8 T8[256][4]=
0xcb,0x84,0x61,0x7b, 0x32,0xb6,0x70,0xd5, 0x6c,0x5c,0x74,0x48, 0xb8,0x57,0x42,0xd0
};
static UINT8 S5[256]=
static Q_UINT8 S5[256]=
{
0x52,0x09,0x6a,0xd5,
0x30,0x36,0xa5,0x38,
@ -673,7 +673,7 @@ static UINT8 S5[256]=
0x55,0x21,0x0c,0x7d
};
static UINT8 U1[256][4]=
static Q_UINT8 U1[256][4]=
{
0x00,0x00,0x00,0x00, 0x0e,0x09,0x0d,0x0b, 0x1c,0x12,0x1a,0x16, 0x12,0x1b,0x17,0x1d,
0x38,0x24,0x34,0x2c, 0x36,0x2d,0x39,0x27, 0x24,0x36,0x2e,0x3a, 0x2a,0x3f,0x23,0x31,
@ -741,7 +741,7 @@ static UINT8 U1[256][4]=
0x9f,0x5d,0x80,0xbe, 0x91,0x54,0x8d,0xb5, 0x83,0x4f,0x9a,0xa8, 0x8d,0x46,0x97,0xa3
};
static UINT8 U2[256][4]=
static Q_UINT8 U2[256][4]=
{
0x00,0x00,0x00,0x00, 0x0b,0x0e,0x09,0x0d, 0x16,0x1c,0x12,0x1a, 0x1d,0x12,0x1b,0x17,
0x2c,0x38,0x24,0x34, 0x27,0x36,0x2d,0x39, 0x3a,0x24,0x36,0x2e, 0x31,0x2a,0x3f,0x23,
@ -809,7 +809,7 @@ static UINT8 U2[256][4]=
0xbe,0x9f,0x5d,0x80, 0xb5,0x91,0x54,0x8d, 0xa8,0x83,0x4f,0x9a, 0xa3,0x8d,0x46,0x97
};
static UINT8 U3[256][4]=
static Q_UINT8 U3[256][4]=
{
0x00,0x00,0x00,0x00, 0x0d,0x0b,0x0e,0x09, 0x1a,0x16,0x1c,0x12, 0x17,0x1d,0x12,0x1b,
0x34,0x2c,0x38,0x24, 0x39,0x27,0x36,0x2d, 0x2e,0x3a,0x24,0x36, 0x23,0x31,0x2a,0x3f,
@ -877,7 +877,7 @@ static UINT8 U3[256][4]=
0x80,0xbe,0x9f,0x5d, 0x8d,0xb5,0x91,0x54, 0x9a,0xa8,0x83,0x4f, 0x97,0xa3,0x8d,0x46
};
static UINT8 U4[256][4]=
static Q_UINT8 U4[256][4]=
{
0x00,0x00,0x00,0x00, 0x09,0x0d,0x0b,0x0e, 0x12,0x1a,0x16,0x1c, 0x1b,0x17,0x1d,0x12,
0x24,0x34,0x2c,0x38, 0x2d,0x39,0x27,0x36, 0x36,0x2e,0x3a,0x24, 0x3f,0x23,0x31,0x2a,
@ -945,7 +945,7 @@ static UINT8 U4[256][4]=
0x5d,0x80,0xbe,0x9f, 0x54,0x8d,0xb5,0x91, 0x4f,0x9a,0xa8,0x83, 0x46,0x97,0xa3,0x8d
};
static UINT32 rcon[30]=
static Q_UINT32 rcon[30]=
{
0x01, 0x02, 0x04, 0x08, 0x10, 0x20,
0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8,
@ -970,7 +970,7 @@ Rijndael::~Rijndael()
// nothing here
}
int Rijndael::init(Mode mode,Direction dir,const UINT8 * key,KeyLength keyLen,UINT8 * initVector)
int Rijndael::init(Mode mode,Direction dir,const Q_UINT8 * key,KeyLength keyLen,Q_UINT8 * initVector)
{
// Not initialized yet
m_state = Invalid;
@ -999,7 +999,7 @@ int Rijndael::init(Mode mode,Direction dir,const UINT8 * key,KeyLength keyLen,UI
}
}
UINT32 uKeyLenInBytes;
Q_UINT32 uKeyLenInBytes;
// And check the key length
switch(keyLen)
@ -1025,9 +1025,9 @@ int Rijndael::init(Mode mode,Direction dir,const UINT8 * key,KeyLength keyLen,UI
if(!key) return RIJNDAEL_BAD_KEY;
UINT8 keyMatrix[_MAX_KEY_COLUMNS][4];
Q_UINT8 keyMatrix[_MAX_KEY_COLUMNS][4];
for(UINT32 i = 0;i < uKeyLenInBytes;i++)keyMatrix[i >> 2][i & 3] = key[i];
for(Q_UINT32 i = 0;i < uKeyLenInBytes;i++)keyMatrix[i >> 2][i & 3] = key[i];
keySched(keyMatrix);
@ -1038,10 +1038,10 @@ int Rijndael::init(Mode mode,Direction dir,const UINT8 * key,KeyLength keyLen,UI
return RIJNDAEL_SUCCESS;
}
int Rijndael::blockEncrypt(const UINT8 *input,int inputLen,UINT8 *outBuffer)
int Rijndael::blockEncrypt(const Q_UINT8 *input,int inputLen,Q_UINT8 *outBuffer)
{
int i, k, numBlocks;
UINT8 block[16], iv[4][4];
Q_UINT8 block[16], iv[4][4];
if(m_state != Valid) return RIJNDAEL_NOT_INITIALIZED;
if(m_direction != Encrypt) return RIJNDAEL_BAD_DIRECTION;
@ -1060,18 +1060,18 @@ int Rijndael::blockEncrypt(const UINT8 *input,int inputLen,UINT8 *outBuffer)
}
break;
case CBC:
((UINT32*)block)[0] = ((UINT32*)m_initVector)[0] ^ ((UINT32*)input)[0];
((UINT32*)block)[1] = ((UINT32*)m_initVector)[1] ^ ((UINT32*)input)[1];
((UINT32*)block)[2] = ((UINT32*)m_initVector)[2] ^ ((UINT32*)input)[2];
((UINT32*)block)[3] = ((UINT32*)m_initVector)[3] ^ ((UINT32*)input)[3];
((Q_UINT32*)block)[0] = ((Q_UINT32*)m_initVector)[0] ^ ((Q_UINT32*)input)[0];
((Q_UINT32*)block)[1] = ((Q_UINT32*)m_initVector)[1] ^ ((Q_UINT32*)input)[1];
((Q_UINT32*)block)[2] = ((Q_UINT32*)m_initVector)[2] ^ ((Q_UINT32*)input)[2];
((Q_UINT32*)block)[3] = ((Q_UINT32*)m_initVector)[3] ^ ((Q_UINT32*)input)[3];
encrypt(block,outBuffer);
input += 16;
for(i = numBlocks - 1;i > 0;i--)
{
((UINT32*)block)[0] = ((UINT32*)outBuffer)[0] ^ ((UINT32*)input)[0];
((UINT32*)block)[1] = ((UINT32*)outBuffer)[1] ^ ((UINT32*)input)[1];
((UINT32*)block)[2] = ((UINT32*)outBuffer)[2] ^ ((UINT32*)input)[2];
((UINT32*)block)[3] = ((UINT32*)outBuffer)[3] ^ ((UINT32*)input)[3];
((Q_UINT32*)block)[0] = ((Q_UINT32*)outBuffer)[0] ^ ((Q_UINT32*)input)[0];
((Q_UINT32*)block)[1] = ((Q_UINT32*)outBuffer)[1] ^ ((Q_UINT32*)input)[1];
((Q_UINT32*)block)[2] = ((Q_UINT32*)outBuffer)[2] ^ ((Q_UINT32*)input)[2];
((Q_UINT32*)block)[3] = ((Q_UINT32*)outBuffer)[3] ^ ((Q_UINT32*)input)[3];
outBuffer += 16;
encrypt(block,outBuffer);
input += 16;
@ -1081,19 +1081,19 @@ int Rijndael::blockEncrypt(const UINT8 *input,int inputLen,UINT8 *outBuffer)
#if STRICT_ALIGN
memcpy(iv,m_initVector,16);
#else /* !STRICT_ALIGN */
*((UINT32*)iv[0]) = *((UINT32*)(m_initVector ));
*((UINT32*)iv[1]) = *((UINT32*)(m_initVector + 4));
*((UINT32*)iv[2]) = *((UINT32*)(m_initVector + 8));
*((UINT32*)iv[3]) = *((UINT32*)(m_initVector +12));
*((Q_UINT32*)iv[0]) = *((Q_UINT32*)(m_initVector ));
*((Q_UINT32*)iv[1]) = *((Q_UINT32*)(m_initVector + 4));
*((Q_UINT32*)iv[2]) = *((Q_UINT32*)(m_initVector + 8));
*((Q_UINT32*)iv[3]) = *((Q_UINT32*)(m_initVector +12));
#endif /* ?STRICT_ALIGN */
for(i = numBlocks; i > 0; i--)
{
for(k = 0; k < 128; k++)
{
*((UINT32*) block ) = *((UINT32*)iv[0]);
*((UINT32*)(block+ 4)) = *((UINT32*)iv[1]);
*((UINT32*)(block+ 8)) = *((UINT32*)iv[2]);
*((UINT32*)(block+12)) = *((UINT32*)iv[3]);
*((Q_UINT32*) block ) = *((Q_UINT32*)iv[0]);
*((Q_UINT32*)(block+ 4)) = *((Q_UINT32*)iv[1]);
*((Q_UINT32*)(block+ 8)) = *((Q_UINT32*)iv[2]);
*((Q_UINT32*)(block+12)) = *((Q_UINT32*)iv[3]);
encrypt(block,block);
outBuffer[k/8] ^= (block[0] & 0x80) >> (k & 7);
iv[0][0] = (iv[0][0] << 1) | (iv[0][1] >> 7);
@ -1123,10 +1123,10 @@ int Rijndael::blockEncrypt(const UINT8 *input,int inputLen,UINT8 *outBuffer)
return 128 * numBlocks;
}
int Rijndael::padEncrypt(const UINT8 *input, int inputOctets, UINT8 *outBuffer)
int Rijndael::padEncrypt(const Q_UINT8 *input, int inputOctets, Q_UINT8 *outBuffer)
{
int i, numBlocks, padLen;
UINT8 block[16], *iv;
Q_UINT8 block[16], *iv;
if(m_state != Valid) return RIJNDAEL_NOT_INITIALIZED;
if(m_direction != Encrypt) return RIJNDAEL_NOT_INITIALIZED;
@ -1154,10 +1154,10 @@ int Rijndael::padEncrypt(const UINT8 *input, int inputOctets, UINT8 *outBuffer)
iv = m_initVector;
for(i = numBlocks; i > 0; i--)
{
((UINT32*)block)[0] = ((UINT32*)input)[0] ^ ((UINT32*)iv)[0];
((UINT32*)block)[1] = ((UINT32*)input)[1] ^ ((UINT32*)iv)[1];
((UINT32*)block)[2] = ((UINT32*)input)[2] ^ ((UINT32*)iv)[2];
((UINT32*)block)[3] = ((UINT32*)input)[3] ^ ((UINT32*)iv)[3];
((Q_UINT32*)block)[0] = ((Q_UINT32*)input)[0] ^ ((Q_UINT32*)iv)[0];
((Q_UINT32*)block)[1] = ((Q_UINT32*)input)[1] ^ ((Q_UINT32*)iv)[1];
((Q_UINT32*)block)[2] = ((Q_UINT32*)input)[2] ^ ((Q_UINT32*)iv)[2];
((Q_UINT32*)block)[3] = ((Q_UINT32*)input)[3] ^ ((Q_UINT32*)iv)[3];
encrypt(block, outBuffer);
iv = outBuffer;
input += 16;
@ -1169,7 +1169,7 @@ int Rijndael::padEncrypt(const UINT8 *input, int inputOctets, UINT8 *outBuffer)
block[i] = input[i] ^ iv[i];
}
for (i = 16 - padLen; i < 16; i++) {
block[i] = (UINT8)padLen ^ iv[i];
block[i] = (Q_UINT8)padLen ^ iv[i];
}
encrypt(block,outBuffer);
break;
@ -1181,10 +1181,10 @@ int Rijndael::padEncrypt(const UINT8 *input, int inputOctets, UINT8 *outBuffer)
return 16*(numBlocks + 1);
}
int Rijndael::blockDecrypt(const UINT8 *input, int inputLen, UINT8 *outBuffer)
int Rijndael::blockDecrypt(const Q_UINT8 *input, int inputLen, Q_UINT8 *outBuffer)