First commit for 0.2.3, some old functions still need to be ported to the new back-end api, i.e. import and export.

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@104 b624d157-de02-0410-bad0-e51aec6abb33
master
tarek_saidi 18 years ago
parent 0286b87a41
commit 21f0fea56a
  1. 14
      changelog
  2. BIN
      share/keepass/icons/keepassx.png
  3. BIN
      share/keepass/icons/keepassx_large.png
  4. BIN
      share/keepass/icons/key.png
  5. 39
      src/Database.cpp
  6. 436
      src/Database.h
  7. 1670
      src/PwManager.cpp
  8. 125
      src/PwManager.h
  9. 1543
      src/StandardDatabase.cpp
  10. 233
      src/StandardDatabase.h
  11. 197
      src/crypto/aes.h
  12. 130
      src/crypto/aes_edefs.h
  13. 891
      src/crypto/aes_modes.c
  14. 131
      src/crypto/aes_tdefs.h
  15. 153
      src/crypto/aescpp.h
  16. 316
      src/crypto/aescrypt.c
  17. 578
      src/crypto/aeskey.c
  18. 719
      src/crypto/aesopt.h
  19. 388
      src/crypto/aestab.c
  20. 186
      src/crypto/aestab.h
  21. 541
      src/crypto/blowfish.cpp
  22. 115
      src/crypto/blowfish.h
  23. 1605
      src/crypto/rijndael.cpp
  24. 158
      src/crypto/rijndael.h
  25. 257
      src/crypto/sha1.cpp
  26. 99
      src/crypto/sha1.h
  27. 251
      src/crypto/sha256.cpp
  28. 59
      src/crypto/sha256.h
  29. 1
      src/crypto/twoclass.h
  30. 420
      src/crypto/yarrow.cpp
  31. 190
      src/crypto/yarrow.h
  32. 88
      src/crypto/yarrow_macros.h
  33. 13
      src/dialogs/DatabaseSettingsDlg.cpp
  34. 4
      src/dialogs/DatabaseSettingsDlg.h
  35. 430
      src/dialogs/EditEntryDlg.cpp
  36. 79
      src/dialogs/EditEntryDlg.h
  37. 81
      src/dialogs/EditGroupDlg.cpp
  38. 17
      src/dialogs/EditGroupDlg.h
  39. 155
      src/dialogs/PasswordDlg.cpp
  40. 1
      src/dialogs/PasswordDlg.h
  41. 85
      src/dialogs/SearchDlg.cpp
  42. 18
      src/dialogs/SearchDlg.h
  43. 142
      src/dialogs/SelectIconDlg.cpp
  44. 14
      src/dialogs/SelectIconDlg.h
  45. 12
      src/dialogs/SettingsDlg.cpp
  46. 5
      src/export/Export_Txt.cpp
  47. 4
      src/export/Export_Txt.h
  48. 698
      src/forms/EditEntryDlg.ui
  49. 99
      src/forms/MainWindow.ui
  50. 9
      src/import/Import_KWalletXml.cpp
  51. 4
      src/import/Import_KWalletXml.h
  52. 15
      src/import/Import_PwManager.cpp
  53. 11
      src/import/Import_PwManager.h
  54. 4
      src/lib/AutoType.h
  55. 4
      src/lib/AutoType_Win.cpp
  56. 36
      src/lib/AutoType_X11.cpp
  57. 468
      src/lib/EntryView.cpp
  58. 102
      src/lib/EntryView.h
  59. 529
      src/lib/GroupView.cpp
  60. 95
      src/lib/GroupView.h
  61. 5
      src/lib/SecString.cpp
  62. 45
      src/lib/SecString.h
  63. 104
      src/main.cpp
  64. 7
      src/main.h
  65. 925
      src/mainwindow.cpp
  66. 48
      src/mainwindow.h
  67. 32
      src/src.pro

