author | zautrix <zautrix> | 2004-10-20 08:28:39 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-20 08:28:39 (UTC) |
commit | 268e69a533c5db110600758366644c9827957364 (patch) (side-by-side diff) | |
tree | a2375a67c76beaf861ae8a67ca11ca0f5743c705 | |
parent | dd66c63b4e953f1e4bb89386bdaed06cbf84a7a5 (diff) | |
download | kdepimpi-268e69a533c5db110600758366644c9827957364.zip kdepimpi-268e69a533c5db110600758366644c9827957364.tar.gz kdepimpi-268e69a533c5db110600758366644c9827957364.tar.bz2 |
several fixes
-rw-r--r-- | pwmanager/pwmanager/compiler.h | 10 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwm.h | 3 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmanager.pro | 4 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.h | 4 | ||||
-rw-r--r-- | pwmanager/pwmanager/randomizer.cpp | 8 | ||||
-rw-r--r-- | pwmanager/pwmanager/setmasterpwwndimpl.h | 4 | ||||
-rw-r--r-- | pwmanager/pwmanager/sha1.h | 9 |
7 files changed, 32 insertions, 10 deletions
diff --git a/pwmanager/pwmanager/compiler.h b/pwmanager/pwmanager/compiler.h index be08c6d..a942246 100644 --- a/pwmanager/pwmanager/compiler.h +++ b/pwmanager/pwmanager/compiler.h @@ -1,61 +1,69 @@ /*************************************************************************** * * * Derived from the linux-2.6 tree * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License version 2 * * as published by the Free Software Foundation. * * * ***************************************************************************/ #ifndef __PWMANAGER_COMPILER_H #define __PWMANAGER_COMPILER_H +#ifdef _WIN32_ +# define __builtin_expect(x, expected_value) (x) +#define NOREGPARM __attribute__((regparm(0))) +#define REGPARM __attribute__((regparm(3))) +#define likely(x) __builtin_expect(!!(x), 1) +#define unlikely(x) __builtin_expect(!!(x), 0) + +#else #ifdef __deprecated # undef __deprecated #endif #if __GNUC__ >= 3 # if __GNUC_MINOR__ > 0 # define __deprecated __attribute__((deprecated)) # endif #elif __GNUC__ == 2 # if __GNUC_MINOR__ < 96 # ifdef __builtin_expect # undef __builtin_expect # endif # define __builtin_expect(x, expected_value) (x) # endif #else # error "Sorry, your compiler is too old/not supported." #endif /* * Allow us to mark functions as 'deprecated' and have gcc emit a nice * warning for each use, in hopes of speeding the functions removal. * Usage is: * int __deprecated foo(void) */ #ifndef __deprecated # define __deprecated /* unimplemented */ #endif /* define likely() and unlikely() */ #ifdef likely # undef likely #endif #ifdef unlikely # undef unlikely #endif #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #ifdef NOREGPARM # undef NOREGPARM #endif #define NOREGPARM __attribute__((regparm(0))) #ifdef REGPARM # undef REGPARM #endif #define REGPARM __attribute__((regparm(3))) - +#endif #endif // __PWMANAGER_COMPILER_H diff --git a/pwmanager/pwmanager/pwm.h b/pwmanager/pwmanager/pwm.h index 116bc66..6ab9d6b 100644 --- a/pwmanager/pwmanager/pwm.h +++ b/pwmanager/pwmanager/pwm.h @@ -16,258 +16,257 @@ * * $Id$ **************************************************************************/ #ifndef __PWM_H #define __PWM_H #include <kpopupmenu.h> #include <klistview.h> #include <kmainwindow.h> #ifndef PWM_EMBEDDED #include <kwin.h> #include <kapp.h> #include <kdeversion.h> #else #include <ksyncmanager.h> #endif #include <kaction.h> #include <qglobal.h> #include "pwmview.h" #include "pwmexception.h" /** timeout for displaying a message on the status-bar (in seconds) */ #define STATUSBAR_MSG_TIMEOUT 5 class PwMInit; class KSyncManager; /** PwM is the base class of the project */ #ifndef PWM_EMBEDDED //MOC_SKIP_BEGIN class PwM : public KMainWindow //MOC_SKIP_END #else class PwM : public KMainWindow, public KSyncInterface #endif { Q_OBJECT public: friend class PwMView; /** construtor */ PwM(PwMInit *_init, PwMDoc *doc, bool virginity = true, QWidget* parent = 0, const char *name = 0); /** destructor */ ~PwM(); /** copy some text to the global clipboard */ static void copyToClipboard(const QString &s); /** returns pointer to the view */ PwMView * curView() { return view; } /** returns pointer to the currently using document. */ PwMDoc * curDoc() { return curView()->document(); } /** open a new doc with the given filename */ PwMDoc * openDoc(QString filename, bool openDeepLocked = false); /** show a message on the global status bar. * The message times out after some seconds. */ void showStatMsg(const QString &msg); /** ask the user where to save the doc (if it has not been saved, yet) * and write the data to disk. */ bool save(); /** ask the user where to save the doc * and write the data to disk. */ bool saveAs(); /** force quit. Quit this window, always! Don't minimize it */ bool isForceQuit() { return forceQuit; } /** set forceQuit */ void setForceQuit(bool force) { forceQuit = force; } /** force minimize this window */ bool isForceMinimizeToTray() { return forceMinimizeToTray; } /** set forceMinimizeToTray */ void setForceMinimizeToTray(bool force) { forceMinimizeToTray = force; } public slots: /** file/new triggered */ void new_slot(); /** file/open triggered */ //US ENH void open_slot(); void open_slot(QString fn); /** file/close triggered */ void close_slot(); /** file/quit triggered */ void quitButton_slot(); /** file/save triggered */ void save_slot(); /** file/saveAs triggered */ void saveAs_slot(); /** file/export/text triggered */ void exportToText(); /** file/export/gpasman triggered */ void exportToGpasman(); /** file/export/kwallet triggered */ void exportToKWallet(); /** file/import/text triggered */ bool importFromText(); /** file/import/gpasman triggered */ bool importFromGpasman(); /** file/import/kwallet triggered */ bool importKWallet(); /** file/print triggered */ void print_slot(); /** manage/add triggered */ //US ENH : changed code to run with older MOC void addPwd_slot(); void addPwd_slot1(QString *pw, PwMDoc *_doc); /** manage/edit triggered */ //US ENH : changed code to run with older MOC void editPwd_slot(); void editPwd_slot1(const QString *category); - void editPwd_slot3(const QString *category = 0, const int *index = 0, - PwMDoc *_doc = 0); + void editPwd_slot3(const QString *category, const int *index ,PwMDoc *_doc ); /** manage/delete triggered */ void deletePwd_slot(); /** execute the "Launcher" entry */ void execLauncher_slot(); /** open browser with URL entry */ void goToURL_slot(); /** manage/changeMasterPwd triggered */ void changeMasterPwd_slot(); /** lock current document */ void lockWnd_slot(); /** deeplock current document */ void deepLockWnd_slot(); /** window/unlock triggered */ void unlockWnd_slot(); /** find item */ void find_slot(); /** configure clicked */ void config_slot(); /** (de)activate the "change master pw" button in the menu-bar */ void activateMpButton(bool activate = true); /** generate a new chipcard */ void genNewCard_slot(); /** completely erase the current card */ void eraseCard_slot(); /** returns the ID number of the current card */ void readCardId_slot(); /** make backup image of the current card */ void makeCardBackup_slot(); /** write backup image to current card */ void replayCardBackup_slot(); #ifdef PWM_EMBEDDED void whatsnew_slot(); void showLicense_slot(); void faq_slot(); void createAboutData_slot(); void syncHowTo_slot(); #endif protected: /** is this window virgin? */ bool isVirgin() { return virgin; } /** add/remove virginity */ void setVirgin(bool v); /** initialize the menubar */ void initMenubar(); /** initialize the toolbar */ void initToolbar(); /** initialize the window-metrics */ void initMetrics(); /** close-event */ void closeEvent(QCloseEvent *e); /** creates a new PwM-ListView and returns it */ PwMView * makeNewListView(PwMDoc *doc); /** Window hide-event */ void hideEvent(QHideEvent *); /** is this window minimized? */ bool isMinimized() { #ifndef PWM_EMBEDDED #if KDE_VERSION >= KDE_MAKE_VERSION(3, 2, 0) return KWin::windowInfo(winId()).isMinimized(); #else // KDE_VERSION return KWin::info(winId()).isIconified(); #endif // KDE_VERSION #else return false; #endif } /** window got the focus */ void focusInEvent(QFocusEvent *e); /** update the caption string */ void updateCaption(); #ifdef CONFIG_KWALLETIF /** check if kwalletemu is enabled and ask the user what to do */ bool checkAndAskForKWalletEmu(); #endif // CONFIG_KWALLETIF protected slots: /** doc got closed */ void docClosed(PwMDoc *doc); signals: /** window got closed (by user or someone else) */ void closed(PwM *wnd); /** window got the focus (was brought to foreground) */ void gotFocus(PwM *wnd); /** window lost the focus */ void lostFocus(PwM *wnd); protected: /** pointer to the view active in this KMainWindow */ PwMView *view; /** pointer to the init class */ PwMInit *init; /** has this window already lost its virginity? * Means is there an open working document */ bool virgin; /** "file" popup-menu */ KPopupMenu *filePopup; /** "manage" popup-menu */ KPopupMenu *managePopup; #ifdef CONFIG_KEYCARD /** "chipcard" popup-menu */ KPopupMenu *chipcardPopup; #endif // CONFIG_KEYCARD /** "view" popup-menu */ KPopupMenu *viewPopup; /** "options" popup-menu */ KPopupMenu *optionsPopup; /** "help" popup-menu */ KPopupMenu *helpPopup; /** "export" popup-menu */ KPopupMenu *exportPopup; /** "import" popup-menu */ KPopupMenu *importPopup; /** force quit this window? */ bool forceQuit; /** force minimize this window to the tray */ bool forceMinimizeToTray; diff --git a/pwmanager/pwmanager/pwmanager.pro b/pwmanager/pwmanager/pwmanager.pro index 7f39c76..49c1f46 100644 --- a/pwmanager/pwmanager/pwmanager.pro +++ b/pwmanager/pwmanager/pwmanager.pro @@ -1,161 +1,161 @@ TEMPLATE = app -CONFIG += qt warn_on +CONFIG += qt warn_off DESTDIR= ../../bin TARGET = pwmpi include( ../../variables.pri ) INCLUDEPATH += . ../../ ../../libkdepim ../../microkde ../../microkde/kdecore ../../microkde/kdeui ../../microkde/kutils DEFINES += PWM_EMBEDDED CONFIG_PWMANAGER_GCRY DESKTOP_VERSION #enable this setting if you want debugoutput for pwmanager #DEFINES += CONFIG_DEBUG LIBS += -L../libcrypt/ LIBS += -L../../bin/ LIBS += -lmicrokde LIBS += -lmicrokdepim LIBS += -lzlib LIBS += -lkpmicrocipher LIBS += -lkpmicroerror LIBS += -lkpmicrompi LIBS += -lstdc++ unix:{ OBJECTS_DIR = obj/unix MOC_DIR = moc/unix } win32:{ DEFINES += _WIN32_ OBJECTS_DIR = obj/win MOC_DIR = moc/win QMAKE_LINK += /NODEFAULTLIB:LIBC - +QMAKE_CXXFLAGS += /TP /GX /GR /Ehsc } #INTERFACES = \ #addentrywnd.ui \ #configwnd.ui \ #findwnd.ui \ #getmasterpwwnd.ui \ #pwgenwnd.ui \ #setmasterpwwnd.ui \ #subtbledit.ui #INTERFACES = \ #subtbledit.ui \ #HEADERS = \ #configuration_31compat.h \ #configuration.h \ #configwnd.h \ #configwndimpl.h \ #selftest.h #subtbledit.h \ #subtbleditimpl.h \ #compressbzip2.h \ HEADERS = \ addentrywnd_emb.h \ addentrywndimpl.h \ base64.h \ binentrygen.h \ blowfish.h \ commentbox.h \ compiler.h \ compressgzip.h \ findwnd_emb.h \ findwndimpl.h \ genpasswd.h \ getkeycardwnd.h \ getmasterpwwnd_emb.h \ getmasterpwwndimpl.h \ globalstuff.h \ gpasmanfile.h \ htmlgen.h \ htmlparse.h \ ipc.h \ libgcryptif.h \ listobjselectwnd.h \ listviewpwm.h \ printtext.h \ pwgenwnd_emb.h \ pwgenwndimpl.h \ pwmdoc.h \ pwmdocui.h \ pwmexception.h \ pwm.h \ pwminit.h \ pwmprefs.h \ pwmprint.h \ pwmtray.h \ pwmview.h \ pwmviewstyle_0.h \ pwmviewstyle_1.h \ pwmviewstyle.h \ randomizer.h \ rc2.h \ rencatwnd.h \ serializer.h \ setmasterpwwnd_emb.h \ setmasterpwwndimpl.h \ sha1.h \ waitwnd.h \ kcmconfigs/kcmpwmconfig.h \ kcmconfigs/pwmconfigwidget.h #sources that need not be build #SOURCES = \ #advcommeditimpl.cpp \ #configuration.cpp \ #configwnd.cpp \ #configwndimpl.cpp \ #configuration_31compat.cpp \ #htmlparse.cpp \ #printtext.cpp \ #selftest.cpp \ #pwmprint.cpp \ #spinforsignal.cpp #subtbledit.cpp \ #subtbleditimpl.cpp \ #compressbzip2.cpp SOURCES = \ addentrywnd_emb.cpp \ addentrywndimpl.cpp \ base64.cpp \ binentrygen.cpp \ blowfish.cpp \ commentbox.cpp \ compressgzip.cpp \ findwnd_emb.cpp \ findwndimpl.cpp \ genpasswd.cpp \ getkeycardwnd.cpp \ getmasterpwwnd_emb.cpp \ getmasterpwwndimpl.cpp \ globalstuff.cpp \ gpasmanfile.cpp \ htmlgen.cpp \ ipc.cpp \ libgcryptif.cpp \ listobjselectwnd.cpp \ listviewpwm.cpp \ main.cpp \ pwgenwnd_emb.cpp \ pwgenwndimpl.cpp \ pwm.cpp \ pwmdoc.cpp \ pwmdocui.cpp \ pwmexception.cpp \ pwminit.cpp \ pwmprefs.cpp \ pwmtray.cpp \ pwmview.cpp \ pwmviewstyle_0.cpp \ pwmviewstyle_1.cpp \ pwmviewstyle.cpp \ randomizer.cpp \ diff --git a/pwmanager/pwmanager/pwmdoc.h b/pwmanager/pwmanager/pwmdoc.h index 635361a..55e3231 100644 --- a/pwmanager/pwmanager/pwmdoc.h +++ b/pwmanager/pwmanager/pwmdoc.h @@ -1,150 +1,152 @@ /*************************************************************************** * * * copyright (C) 2003, 2004 by Michael Buesch * * email: mbuesch@freenet.de * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License version 2 * * as published by the Free Software Foundation. * * * ***************************************************************************/ /*************************************************************************** * copyright (C) 2004 by Ulf Schenk * This file is originaly based on version 1.1 of pwmanager * and was modified to run on embedded devices that run microkde * * $Id$ **************************************************************************/ #ifndef __PWMDOC_H #define __PWMDOC_H - +#ifdef _WIN32_ +#define ssize_t unsigned int +#endif #define PWM_FILE_VER (static_cast<char>(0x05)) #define PWM_HASH_SHA1 (static_cast<char>(0x01)) #define PWM_HASH_SHA256 (static_cast<char>(0x02)) #define PWM_HASH_SHA384 (static_cast<char>(0x03)) #define PWM_HASH_SHA512 (static_cast<char>(0x04)) #define PWM_HASH_MD5 (static_cast<char>(0x05)) #define PWM_HASH_RMD160 (static_cast<char>(0x06)) #define PWM_HASH_TIGER (static_cast<char>(0x07)) #define PWM_CRYPT_BLOWFISH (static_cast<char>(0x01)) #define PWM_CRYPT_AES128 (static_cast<char>(0x02)) #define PWM_CRYPT_AES192 (static_cast<char>(0x03)) #define PWM_CRYPT_AES256 (static_cast<char>(0x04)) #define PWM_CRYPT_3DES (static_cast<char>(0x05)) #define PWM_CRYPT_TWOFISH (static_cast<char>(0x06)) #define PWM_CRYPT_TWOFISH128 (static_cast<char>(0x07)) #define PWM_COMPRESS_NONE (static_cast<char>(0x00)) #define PWM_COMPRESS_GZIP (static_cast<char>(0x01)) #define PWM_COMPRESS_BZIP2 (static_cast<char>(0x02)) #define DEFAULT_MAX_ENTRIES (~(static_cast<unsigned int>(0))) #define FILE_ID_HEADER "PWM_PASSWORD_FILE" #include "pwmexception.h" #include "pwmdocui.h" #include <qobject.h> #include <qtimer.h> #include <qdatetime.h> #include <kprocess.h> #ifndef PWM_EMBEDDED #include "configuration.h" #else #include <kapplication.h> #include <ksyncmanager.h> #endif #include <string> #include <vector> #include <utility> using std::vector; using std::string; using std::pair; /* used in findEntry() function */ #define SEARCH_IN_DESC (1) #define SEARCH_IN_NAME (1 << 1) #define SEARCH_IN_PW (1 << 2) #define SEARCH_IN_COMMENT (1 << 3) #define SEARCH_IN_URL (1 << 4) #define SEARCH_IN_LAUNCHER (1 << 5) #define SEARCH_IN_ALL (SEARCH_IN_DESC | SEARCH_IN_NAME | \ SEARCH_IN_PW | SEARCH_IN_COMMENT | \ SEARCH_IN_URL | SEARCH_IN_LAUNCHER) /** document deeplocked. Data is out for lunch to disk */ #define DOC_STAT_DEEPLOCKED (1) /** encrypted document on disk is dirty. data has to go to disk. */ #define DOC_STAT_DISK_DIRTY (1 << 1) /** we are using a chipcard to encrypt the data */ #define DOC_STAT_USE_CHIPCARD (1 << 2) /** use "currentPw" to unlock. (This flag is set/unset by a timer) */ #define DOC_STAT_UNLOCK_WITHOUT_PW (1 << 3) class PwMDoc; class PwMView; class QFile; /* meta data for a PwMDataItem */ struct PwMMetaData { PwMMetaData() : updateInt (0) { } /** creation date of the PwMDataItem to which * this meta data belongs. */ QDateTime create; /** becomes valid on this date */ QDateTime valid; /** expire date */ QDateTime expire; /** update date (last updated at this date) */ QDateTime update; /** update interval (in minutes). Time since the * last update to remind the user to update the item. * 0 disables. */ unsigned long updateInt; //US ENH: enhancements of the filestructure /* each entry gets a unique id assigned */ string uniqueid; void clear() { create = QDateTime(); expire = QDateTime(); update = QDateTime(); updateInt = 0; uniqueid = KApplication::randomString(8).latin1(); } inline bool isValid() const { if (valid.isNull()) return true; return (valid < QDateTime::currentDateTime()); } inline bool isExpired() const { if (expire.isNull()) return false; return (expire < QDateTime::currentDateTime()); } inline bool isUpdateIntOver() const { if (updateInt == 0 || update.isNull()) return false; QDateTime d(update); diff --git a/pwmanager/pwmanager/randomizer.cpp b/pwmanager/pwmanager/randomizer.cpp index e1085ff..da4df78 100644 --- a/pwmanager/pwmanager/randomizer.cpp +++ b/pwmanager/pwmanager/randomizer.cpp @@ -1,167 +1,171 @@ /*************************************************************************** * * * copyright (C) 2003, 2004 by Michael Buesch * * email: mbuesch@freenet.de * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License version 2 * * as published by the Free Software Foundation. * * * ***************************************************************************/ /*************************************************************************** * copyright (C) 2004 by Ulf Schenk * This file is originaly based on version 1.1 of pwmanager * and was modified to run on embedded devices that run microkde * * $Id$ **************************************************************************/ #include "randomizer.h" #include "pwmexception.h" #include <qfile.h> #include <kapplication.h> #include <stdlib.h> #include <time.h> #ifdef PWM_EMBEDDED #ifndef Q_LONG #define Q_LONG long #endif #endif //PWM_EMBEDDED - - +#ifdef _WIN32_ +int rand_r( uint * seed ) { + srand(*seed); + return rand(); +} +#endif Randomizer * Randomizer::rndObj (0); Randomizer::Randomizer() { rndDev = new QFile; seed = time(0); #if 1 // set to 0 to test rand_r() fallback // probe for /dev/urandom rndDev->setName("/dev/urandom"); if (rndDev->exists() && rndDev->open(IO_ReadOnly)) { printDebug("Randomizer: using /dev/urandom"); return; } // probe for /dev/random rndDev->setName("/dev/random"); if (rndDev->exists() && rndDev->open(IO_ReadOnly)) { printDebug("Randomizer: using /dev/random"); return; } // probe for EGD char *fn = getenv("RANDFILE"); if (fn) { rndDev->setName(fn); if (rndDev->exists() && rndDev->open(IO_ReadOnly)) { printDebug(string("Randomizer: using $RANDFILE \"") + fn + "\" (aka EGD)"); return; } } #endif /* no secure randomizer found. * Fall back to stdlib randomizer. */ delete_and_null(rndDev); printWarn("neither /dev/*random nor EGD found! " "Falling back to insecure rand_r()!"); } Randomizer::~Randomizer() { #ifndef PWM_EMBEDDED while (mutex.locked()) { /* wait for the mutex to unlock. * Don't block the GUI here, so processEvents() */ kapp->processEvents(); } #endif if (rndDev) { rndDev->close(); delete rndDev; } } char Randomizer::genRndChar() { char ret; #ifndef PWM_EMBEDDED mutex.lock(); #endif if (rndDev) { /* we have a file which provides random data. * Simply read it. */ ret = rndDev->getch(); } else { /* fall back to rand_r() */ ret = rand_r(&seed) % 0xFF; } #ifndef PWM_EMBEDDED mutex->unlock(); #endif return ret; } int Randomizer::genRndInt() { int ret; #ifndef PWM_EMBEDDED mutex->lock(); #endif if (rndDev) { if (sizeof(int) == 4) { (reinterpret_cast<char *>(&ret))[0] = rndDev->getch(); (reinterpret_cast<char *>(&ret))[1] = rndDev->getch(); (reinterpret_cast<char *>(&ret))[2] = rndDev->getch(); (reinterpret_cast<char *>(&ret))[3] = rndDev->getch(); } else if (sizeof(int) == 8) { (reinterpret_cast<char *>(&ret))[0] = rndDev->getch(); (reinterpret_cast<char *>(&ret))[1] = rndDev->getch(); (reinterpret_cast<char *>(&ret))[2] = rndDev->getch(); (reinterpret_cast<char *>(&ret))[3] = rndDev->getch(); (reinterpret_cast<char *>(&ret))[4] = rndDev->getch(); (reinterpret_cast<char *>(&ret))[5] = rndDev->getch(); (reinterpret_cast<char *>(&ret))[6] = rndDev->getch(); (reinterpret_cast<char *>(&ret))[7] = rndDev->getch(); } else { printWarn(string(__FILE__) + ":" + tostr(__LINE__) + ": sizeof(int) != 4 && sizeof(int) != 8"); ret = rand_r(&seed); } } else { ret = rand_r(&seed); } #ifndef PWM_EMBEDDED mutex->unlock(); #endif return ret; } unsigned int Randomizer::genRndUInt() { unsigned int ret; #ifndef PWM_EMBEDDED mutex->lock(); #endif if (rndDev) { if (sizeof(unsigned int) == 4) { (reinterpret_cast<char *>(&ret))[0] = rndDev->getch(); diff --git a/pwmanager/pwmanager/setmasterpwwndimpl.h b/pwmanager/pwmanager/setmasterpwwndimpl.h index 3203d4d..08f3654 100644 --- a/pwmanager/pwmanager/setmasterpwwndimpl.h +++ b/pwmanager/pwmanager/setmasterpwwndimpl.h @@ -1,80 +1,84 @@ /*************************************************************************** * * * copyright (C) 2003 by Michael Buesch * * email: mbuesch@freenet.de * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License version 2 * * as published by the Free Software Foundation. * * * ***************************************************************************/ /*************************************************************************** * copyright (C) 2004 by Ulf Schenk * This file is originaly based on version 1.0.1 of pwmanager * and was modified to run on embedded devices that run microkde * * $Id$ **************************************************************************/ #ifndef SETMASTERPWWNDIMPL_H #define SETMASTERPWWNDIMPL_H #ifndef PWM_EMBEDDED #include "setmasterpwwnd.h" #else #include "setmasterpwwnd_emb.h" #endif #include <klocale.h> +#ifdef _WIN32_ +#define uint32_t Q_UINT32 +#else #include <stdint.h> +#endif #include <string> using std::string; class PwMKeyCard; /** set master pw wnd */ class SetMasterPwWndImpl : public setMasterPwWnd { Q_OBJECT public: SetMasterPwWndImpl(QWidget* parent = 0, const char *name = 0); ~SetMasterPwWndImpl(); static QString string_cardNone() { return i18n("NONE"); } /** returns the selected pw (or the key on the card) */ string getPw(bool *useCard); /** set pointer to the keycard-access object */ void setPwMKeyCard(PwMKeyCard *_keyCard) { keyCard = _keyCard; } public slots: /** ok button pressed */ void okButton_slot(); /** cancel button pressed */ void cancelButton_slot(); /** "generate a new card" button pressed */ void genCardButton_slot(); /** "select current card" button pressed */ void selCardButton_slot(); #ifdef PWM_EMBEDDED virtual void slotOk(); #endif protected slots: /** key from PwMKeyCard is available */ void keyAvailable_slot(uint32_t cardId, const string &key); protected: /** key of currently inserted card */ string curCardKey; /** pointer to the keycard-access object */ PwMKeyCard *keyCard; }; #endif diff --git a/pwmanager/pwmanager/sha1.h b/pwmanager/pwmanager/sha1.h index 29442a7..c649bae 100644 --- a/pwmanager/pwmanager/sha1.h +++ b/pwmanager/pwmanager/sha1.h @@ -1,75 +1,80 @@ /*************************************************************************** * * * copyright (C) 2003 by Michael Buesch * * email: mbuesch@freenet.de * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License version 2 * * as published by the Free Software Foundation. * * * ***************************************************************************/ /*************************************************************************** * copyright (C) 2004 by Ulf Schenk * This file is originaly based on version 1.0.1 of pwmanager * and was modified to run on embedded devices that run microkde * * $Id$ **************************************************************************/ #ifndef SHA1_H #define SHA1_H - +#ifdef _WIN32_ +#define uint32_t unsigned int +#define uint8_t unsigned char +#define byte unsigned char +#else #include <stdint.h> +typedef uint8_t byte; +#endif #include <string> using std::string; -typedef uint8_t byte; #define SHA1_HASH_LEN_BIT 160 #define SHA1_HASH_LEN_BYTE (SHA1_HASH_LEN_BIT / 8) /** sha1 hash algorithm. * Derived from libgcrypt-1.1.12 */ class Sha1 { struct SHA1_CONTEXT { uint32_t h0,h1,h2,h3,h4; uint32_t nblocks; byte buf[64]; int count; }; public: Sha1() { sha1_init(); } static bool selfTest(); void sha1_write(const byte *inbuf, uint32_t inlen); string sha1_read(); protected: void sha1_init(); void sha1_final(); void burn_stack (int bytes); void transform(const byte *data); /** Rotate a 32 bit integer by n bytes */ uint32_t rol(uint32_t x, int n) { #if defined(__GNUC__) && defined(__i386__) __asm__("roll %%cl,%0" :"=r" (x) :"0" (x),"c" (n)); return x; #else return ((x) << (n)) | ((x) >> (32-(n))); #endif } protected: struct SHA1_CONTEXT ctx; }; #endif |