@ -1,3 +1,17 @@
---------------
0.2.3
---------------
-fixed to long Auto-Type delay
-fixed wrong text color in the password repeation box when using new Qt versions (Bug #???)
-fixed problem with the assignment of group icons (custom icons metastream format rev 3)
-more stable drag&drop implementation which also works under MacOSX
-new more robust and flexible database back-end api
-replaced old AES implementation by the latest version of Brian Gladman's implementation.
-now using strong random number generator 'yarrow' instead of the standard library functions.
-final program icon
---------------
0.2.2
---------------

Binary file not shown.

Before

Width:  |  Height:  |  Size: 806 B

After

Width:  |  Height:  |  Size: 898 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

@ -87,49 +87,18 @@ else return date().toString(format);
CEntry::CEntry(){
ImageID=0;
OldImgID=0;
GroupID=0;
Image=0;
GroupId=0;
Creation=QDateTime::currentDateTime();
LastMod=QDateTime::currentDateTime();
LastAccess=QDateTime::currentDateTime();
Expire=QDateTime(QDate(2999,12,28),QTime(23,59,59)); //Never
BinaryData=QByteArray();
Binary=QByteArray();
}
bool CGroup::UI_ExpandByDefault=true;
bool CEntry::operator==(const CEntry& e)const{
if(sID==e.sID)return true;
else return false;
}
bool CGroup::operator==(const CGroup& g)const{
if(ID==g.ID)return true;
else return false;
}
CGroup::CGroup(){
Creation=QDateTime::currentDateTime();
LastAccess=QDateTime::currentDateTime();
LastMod=QDateTime::currentDateTime();
Expire=QDateTime(QDate(2999,12,28),QTime(23,59,59));
Level=0;
ImageID=0;
OldImgID=0;
Name="<Group>";
UI_ItemIsExpanded=UI_ExpandByDefault;
}
CGroup::~CGroup(){
Image=0;
}
CEntry::~CEntry(){
}
Database::Database(){
file=NULL;
KeyEncRounds=6000;
CryptoAlgorithmus=ALGO_AES;
}

@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2005-2006 by Tarek Saidi *
* mail@tarek-saidi.de *
* tarek.saidi@arcor.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@ -17,6 +17,7 @@
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef _DATABASE_H_
#define _DATABASE_H_
@ -30,6 +31,15 @@ using namespace std;
extern const QDateTime Date_Never;
typedef enum CryptAlgorithm{
Rijndael_Cipher=0,
Twofish_Cipher=1
};
//! Universally Unique Identifier Class.
/*!
Provides generation, serialization, deserialization and comparison of UUIDs.
*/
class KpxUuid{
public:
KpxUuid();
@ -46,122 +56,344 @@ private:
QByteArray Data;
};
//! Advanced DateTime Class.
/*!
This class advances the standard Qt class 'QDateTime' with KeePassX specific methods for string conversion.
*/
class KpxDateTime:public QDateTime{
public:
KpxDateTime(){};
KpxDateTime ( const QDate & date ):QDateTime(date){};
KpxDateTime ( const QDate & date, const QTime & time, Qt::TimeSpec spec = Qt::LocalTime):QDateTime(date,time,spec){};
KpxDateTime ( const QDateTime & other ):QDateTime(other){};
virtual QString toString(Qt::DateFormat format = Qt::TextDate ) const;
QString dateToString(Qt::DateFormat format = Qt::TextDate)const;
public:
KpxDateTime(){};
KpxDateTime ( const QDate & date ):QDateTime(date){};
KpxDateTime ( const QDate & date, const QTime & time, Qt::TimeSpec spec = Qt::LocalTime):QDateTime(date,time,spec){};
KpxDateTime ( const QDateTime & other ):QDateTime(other){};
//! Returns a string representation of the DateTime object in the given format or "Never" if the DateTime value is 28.12.2999 23:59:59.
virtual QString toString(Qt::DateFormat format = Qt::TextDate ) const;
//! Returns a string representation of the date part of the DateTime object in the given format or "Never" if the DateTime value is 28.12.2999 23:59:59.
QString dateToString(Qt::DateFormat format = Qt::TextDate)const;
};
//! Entry Data Structure
/*! This class holds the data of a normal database entry. It is used by some interface functions to process predefined entries and can be used for internal data handling.*/
class CEntry{
public:
CEntry();
~CEntry();
KpxUuid Uuid;
quint32 sID;
quint32 GroupID;
quint32 ImageID;
quint32 OldImgID;
QString Title;
QString URL;
QString UserName;
SecString Password;
QString Additional;
QString BinaryDesc;
KpxDateTime Creation;
KpxDateTime LastMod;
KpxDateTime LastAccess;
KpxDateTime Expire;
QByteArray BinaryData;
/*quint32 PasswordLength;*/
bool ReadEntryField(quint16 FieldType, quint32 FieldSize, quint8 *pData);
bool operator==(const CEntry&) const;
CEntry();
KpxUuid Uuid;
quint32 GroupId;
quint32 Image;
QString Title;
QString Url;
QString Username;
SecString Password;
QString Comment;
QString BinaryDesc;
KpxDateTime Creation;
KpxDateTime LastMod;
KpxDateTime LastAccess;
KpxDateTime Expire;
QByteArray Binary;
bool operator==(const CEntry& other) const;
};
//! Group Data Structure
/*! This class holds the data of a normal database group. It is used by some interface functions to process predefined groups and can be used for internal data handling.*/
class CGroup{
public:
CGroup();
~CGroup();
quint32 ID;
quint32 ImageID;
quint32 OldImgID;
QString Name;
QDateTime Creation;
QDateTime LastMod;
QDateTime LastAccess;
QDateTime Expire;
quint16 Level;
quint32 Flags;
bool ReadGroupField(quint16 FieldType, quint32 FieldSize, quint8 *pData);
bool operator==(const CGroup&) const;
bool UI_ItemIsExpanded;
static bool UI_ExpandByDefault;
CGroup();
quint32 Id;
quint32 Image;
QString Title;
bool operator==(const CGroup& other) const;
};
class IGroupHandle;
class IEntryHandle;
//! Handle class interface for accessing entries
/*!
The IEntryHandle interface provides access to Entry data structures without using direct references. Every entry handle class must implement this interface necessarily.
*/
class IEntryHandle{
public:
virtual void setImage(const quint32& ImageID)=0;
virtual void setOldImage(const quint32& OldImgID)=0;
virtual void setTitle(const QString& Title)=0;
virtual void setUrl(const QString& URL)=0;
virtual void setUsername(const QString& Username)=0;
virtual void setPassword(const SecString& Password)=0;
virtual void setComment(const QString& Comment)=0;
virtual void setBinaryDesc(const QString& BinaryDesc)=0;
virtual void setCreation(const KpxDateTime& Creation)=0;
virtual void setLastMod(const KpxDateTime& LastMod)=0;
virtual void setLastAccess(const KpxDateTime& LastAccess)=0;
virtual void setExpire(const KpxDateTime& Expire)=0;
virtual void setBinary(const QByteArray& BinaryData)=0;
virtual KpxUuid uuid()=0;
virtual IGroupHandle* group()=0;
virtual quint32 image()=0;
virtual quint32 oldImage()=0;
virtual QString title()=0;
virtual QString url()=0;
virtual QString username()=0;
virtual SecString password()=0;
virtual QString comment()=0;
virtual QString binaryDesc()=0;
virtual KpxDateTime creation()=0;
virtual KpxDateTime lastMod()=0;
virtual KpxDateTime lastAccess()=0;
virtual KpxDateTime expire()=0;
virtual QByteArray binary()=0;
virtual quint32 binarySize()=0;
//! \return the index of the entry amongst the entries of its group. The index of the first entry is 0.
virtual int index()const=0;
/*! Tests the validity of the handle.
\return TRUE if the handle is valid and FALSE if the handle is invalid e.g. because the associated entry was deleted.*/
virtual bool isValid()const=0;
virtual bool operator<(const IEntryHandle*& other)=0;
};
//! Custom Icon Interface
/*!
This class provides an interface for the management of custom icons. The implementation is optional and not necessarily needed.
*/
class ICustomIcons:public QObject{
Q_OBJECT
public:
/*! Adds a new custom icon to the database.
\param icon The pixmap which contains the new icon. This function makes a copy of the given pixmap.
*/
virtual void addIcon(const QPixmap& icon)=0;
/*! Removes an icon.
\param index The index of the icon which should be removed. Built-in icons cannot be removed so make sure that index is not the index of an Built-in icon before calling this function.
*/
virtual void removeIcon(int index)=0;
/*! Replaces one icon with another one.
\param index The index of the icon which should be replaced. Built-in icons cannot be replaced so make sure that index is not the index of an Built-in icon before calling this function.
\param icon The pixmap which contains the new icon.
*/
virtual void replaceIcon(int index,const QPixmap& icon)=0;
signals:
/*! This signal is emitted when an icon was modified.
That means it is emitted after every call off addIcon(), removeIcon() and replaceIcon().
*/
void iconsModified();
};
#define ALGO_AES 0
#define ALGO_TWOFISH 1
class Database:public QObject{
//! Handle class interface for accessing groups
/*!
The IGroupHandle interface provides access to CGroup data structures without using direct references. Every entry handle class must implement this interface necessarily.
*/
class IGroupHandle{
public:
virtual void setTitle(const QString& Title)=0;
virtual void setImage(const quint32& ImageID)=0;
virtual QString title()=0;
virtual quint32 image()=0;
//! \return a pointer to the handle of the parent group or NULL if the group has no parent.
virtual IGroupHandle* parent()=0;
//! \return a List of pointers to the handles of all childs of the group and an empty list if the group has no childs. The list is sorted and starts with the first child.
virtual QList<IGroupHandle*> childs()=0;
//! \return the index of the group amongst the childs of its parent. The index of the first child is 0.
virtual int index()=0;
/*! Sets the index of a group amongst the childs of its parent.
This function can be used to sort the groups of the database in a specific order.
\param index The new index of the group. The indices of the other groups which are affected by this operation will be automatically adjusted.*/
virtual void setIndex(int index)=0;
/*! Tests the validity of the handle.
\return TRUE if the handle is valid and FALSE if the handle is invalid e.g. because the associated group was deleted.*/
virtual bool isValid()=0;
/*! \return the level of the group in the group tree. This level is tantamount to the number of parents that the group has. */
virtual int level()=0;
};
//! Common Database Interface.
/*!
This is the common base interface for databases. Every database class must implement this interface necessarily.
*/
class IDatabase{
public:
Database();
virtual ~Database(){};
virtual bool openDatabase(QString filename, QString& err)=0;
virtual bool saveDatabase()=0;
virtual bool closeDatabase()=0;
virtual void newDatabase()=0;
virtual bool CalcMasterKeyByPassword(QString& password)=0;
virtual bool CalcMasterKeyByFile(QString filename)=0;
virtual bool CalcMasterKeyByFileAndPw(QString filename, QString& password)=0;
virtual bool createKeyFile(const QString& filename)=0;
virtual CGroup& group(unsigned long index)=0;
virtual void setGroup(unsigned long index,CGroup& group)=0;
virtual int numGroups()=0;
virtual CGroup* addGroup(CGroup* parent)=0;
virtual void deleteGroup(CGroup* pGroup)=0;
virtual void deleteGroup(unsigned long ID)=0;
virtual void moveGroup(CGroup* group, CGroup* DstGroup, int pos=-1)=0;
virtual void moveGroupDirectly(CGroup* group, CGroup* DstGroup)=0; //inserts group directly behind DstGroup on the same level
virtual int getGroupIndex(CGroup* group)=0;
virtual int getGroupIndex(unsigned long ID)=0;
virtual int getNumberOfChilds(CGroup* pGroup)=0;
virtual QList<int> getChildIds(CGroup* pGroup)=0;
virtual CEntry& entry(unsigned long index)=0;
virtual void setEntry(unsigned long index,CEntry& Entry)=0;
virtual int numEntries()=0;
virtual CEntry* cloneEntry(CEntry* pEntry)=0;
virtual void deleteEntry(CEntry* pEntry)=0;
virtual void moveEntry(CEntry* pEntry,CGroup* pDstGroup)=0;
virtual CEntry* addEntry()=0;
virtual CEntry* addEntry(CEntry* NewEntry)=0;
virtual void merge(Database* db2)=0;
virtual bool isParentGroup(CGroup* Group,CGroup* PotenialParent)=0;
virtual QString getError()=0; //get first error
virtual QString getErrors()=0; //get all errors in a \n seperated String
virtual QPixmap& icon(int index)=0;
virtual int numIcons()=0;
virtual void addIcon(const QPixmap& icon)=0;
virtual void removeIcon(int Id)=0;
virtual void replaceIcon(int Id,const QPixmap& icon)=0;
quint32 CryptoAlgorithmus;
quint32 KeyEncRounds;
QFile* file;
bool modflag;
int SearchGroupID;
protected:
quint8 MasterKey[32];
quint8 TransformedMasterKey[32];
//! Loads a database.
/*! It is not allowed to call this function if a database is already loaded.
\param identifier Normally this is the filename of the database but it can also be an IP address or something else if the database is not file based.
\return TRUE if loading was successfull, otherwise FALSE.
*/
virtual bool load(QString identifier)=0;
//! Saves the current database.
/*! It is not allowed to call this function if no database is loaded.
\return TRUE if saving was successfull, otherwise FALSE.
*/
virtual bool save()=0;
//! Closes the current database.
/*! After a call of this function the database object can be used to load another database.
It is not allowed to call this function if no database is loaded.
Please note: The database will be closed without saving it in before.
* \return TRUE if closing was successfull, otherwise FALSE.
*/
virtual bool close()=0;
//! Creates a new database.
/*! It is not allowed to call this function if a database is already loaded.
\return TRUE if saving was successfull, otherwise FALSE.
*/
virtual void create()=0;
virtual bool changeFile(const QString& filename)=0;
virtual QFile* file()=0;
//! \return a list with the pointers to the handles of all entries of the database. The list contains only valid handles. The list is not sorted.
virtual QList<IEntryHandle*> entries()=0;
//! \param Group The group which contains the wanted entries.
//! \return a list of pointers to the handles of all entries which belong to the given group. The list contains only valid handles and is sorted in an ascending order regarding to the entry indices.
virtual QList<IEntryHandle*> entries(IGroupHandle* Group)=0;
//! \return a list with the pointers to the handles of all entries of the database. The list contains only valid handles and is not sorted.
virtual QList<IGroupHandle*> groups()=0;
/*!
This function might be slower than groups() - denpending on the implementation.
\return a list with the pointers to the handles of all entries of the database. The list ist sorted and contains only valid handles.*/
virtual QList<IGroupHandle*> sortedGroups()=0;
/*! \return the last error message or an empty QString() object if no error occured.*/
virtual QString getError()=0;
/*! Creates a clone of a given entry.
All attributes besides the UUID are copied, even the creation date.
\param entry The handle of the entry which should be cloned.
\return a pointer to the handle of the cloned entry.
*/
virtual IEntryHandle* cloneEntry(const IEntryHandle* entry)=0;
/*! Deletes a given entry.
\param entry The handle of the entry which should be deleted.
*/
virtual void deleteEntry(IEntryHandle* entry)=0;
/*! Deletes the last added entry.
This function should only be called immediately after an addEntry() call, otherwise the behavior is undefined. Immediately means that there are no other add/move/delete operations between the two function calls.*/
virtual void deleteLastEntry()=0;
/*! Deletes multiple given entries.
Calling this function can be faster then calling deleteEntry(..) several times - depending on the implementation.
Important: All entries must belong to the same group!
\param entries A pointer list of handles of the entries which sould be deleted. The list can be empty therefore no prior testing is necessary.*/
virtual void deleteEntries(QList<IEntryHandle*> entries)=0;
/*! Creates a new blank entry.
\param Group The group to which the entry should be added.
\return the handle of the new entry.
*/
virtual IEntryHandle* newEntry(IGroupHandle* Group)=0;
/*! Adds a Entry object to the database.
\param Group The group to which the entry should be added.
\param NewEntry The new entry. It is important that the new entry object has a valid UUID!
\return a pointer to the handle of the added entry.
*/
virtual IEntryHandle* addEntry(const CEntry* NewEntry, IGroupHandle* Group)=0;
/*! Moves an entry to another group.
\param entry The entry which should be moved.
\param group The new group of the entry.*/
virtual void moveEntry(IEntryHandle* entry, IGroupHandle* group)=0;
/*! Removes a group from the database.
Deletes the group, all it's entries and child groups and their entries as well.
\param group The group which should be deleted.*/
virtual void deleteGroup(IGroupHandle* group)=0;
/*! Adds a group to the database.
\param Group A pointer to a CGroup object. Id and ParentId of the object are ignored.
\param Parent A pointer to the handle of parent of the group. Can be NULL if the group is a top-level group.
\return a pointer to the handle of the added group.*/
virtual IGroupHandle* addGroup(const CGroup* Group,IGroupHandle* Parent)=0;
/*! Moves a group.
\param Group The group which should be moved.
\param NewParent The new parent of the group.
\param Position The position of the group amongst it's new siblings. If Position is 0 the group will be prepended if it is -1 the group will be appended.*/
virtual void moveGroup(IGroupHandle* Group,IGroupHandle* NewParent,int Position)=0;
/*! Checks two given groups if one is the parent of the other.
\param Child The child group.
\param Parent The parent group.
\return TRUE if Parent is the parent of child, otherwise FALSE.*/
virtual bool isParent(IGroupHandle* parent, IGroupHandle* child)=0;
/*! \param index Index of the requested icon.
\return a reference to the pixmap of the requested icon.
*/
virtual QPixmap& icon(int index)=0;
//! \return the number of icons provided by the database. This number can vary at runtime if the database supports custom icons.
virtual int numIcons()=0;
/*! Deletes all old invalid handles of the database.
Make sure that there are no pointers to those handles which are still in use before calling this function.*/
virtual void cleanUpHandles()=0;
/*! \return the number of groups in the database.*/
virtual int numGroups()=0;
/*! \return the number of entires in the database.*/
virtual int numEntries()=0;
/*! \return the number of built-in icons of the database. Each database must contain at least one built-in icon. */
virtual int builtinIcons()=0;
/*! Searches in the database for a string or regular expression.
\param Group The group where the search should be performed in. If Group is NULL the search will be performed in the whole database.
\param SearchString The searched string or a regular expression.
\param CaseSensitvie If this parameter is true the search will be case sensitive.
\param RegExp The SearchString parameter will be handled as regular expression if this parameter is true.
\param Recursive Defines whether the search should include subgroups of Group or not. This parameter has no effect if Group is NULL.
\param Fields A pointer to a six element bool array. It defines which fields are included into the search. The order is: title, username, url, password, comment, attachment description. The pointer can also be NULL, than the default pattern is used instead.
\return the search results as a list of pointers to the entry handles.*/
virtual QList<IEntryHandle*> search(IGroupHandle* Group,const QString& SearchString, bool CaseSensitve, bool RegExp,bool Recursive,bool* Fields)=0;
};
//! Interface for password/file based authentication
class IFilePasswordAuth{
public:
virtual void authByPwd(QString& password)=0;
virtual bool authByFile(QFile& file)=0;
virtual bool authByFileAndPwd(QString& password, QFile& file)=0;
/*! Creates a key file.
\param filename Filename of the new key file.
\param length Length of the key file.
\param Hex Wether the key file should be binary or hexadecimal ASCII code. If Hex is true the real file size will be double of length.
\return TRUE if the creation was successfull, otherwise FALSE.
*/
virtual bool createKeyFile(const QString& filename,int length=32, bool Hex=false)=0;
};
#endif

File diff suppressed because it is too large Load Diff

@ -1,125 +0,0 @@
/***************************************************************************
* Copyright (C) 2005-2006 by Tarek Saidi *
* tarek.saidi@arcor.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef _PW_MANAGER_H_
#define _PW_MANAGER_H_
#define DB_HEADER_SIZE 124
#define PWM_DBSIG_1 0x9AA2D903
#define PWM_DBSIG_2 0xB54BFB65
#define PWM_DBVER_DW 0x00030002
#define PWM_FLAG_SHA2 1
#define PWM_FLAG_RIJNDAEL 2
#define PWM_FLAG_ARCFOUR 4
#define PWM_FLAG_TWOFISH 8
#define PWM_STD_KEYENCROUNDS 6000
#include <qcolor.h>
#include <qobject.h>
#include <QDateTime>
#include <QDate>
#include <QTime>
#include <QStringList>
#include <QPixmap>
#include "lib/SecString.h"
#include "Database.h"
class PwDatabase:public Database{
Q_OBJECT
public:
PwDatabase();
bool openDatabase(QString filename, QString& err);
bool saveDatabase();
bool closeDatabase();
void newDatabase();
bool CalcMasterKeyByPassword(QString& password);
bool CalcMasterKeyByFile(QString filename);
bool CalcMasterKeyByFileAndPw(QString filename, QString& password);
bool createKeyFile(const QString& filename);
CGroup& group(unsigned long index);
void setGroup(unsigned long index,CGroup& group);
int numGroups();
CGroup* addGroup(CGroup* parent);
void deleteGroup(CGroup* pGroup);
void deleteGroup(unsigned long ID);
void moveGroup(CGroup* group, CGroup* DstGroup, int pos=-1);
void moveGroupDirectly(CGroup* group, CGroup* DstGroup); //inserts group directly behind DstGroup on the same level
int getGroupIndex(CGroup* group);
int getGroupIndex(unsigned long ID);
int getNumberOfChilds(CGroup* pGroup);
QList<int> getChildIds(CGroup* pGroup);
CEntry& entry(unsigned long index);
CEntry* getEntry(const KpxUuid& uuid);
void setEntry(unsigned long index,CEntry& Entry);
int numEntries();
CEntry* cloneEntry(CEntry* pEntry);
void deleteEntry(CEntry* pEntry);
void moveEntry(CEntry* pEntry,CGroup* pDstGroup);
CEntry* addEntry();
CEntry* addEntry(CEntry* NewEntry);
void merge(Database* db2);
bool isParentGroup(CGroup* Group,CGroup* PotenialParent);
QString getError(); //get first error
QString getErrors(); //get all errors in a \n seperated String
QPixmap& icon(int index);
int numIcons();
void addIcon(const QPixmap& icon);
void removeIcon(int Id);
void replaceIcon(int Id,const QPixmap& icon);
QList<CGroup>Groups;
QList<CEntry>Entries;
private:
bool IsMetaStream(CEntry& Entry);
bool parseMetaStream(const CEntry& Entry);
bool parseCustomIconsMetaStream(const QByteArray& data);
bool parseCustomIconsMetaStreamV1(const QByteArray& data);
void createCustomIconsMetaStream(CEntry* dst);
void transformKey(quint8* src,quint8* dst,quint8* seed,int rounds);
bool readHeader(char* raw);
bool isGroupIdInUse(quint32 GroupID);
bool isEntrySidInUse(quint32 sID);
quint32 getNewGroupId();
quint32 getNewEntrySid();
bool convHexToBinaryKey(char* HexKey, char* dst);
QStringList Errors;
QList<QPixmap> CustomIcons;
QList<CEntry> UnkownMetaStreams;
signals:
void iconsModified();
};
void memcpyFromLEnd32(quint32* dst,const char* src);
void memcpyFromLEnd16(quint16* dst,const char* src);
void memcpyToLEnd32(char* src,const quint32* dst);
void memcpyToLEnd16(char* src,const quint16* dst);
QDateTime dateFromPackedStruct5(const unsigned char* pBytes);
void dateToPackedStruct5(const QDateTime& datetime, unsigned char* dst);
bool testDatabase();
#endif

File diff suppressed because it is too large Load Diff

@ -0,0 +1,233 @@
/***************************************************************************
* Copyright (C) 2005-2006 by Tarek Saidi *
* keepassx@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef _STD_DATABASE_H_
#define _STD_DATABASE_H_
#define DB_HEADER_SIZE 124
#define PWM_DBSIG_1 0x9AA2D903
#define PWM_DBSIG_2 0xB54BFB65
#define PWM_DBVER_DW 0x00030002
#define PWM_FLAG_SHA2 1
#define PWM_FLAG_RIJNDAEL 2
#define PWM_FLAG_ARCFOUR 4
#define PWM_FLAG_TWOFISH 8
#define PWM_STD_KEYENCROUNDS 6000
#include <qcolor.h>
#include <qobject.h>
#include <QDateTime>
#include <QDate>
#include <QTime>
#include <QStringList>
#include <QPixmap>
#include "lib/SecString.h"
#include "Database.h"
void memcpyFromLEnd32(quint32* dst,const char* src);
void memcpyFromLEnd16(quint16* dst,const char* src);
void memcpyToLEnd32(char* src,const quint32* dst);
void memcpyToLEnd16(char* src,const quint16* dst);
//! Implementation of the standard KeePassX database.
class StandardDatabase:public ICustomIcons,public IDatabase, public IFilePasswordAuth{
Q_OBJECT
public:
class StdGroup;
class StdEntry;
class EntryHandle:public IEntryHandle{
friend class StandardDatabase;
public:
EntryHandle(StandardDatabase* db);
virtual void setImage(const quint32& ImageID);
void setOldImage(const quint32& OldImgID);
virtual void setTitle(const QString& Title);
virtual void setUrl(const QString& URL);
virtual void setUsername(const QString& Username);
virtual void setPassword(const SecString& Password);
virtual void setComment(const QString& Comment);
virtual void setBinaryDesc(const QString& BinaryDesc);
virtual void setCreation(const KpxDateTime& Creation);
virtual void setLastMod(const KpxDateTime& LastMod);
virtual void setLastAccess(const KpxDateTime& LastAccess);
virtual void setExpire(const KpxDateTime& Expire);
virtual void setBinary(const QByteArray& BinaryData);
virtual KpxUuid uuid();
virtual IGroupHandle* group();
virtual quint32 image();
virtual int index() const;
quint32 oldImage();
virtual QString title();
virtual QString url();
virtual QString username();
virtual SecString password();
virtual QString comment();
virtual QString binaryDesc();
virtual KpxDateTime creation();
virtual KpxDateTime lastMod();
virtual KpxDateTime lastAccess();
virtual KpxDateTime expire();
virtual QByteArray binary();
virtual quint32 binarySize();
virtual bool isValid() const;
virtual bool operator<(const IEntryHandle*& other);
private:
void invalidate(){valid=false;}
bool valid;
unsigned int ListIndex;
KpxUuid Uuid;
StandardDatabase* pDB;
StdEntry* Entry;
};
class GroupHandle:public IGroupHandle{
friend class StandardDatabase;
GroupHandle(StandardDatabase* db);
public:
virtual void setTitle(const QString& Title);
virtual void setImage(const quint32& ImageId);
void setOldImage(const quint32& ImageId);
virtual QString title();
virtual quint32 image();
quint32 oldImage();
virtual bool isValid();
virtual IGroupHandle* parent();
virtual QList<IGroupHandle*> childs();
virtual int index();
virtual void setIndex(int index);
virtual int level();
private:
void invalidate(){valid=false;}
bool valid;
StdGroup* Group;
StandardDatabase* pDB;
};
friend class EntryHandle;
friend class GroupHandle;
class StdEntry:public CEntry{
public:
quint32 OldImage;
quint16 Index;
EntryHandle* Handle;
StdGroup* Group;
};
class StdGroup:public CGroup{
public:
StdGroup():CGroup(){};
StdGroup(const CGroup&);
quint32 OldImage;
quint16 Index;
StdGroup* Parent;
GroupHandle* Handle;
QList<StdGroup*> Childs;
QList<StdEntry*> Entries;
};
virtual bool load(QString identifier);
virtual bool save();
virtual bool close();
virtual void create();
virtual int numEntries();
virtual int numGroups();
virtual QString getError();
virtual void cleanUpHandles();
virtual QPixmap& icon(int index);
virtual int numIcons();
virtual void addIcon(const QPixmap& icon);
virtual void removeIcon(int index);
virtual void replaceIcon(int index,const QPixmap& icon);
virtual int builtinIcons(){return 62;};
virtual void authByPwd(QString& password);
virtual bool authByFile(QFile& file);
virtual bool authByFileAndPwd(QString& password, QFile& file);
virtual bool createKeyFile(const QString& filename,int length=32, bool Hex=false);
virtual QList<IEntryHandle*> search(IGroupHandle* Group,const QString& SearchString, bool CaseSensitve, bool RegExp,bool Recursive,bool* Fields);
virtual QFile* file(){return File;}
virtual bool changeFile(const QString& filename);
virtual QList<IEntryHandle*> entries();
virtual QList<IEntryHandle*> entries(IGroupHandle* Group);
virtual IEntryHandle* cloneEntry(const IEntryHandle* entry);
virtual void deleteEntry(IEntryHandle* entry);
virtual void deleteEntries(QList<IEntryHandle*> entries);
virtual IEntryHandle* newEntry(IGroupHandle* group);
virtual IEntryHandle* addEntry(const CEntry* NewEntry, IGroupHandle* group);
virtual void moveEntry(IEntryHandle* entry, IGroupHandle* group);
virtual void deleteLastEntry();
virtual QList<IGroupHandle*> groups();
virtual QList<IGroupHandle*> sortedGroups();
virtual void deleteGroup(IGroupHandle* group);
virtual void moveGroup(IGroupHandle* Group,IGroupHandle* NewParent,int Position);
virtual IGroupHandle* addGroup(const CGroup* Group,IGroupHandle* Parent);
virtual bool isParent(IGroupHandle* parent, IGroupHandle* child);
private:
QDateTime dateFromPackedStruct5(const unsigned char* pBytes);
void dateToPackedStruct5(const QDateTime& datetime, unsigned char* dst);
bool isMetaStream(StdEntry& Entry);
bool parseMetaStream(const StdEntry& Entry);
bool parseCustomIconsMetaStream(const QByteArray& data);
bool parseCustomIconsMetaStreamV1(const QByteArray& data);
bool parseCustomIconsMetaStreamV2(const QByteArray& data);
bool readEntryField(StdEntry* entry, quint16 FieldType, quint32 FieldSize, quint8 *pData);
bool readGroupField(StdGroup* group,QList<quint32>& Levels,quint16 FieldType, quint32 FieldSize, quint8 *pData);
bool createGroupTree(QList<quint32>& Levels);
void createHandles();
bool transformKey(quint8* src,quint8* dst,quint8* KeySeed,int rounds);
void invalidateHandle(StdEntry* entry);
bool convHexToBinaryKey(char* HexKey, char* dst);
quint32 getNewGroupId();
void serializeEntries(QList<StdEntry>& EntryList,char* buffer,unsigned int& pos);
void serializeGroups(QList<StdGroup>& GroupList,char* buffer,unsigned int& pos);
void createCustomIconsMetaStream(StdEntry* e);
void appendChildsToGroupList(QList<StdGroup*>& list,StdGroup& group);
void appendChildsToGroupList(QList<IGroupHandle*>& list,StdGroup& group);
bool searchStringContains(const QString& search, const QString& string,bool Cs, bool RegExp);
void getEntriesRecursive(IGroupHandle* Group, QList<IEntryHandle*>& EntryList);
void rebuildIndices(QList<StdGroup*>& list);
StdEntry* getEntry(const KpxUuid& uuid);
StdEntry* getEntry(EntryHandle* handle);
int getEntryListIndex(EntryHandle* handle);
EntryHandle* getHandle(StdEntry* entry);
StdGroup* getGroup(quint32 Id);
void deleteGroup(StdGroup* group);
QList<EntryHandle> EntryHandles;
QList<GroupHandle> GroupHandles;
QList<StdEntry> Entries;
QList<StdGroup> Groups;
StdGroup RootGroup;
QList<QPixmap>CustomIcons;
QFile* File;
QString error;
QList<StdEntry> UnknownMetaStreams;
unsigned int KeyTransfRounds;
CryptAlgorithm Algorithm;
quint8 RawMasterKey[32];
quint8 MasterKey[32];
};
#endif

@ -0,0 +1,197 @@
/*
---------------------------------------------------------------------------
Copyright (c) 2003, Dr Brian Gladman, Worcester, UK. All rights reserved.
LICENSE TERMS
The free distribution and use of this software in both source and binary
form is allowed (with or without changes) provided that:
1. distributions of this source code include the above copyright
notice, this list of conditions and the following disclaimer;
2. distributions in binary form include the above copyright
notice, this list of conditions and the following disclaimer
in the documentation and/or other associated materials;
3. the copyright holder's name is not used to endorse products
built using this software without specific written permission.
ALTERNATIVELY, provided that this notice is retained in full, this product
may be distributed under the terms of the GNU General Public License (GPL),
in which case the provisions of the GPL apply INSTEAD OF those given above.
DISCLAIMER
This software is provided 'as is' with no explicit or implied warranties
in respect of its properties, including, but not limited to, correctness
and/or fitness for purpose.
---------------------------------------------------------------------------
Issue 31/01/2006
This file contains the definitions required to use AES in C. See aesopt.h
for optimisation details.
*/
#ifndef _AES_H
#define _AES_H
#include <stdlib.h>
/* This include is used to find 8 & 32 bit unsigned integer types */
#include "aes_tdefs.h"
#if defined(__cplusplus)
extern "C"
{
#endif
#define AES_128 /* define if AES with 128 bit keys is needed */
#define AES_192 /* define if AES with 192 bit keys is needed */
#define AES_256 /* define if AES with 256 bit keys is needed */
#define AES_VAR /* define if a variable key size is needed */
#define AES_MODES /* define if support is needed for modes */
/* The following must also be set in assembler files if being used */
#define AES_ENCRYPT /* if support for encryption is needed */
#define AES_DECRYPT /* if support for decryption is needed */
#define AES_ERR_CHK /* for parameter checks & error return codes */
#define AES_REV_DKS /* define to reverse decryption key schedule */
#define AES_BLOCK_SIZE 16 /* the AES block size in bytes */
#define N_COLS 4 /* the number of columns in the state */
/* The key schedule length is 11, 13 or 15 16-byte blocks for 128, */
/* 192 or 256-bit keys respectively. That is 176, 208 or 240 bytes */
/* or 44, 52 or 60 32-bit words. */
#if defined( AES_VAR ) || defined( AES_256 )
#define KS_LENGTH 60
#elif defined( AES_192 )
#define KS_LENGTH 52
#else
#define KS_LENGTH 44
#endif
#if defined( AES_ERR_CHK )
#define aes_rval int_ret
#else
#define aes_rval void_ret
#endif
/* the character array 'inf' in the following structures is used */
/* to hold AES context information. This AES code uses cx->inf.b[0] */
/* to hold the number of rounds multiplied by 16. The other three */
/* elements can be used by code that implements additional modes */
typedef union
{ uint_32t l;
uint_8t b[4];
} aes_inf;
typedef struct
{ uint_32t ks[KS_LENGTH];
aes_inf inf;
} aes_encrypt_ctx;
typedef struct
{ uint_32t ks[KS_LENGTH];
aes_inf inf;
} aes_decrypt_ctx;
/* This routine must be called before first use if non-static */
/* tables are being used */
aes_rval gen_tabs(void);
/* Key lengths in the range 16 <= key_len <= 32 are given in bytes, */
/* those in the range 128 <= key_len <= 256 are given in bits */
#if defined( AES_ENCRYPT )
#if defined(AES_128) || defined(AES_VAR)
aes_rval aes_encrypt_key128(const unsigned char *key, aes_encrypt_ctx cx[1]);
#endif
#if defined(AES_192) || defined(AES_VAR)
aes_rval aes_encrypt_key192(const unsigned char *key, aes_encrypt_ctx cx[1]);
#endif
#if defined(AES_256) || defined(AES_VAR)
aes_rval aes_encrypt_key256(const unsigned char *key, aes_encrypt_ctx cx[1]);
#endif
#if defined(AES_VAR)
aes_rval aes_encrypt_key(const unsigned char *key, int key_len, aes_encrypt_ctx cx[1]);
#endif
aes_rval aes_encrypt(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1]);
#endif
#if defined( AES_DECRYPT )
#if defined(AES_128) || defined(AES_VAR)
aes_rval aes_decrypt_key128(const unsigned char *key, aes_decrypt_ctx cx[1]);
#endif
#if defined(AES_192) || defined(AES_VAR)
aes_rval aes_decrypt_key192(const unsigned char *key, aes_decrypt_ctx cx[1]);
#endif
#if defined(AES_256) || defined(AES_VAR)
aes_rval aes_decrypt_key256(const unsigned char *key, aes_decrypt_ctx cx[1]);
#endif
#if defined(AES_VAR)
aes_rval aes_decrypt_key(const unsigned char *key, int key_len, aes_decrypt_ctx cx[1]);
#endif
aes_rval aes_decrypt(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1]);
#endif
#if defined(AES_MODES)
aes_rval aes_ecb_encrypt(const unsigned char *ibuf, unsigned char *obuf,
int len, const aes_encrypt_ctx cx[1]);
aes_rval aes_ecb_decrypt(const unsigned char *ibuf, unsigned char *obuf,
int len, const aes_decrypt_ctx cx[1]);
aes_rval aes_cbc_encrypt(const unsigned char *ibuf, unsigned char *obuf,
int len, unsigned char *iv, const aes_encrypt_ctx cx[1]);
aes_rval aes_cbc_decrypt(const unsigned char *ibuf, unsigned char *obuf,
int len, unsigned char *iv, const aes_decrypt_ctx cx[1]);
aes_rval aes_mode_reset(aes_encrypt_ctx cx[1]);
aes_rval aes_cfb_encrypt(const unsigned char *ibuf, unsigned char *obuf,
int len, unsigned char *iv, aes_encrypt_ctx cx[1]);
aes_rval aes_cfb_decrypt(const unsigned char *ibuf, unsigned char *obuf,
int len, unsigned char *iv, aes_encrypt_ctx cx[1]);
#define aes_ofb_encrypt aes_ofb_crypt
#define aes_ofb_decrypt aes_ofb_crypt
aes_rval aes_ofb_crypt(const unsigned char *ibuf, unsigned char *obuf,
int len, unsigned char *iv, aes_encrypt_ctx cx[1]);
typedef void cbuf_inc(unsigned char *cbuf);
#define aes_ctr_encrypt aes_ctr_crypt
#define aes_ctr_decrypt aes_ctr_crypt
aes_rval aes_ctr_crypt(const unsigned char *ibuf, unsigned char *obuf,
int len, unsigned char *cbuf, cbuf_inc ctr_inc, aes_encrypt_ctx cx[1]);
#endif
#if defined(__cplusplus)
}
#endif
#endif

@ -0,0 +1,130 @@
/*
---------------------------------------------------------------------------
Copyright (c) 2003, Dr Brian Gladman, Worcester, UK. All rights reserved.
LICENSE TERMS
The free distribution and use of this software in both source and binary
form is allowed (with or without changes) provided that:
1. distributions of this source code include the above copyright
notice, this list of conditions and the following disclaimer;
2. distributions in binary form include the above copyright
notice, this list of conditions and the following disclaimer
in the documentation and/or other associated materials;
3. the copyright holder's name is not used to endorse products
built using this software without specific written permission.
ALTERNATIVELY, provided that this notice is retained in full, this product
may be distributed under the terms of the GNU General Public License (GPL),
in which case the provisions of the GPL apply INSTEAD OF those given above.
DISCLAIMER
This software is provided 'as is' with no explicit or implied warranties
in respect of its properties, including, but not limited to, correctness
and/or fitness for purpose.
---------------------------------------------------------------------------
Issue 31/01/2006
*/
#ifndef EDEFS_H
#define EDEFS_H
#if defined(__cplusplus)
extern "C"
{
#endif
#define IS_LITTLE_ENDIAN 1234 /* byte 0 is least significant (i386) */
#define IS_BIG_ENDIAN 4321 /* byte 0 is most significant (mc68k) */
#if defined(__GNUC__) || defined(__GNU_LIBRARY__)
# if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
# include <sys/endian.h>
# elif defined( BSD ) && ( BSD >= 199103 ) || defined( __DJGPP__ ) || defined( __CYGWIN32__ )
# include <machine/endian.h>
# elif defined(__APPLE__)
# if defined(__BIG_ENDIAN__) && !defined( BIG_ENDIAN )
# define BIG_ENDIAN
# elif defined(__LITTLE_ENDIAN__) && !defined( LITTLE_ENDIAN )
# define LITTLE_ENDIAN
# endif
# elif !defined( __MINGW32__ )
# include <endian.h>
# if !defined(__BEOS__)
# include <byteswap.h>
# endif
# endif
#endif
#if !defined(PLATFORM_BYTE_ORDER)
# if defined(LITTLE_ENDIAN) || defined(BIG_ENDIAN)
# if defined(LITTLE_ENDIAN) && !defined(BIG_ENDIAN)
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
# elif !defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN)
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
# elif defined(BYTE_ORDER) && (BYTE_ORDER == LITTLE_ENDIAN)
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
# elif defined(BYTE_ORDER) && (BYTE_ORDER == BIG_ENDIAN)
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
# endif
# elif defined(_LITTLE_ENDIAN) || defined(_BIG_ENDIAN)
# if defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
# elif !defined(_LITTLE_ENDIAN) && defined(_BIG_ENDIAN)
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
# elif defined(_BYTE_ORDER) && (_BYTE_ORDER == _LITTLE_ENDIAN)
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
# elif defined(_BYTE_ORDER) && (_BYTE_ORDER == _BIG_ENDIAN)
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
# endif
# elif defined(__LITTLE_ENDIAN__) || defined(__BIG_ENDIAN__)
# if defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
# elif !defined(__LITTLE_ENDIAN__) && defined(__BIG_ENDIAN__)
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
# elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __LITTLE_ENDIAN__)
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
# elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __BIG_ENDIAN__)
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
# endif
# endif
#endif
/* if the platform is still unknown, try to find its byte order */
/* from commonly used machine defines */
#if !defined(PLATFORM_BYTE_ORDER)
#if defined( __alpha__ ) || defined( __alpha ) || defined( i386 ) || \
defined( __i386__ ) || defined( _M_I86 ) || defined( _M_IX86 ) || \
defined( __OS2__ ) || defined( sun386 ) || defined( __TURBOC__ ) || \
defined( vax ) || defined( vms ) || defined( VMS ) || \
defined( __VMS ) || defined( _M_X64 )
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
#elif defined( AMIGA ) || defined( applec ) || defined( __AS400__ ) || \
defined( _CRAY ) || defined( __hppa ) || defined( __hp9000 ) || \
defined( ibm370 ) || defined( mc68000 ) || defined( m68k ) || \
defined( __MRC__ ) || defined( __MVS__ ) || defined( __MWERKS__ ) || \
defined( sparc ) || defined( __sparc) || defined( SYMANTEC_C ) || \
defined( __TANDEM ) || defined( THINK_C ) || defined( __VMCMS__ ) || \
defined( __VOS__ )
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
#elif 0 /* **** EDIT HERE IF NECESSARY **** */
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
#elif 0 /* **** EDIT HERE IF NECESSARY **** */
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
#else
# error Please edit edefs.h (lines 117 or 119) to set the platform byte order
#endif
#endif
#if defined(__cplusplus)
}
#endif
#endif

@ -0,0 +1,891 @@
/*
---------------------------------------------------------------------------
Copyright (c) 2003, Dr Brian Gladman, Worcester, UK. All rights reserved.
LICENSE TERMS
The free distribution and use of this software in both source and binary
form is allowed (with or without changes) provided that:
1. distributions of this source code include the above copyright
notice, this list of conditions and the following disclaimer;
2. distributions in binary form include the above copyright
notice, this list of conditions and the following disclaimer
in the documentation and/or other associated materials;
3. the copyright holder's name is not used to endorse products
built using this software without specific written permission.
ALTERNATIVELY, provided that this notice is retained in full, this product
may be distributed under the terms of the GNU General Public License (GPL),
in which case the provisions of the GPL apply INSTEAD OF those given above.
DISCLAIMER