summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/compiler.h10
-rw-r--r--pwmanager/pwmanager/pwm.h3
-rw-r--r--pwmanager/pwmanager/pwmanager.pro4
-rw-r--r--pwmanager/pwmanager/pwmdoc.h4
-rw-r--r--pwmanager/pwmanager/randomizer.cpp8
-rw-r--r--pwmanager/pwmanager/setmasterpwwndimpl.h4
-rw-r--r--pwmanager/pwmanager/sha1.h9
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 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * Derived from the linux-2.6 tree * 3 * Derived from the linux-2.6 tree *
4 * * 4 * *
5 * This program is free software; you can redistribute it and/or modify * 5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License version 2 * 6 * it under the terms of the GNU General Public License version 2 *
7 * as published by the Free Software Foundation. * 7 * as published by the Free Software Foundation. *
8 * * 8 * *
9 ***************************************************************************/ 9 ***************************************************************************/
10 10
11#ifndef __PWMANAGER_COMPILER_H 11#ifndef __PWMANAGER_COMPILER_H
12#define __PWMANAGER_COMPILER_H 12#define __PWMANAGER_COMPILER_H
13 13
14#ifdef _WIN32_
15# define __builtin_expect(x, expected_value) (x)
16 #define NOREGPARM__attribute__((regparm(0)))
17 #define REGPARM __attribute__((regparm(3)))
18 #define likely(x)__builtin_expect(!!(x), 1)
19 #define unlikely(x)__builtin_expect(!!(x), 0)
20
21#else
14#ifdef __deprecated 22#ifdef __deprecated
15# undef __deprecated 23# undef __deprecated
16#endif 24#endif
17#if __GNUC__ >= 3 25#if __GNUC__ >= 3
18# if __GNUC_MINOR__ > 0 26# if __GNUC_MINOR__ > 0
19 # define __deprecated__attribute__((deprecated)) 27 # define __deprecated__attribute__((deprecated))
20# endif 28# endif
21#elif __GNUC__ == 2 29#elif __GNUC__ == 2
22# if __GNUC_MINOR__ < 96 30# if __GNUC_MINOR__ < 96
23# ifdef __builtin_expect 31# ifdef __builtin_expect
24# undef __builtin_expect 32# undef __builtin_expect
25# endif 33# endif
26# define __builtin_expect(x, expected_value) (x) 34# define __builtin_expect(x, expected_value) (x)
27# endif 35# endif
28#else 36#else
29# error "Sorry, your compiler is too old/not supported." 37# error "Sorry, your compiler is too old/not supported."
30#endif 38#endif
31 39
32/* 40/*
33 * Allow us to mark functions as 'deprecated' and have gcc emit a nice 41 * Allow us to mark functions as 'deprecated' and have gcc emit a nice
34 * warning for each use, in hopes of speeding the functions removal. 42 * warning for each use, in hopes of speeding the functions removal.
35 * Usage is: 43 * Usage is:
36 * int __deprecated foo(void) 44 * int __deprecated foo(void)
37 */ 45 */
38#ifndef __deprecated 46#ifndef __deprecated
39 # define __deprecated /* unimplemented */ 47 # define __deprecated /* unimplemented */
40#endif 48#endif
41 49
42/* define likely() and unlikely() */ 50/* define likely() and unlikely() */
43#ifdef likely 51#ifdef likely
44# undef likely 52# undef likely
45#endif 53#endif
46#ifdef unlikely 54#ifdef unlikely
47# undef unlikely 55# undef unlikely
48#endif 56#endif
49 #define likely(x)__builtin_expect(!!(x), 1) 57 #define likely(x)__builtin_expect(!!(x), 1)
50 #define unlikely(x)__builtin_expect(!!(x), 0) 58 #define unlikely(x)__builtin_expect(!!(x), 0)
51 59
52#ifdef NOREGPARM 60#ifdef NOREGPARM
53# undef NOREGPARM 61# undef NOREGPARM
54#endif 62#endif
55 #define NOREGPARM__attribute__((regparm(0))) 63 #define NOREGPARM__attribute__((regparm(0)))
56#ifdef REGPARM 64#ifdef REGPARM
57# undef REGPARM 65# undef REGPARM
58#endif 66#endif
59 #define REGPARM __attribute__((regparm(3))) 67 #define REGPARM __attribute__((regparm(3)))
60 68#endif
61#endif // __PWMANAGER_COMPILER_H 69#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
@@ -80,130 +80,129 @@ public:
80 PwMDoc * openDoc(QString filename, bool openDeepLocked = false); 80 PwMDoc * openDoc(QString filename, bool openDeepLocked = false);
81 /** show a message on the global status bar. 81 /** show a message on the global status bar.
82 * The message times out after some seconds. 82 * The message times out after some seconds.
83 */ 83 */
84 void showStatMsg(const QString &msg); 84 void showStatMsg(const QString &msg);
85 /** ask the user where to save the doc (if it has not been saved, yet) 85 /** ask the user where to save the doc (if it has not been saved, yet)
86 * and write the data to disk. 86 * and write the data to disk.
87 */ 87 */
88 bool save(); 88 bool save();
89 /** ask the user where to save the doc 89 /** ask the user where to save the doc
90 * and write the data to disk. 90 * and write the data to disk.
91 */ 91 */
92 bool saveAs(); 92 bool saveAs();
93 /** force quit. Quit this window, always! Don't minimize it */ 93 /** force quit. Quit this window, always! Don't minimize it */
94 bool isForceQuit() 94 bool isForceQuit()
95 { return forceQuit; } 95 { return forceQuit; }
96 /** set forceQuit */ 96 /** set forceQuit */
97 void setForceQuit(bool force) 97 void setForceQuit(bool force)
98 { forceQuit = force; } 98 { forceQuit = force; }
99 /** force minimize this window */ 99 /** force minimize this window */
100 bool isForceMinimizeToTray() 100 bool isForceMinimizeToTray()
101 { return forceMinimizeToTray; } 101 { return forceMinimizeToTray; }
102 /** set forceMinimizeToTray */ 102 /** set forceMinimizeToTray */
103 void setForceMinimizeToTray(bool force) 103 void setForceMinimizeToTray(bool force)
104 { forceMinimizeToTray = force; } 104 { forceMinimizeToTray = force; }
105 105
106public slots: 106public slots:
107 /** file/new triggered */ 107 /** file/new triggered */
108 void new_slot(); 108 void new_slot();
109 /** file/open triggered */ 109 /** file/open triggered */
110//US ENH 110//US ENH
111 void open_slot(); 111 void open_slot();
112 void open_slot(QString fn); 112 void open_slot(QString fn);
113 /** file/close triggered */ 113 /** file/close triggered */
114 void close_slot(); 114 void close_slot();
115 /** file/quit triggered */ 115 /** file/quit triggered */
116 void quitButton_slot(); 116 void quitButton_slot();
117 /** file/save triggered */ 117 /** file/save triggered */
118 void save_slot(); 118 void save_slot();
119 /** file/saveAs triggered */ 119 /** file/saveAs triggered */
120 void saveAs_slot(); 120 void saveAs_slot();
121 /** file/export/text triggered */ 121 /** file/export/text triggered */
122 void exportToText(); 122 void exportToText();
123 /** file/export/gpasman triggered */ 123 /** file/export/gpasman triggered */
124 void exportToGpasman(); 124 void exportToGpasman();
125 /** file/export/kwallet triggered */ 125 /** file/export/kwallet triggered */
126 void exportToKWallet(); 126 void exportToKWallet();
127 /** file/import/text triggered */ 127 /** file/import/text triggered */
128 bool importFromText(); 128 bool importFromText();
129 /** file/import/gpasman triggered */ 129 /** file/import/gpasman triggered */
130 bool importFromGpasman(); 130 bool importFromGpasman();
131 /** file/import/kwallet triggered */ 131 /** file/import/kwallet triggered */
132 bool importKWallet(); 132 bool importKWallet();
133 /** file/print triggered */ 133 /** file/print triggered */
134 void print_slot(); 134 void print_slot();
135 /** manage/add triggered */ 135 /** manage/add triggered */
136 //US ENH : changed code to run with older MOC 136 //US ENH : changed code to run with older MOC
137 137
138 void addPwd_slot(); 138 void addPwd_slot();
139 void addPwd_slot1(QString *pw, PwMDoc *_doc); 139 void addPwd_slot1(QString *pw, PwMDoc *_doc);
140 /** manage/edit triggered */ 140 /** manage/edit triggered */
141 //US ENH : changed code to run with older MOC 141 //US ENH : changed code to run with older MOC
142 void editPwd_slot(); 142 void editPwd_slot();
143 void editPwd_slot1(const QString *category); 143 void editPwd_slot1(const QString *category);
144 void editPwd_slot3(const QString *category = 0, const int *index = 0, 144 void editPwd_slot3(const QString *category, const int *index ,PwMDoc *_doc );
145 PwMDoc *_doc = 0);
146 145
147 /** manage/delete triggered */ 146 /** manage/delete triggered */
148 void deletePwd_slot(); 147 void deletePwd_slot();
149 /** execute the "Launcher" entry */ 148 /** execute the "Launcher" entry */
150 void execLauncher_slot(); 149 void execLauncher_slot();
151 /** open browser with URL entry */ 150 /** open browser with URL entry */
152 void goToURL_slot(); 151 void goToURL_slot();
153 /** manage/changeMasterPwd triggered */ 152 /** manage/changeMasterPwd triggered */
154 void changeMasterPwd_slot(); 153 void changeMasterPwd_slot();
155 /** lock current document */ 154 /** lock current document */
156 void lockWnd_slot(); 155 void lockWnd_slot();
157 /** deeplock current document */ 156 /** deeplock current document */
158 void deepLockWnd_slot(); 157 void deepLockWnd_slot();
159 /** window/unlock triggered */ 158 /** window/unlock triggered */
160 void unlockWnd_slot(); 159 void unlockWnd_slot();
161 /** find item */ 160 /** find item */
162 void find_slot(); 161 void find_slot();
163 /** configure clicked */ 162 /** configure clicked */
164 void config_slot(); 163 void config_slot();
165 /** (de)activate the "change master pw" button in the menu-bar */ 164 /** (de)activate the "change master pw" button in the menu-bar */
166 void activateMpButton(bool activate = true); 165 void activateMpButton(bool activate = true);
167 /** generate a new chipcard */ 166 /** generate a new chipcard */
168 void genNewCard_slot(); 167 void genNewCard_slot();
169 /** completely erase the current card */ 168 /** completely erase the current card */
170 void eraseCard_slot(); 169 void eraseCard_slot();
171 /** returns the ID number of the current card */ 170 /** returns the ID number of the current card */
172 void readCardId_slot(); 171 void readCardId_slot();
173 /** make backup image of the current card */ 172 /** make backup image of the current card */
174 void makeCardBackup_slot(); 173 void makeCardBackup_slot();
175 /** write backup image to current card */ 174 /** write backup image to current card */
176 void replayCardBackup_slot(); 175 void replayCardBackup_slot();
177 176
178#ifdef PWM_EMBEDDED 177#ifdef PWM_EMBEDDED
179 void whatsnew_slot(); 178 void whatsnew_slot();
180 void showLicense_slot(); 179 void showLicense_slot();
181 void faq_slot(); 180 void faq_slot();
182 void createAboutData_slot(); 181 void createAboutData_slot();
183 void syncHowTo_slot(); 182 void syncHowTo_slot();
184#endif 183#endif
185 184
186protected: 185protected:
187 /** is this window virgin? */ 186 /** is this window virgin? */
188 bool isVirgin() 187 bool isVirgin()
189 { return virgin; } 188 { return virgin; }
190 /** add/remove virginity */ 189 /** add/remove virginity */
191 void setVirgin(bool v); 190 void setVirgin(bool v);
192 /** initialize the menubar */ 191 /** initialize the menubar */
193 void initMenubar(); 192 void initMenubar();
194 /** initialize the toolbar */ 193 /** initialize the toolbar */
195 void initToolbar(); 194 void initToolbar();
196 /** initialize the window-metrics */ 195 /** initialize the window-metrics */
197 void initMetrics(); 196 void initMetrics();
198 /** close-event */ 197 /** close-event */
199 void closeEvent(QCloseEvent *e); 198 void closeEvent(QCloseEvent *e);
200 /** creates a new PwM-ListView and returns it */ 199 /** creates a new PwM-ListView and returns it */
201 PwMView * makeNewListView(PwMDoc *doc); 200 PwMView * makeNewListView(PwMDoc *doc);
202 /** Window hide-event */ 201 /** Window hide-event */
203 void hideEvent(QHideEvent *); 202 void hideEvent(QHideEvent *);
204 /** is this window minimized? */ 203 /** is this window minimized? */
205 bool isMinimized() 204 bool isMinimized()
206 { 205 {
207#ifndef PWM_EMBEDDED 206#ifndef PWM_EMBEDDED
208 #if KDE_VERSION >= KDE_MAKE_VERSION(3, 2, 0) 207 #if KDE_VERSION >= KDE_MAKE_VERSION(3, 2, 0)
209 return KWin::windowInfo(winId()).isMinimized(); 208 return KWin::windowInfo(winId()).isMinimized();
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,97 +1,97 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG += qt warn_on 2 CONFIG += qt warn_off
3DESTDIR= ../../bin 3DESTDIR= ../../bin
4 TARGET = pwmpi 4 TARGET = pwmpi
5include( ../../variables.pri ) 5include( ../../variables.pri )
6 6
7INCLUDEPATH += . ../../ ../../libkdepim ../../microkde ../../microkde/kdecore ../../microkde/kdeui ../../microkde/kutils 7INCLUDEPATH += . ../../ ../../libkdepim ../../microkde ../../microkde/kdecore ../../microkde/kdeui ../../microkde/kutils
8DEFINES += PWM_EMBEDDED CONFIG_PWMANAGER_GCRY DESKTOP_VERSION 8DEFINES += PWM_EMBEDDED CONFIG_PWMANAGER_GCRY DESKTOP_VERSION
9 9
10#enable this setting if you want debugoutput for pwmanager 10#enable this setting if you want debugoutput for pwmanager
11#DEFINES += CONFIG_DEBUG 11#DEFINES += CONFIG_DEBUG
12LIBS += -L../libcrypt/ 12LIBS += -L../libcrypt/
13LIBS += -L../../bin/ 13LIBS += -L../../bin/
14LIBS += -lmicrokde 14LIBS += -lmicrokde
15LIBS += -lmicrokdepim 15LIBS += -lmicrokdepim
16LIBS += -lzlib 16LIBS += -lzlib
17LIBS += -lkpmicrocipher 17LIBS += -lkpmicrocipher
18LIBS += -lkpmicroerror 18LIBS += -lkpmicroerror
19LIBS += -lkpmicrompi 19LIBS += -lkpmicrompi
20LIBS += -lstdc++ 20LIBS += -lstdc++
21 21
22unix:{ 22unix:{
23OBJECTS_DIR = obj/unix 23OBJECTS_DIR = obj/unix
24MOC_DIR = moc/unix 24MOC_DIR = moc/unix
25 25
26} 26}
27win32:{ 27win32:{
28 28
29DEFINES += _WIN32_ 29DEFINES += _WIN32_
30OBJECTS_DIR = obj/win 30OBJECTS_DIR = obj/win
31MOC_DIR = moc/win 31MOC_DIR = moc/win
32QMAKE_LINK += /NODEFAULTLIB:LIBC 32QMAKE_LINK += /NODEFAULTLIB:LIBC
33 33QMAKE_CXXFLAGS += /TP /GX /GR /Ehsc
34} 34}
35 35
36#INTERFACES = \ 36#INTERFACES = \
37#addentrywnd.ui \ 37#addentrywnd.ui \
38#configwnd.ui \ 38#configwnd.ui \
39#findwnd.ui \ 39#findwnd.ui \
40#getmasterpwwnd.ui \ 40#getmasterpwwnd.ui \
41#pwgenwnd.ui \ 41#pwgenwnd.ui \
42#setmasterpwwnd.ui \ 42#setmasterpwwnd.ui \
43#subtbledit.ui 43#subtbledit.ui
44 44
45#INTERFACES = \ 45#INTERFACES = \
46#subtbledit.ui \ 46#subtbledit.ui \
47 47
48 48
49 49
50#HEADERS = \ 50#HEADERS = \
51#configuration_31compat.h \ 51#configuration_31compat.h \
52#configuration.h \ 52#configuration.h \
53#configwnd.h \ 53#configwnd.h \
54#configwndimpl.h \ 54#configwndimpl.h \
55#selftest.h 55#selftest.h
56#subtbledit.h \ 56#subtbledit.h \
57#subtbleditimpl.h \ 57#subtbleditimpl.h \
58#compressbzip2.h \ 58#compressbzip2.h \
59 59
60HEADERS = \ 60HEADERS = \
61addentrywnd_emb.h \ 61addentrywnd_emb.h \
62addentrywndimpl.h \ 62addentrywndimpl.h \
63base64.h \ 63base64.h \
64binentrygen.h \ 64binentrygen.h \
65blowfish.h \ 65blowfish.h \
66commentbox.h \ 66commentbox.h \
67compiler.h \ 67compiler.h \
68compressgzip.h \ 68compressgzip.h \
69findwnd_emb.h \ 69findwnd_emb.h \
70findwndimpl.h \ 70findwndimpl.h \
71genpasswd.h \ 71genpasswd.h \
72getkeycardwnd.h \ 72getkeycardwnd.h \
73getmasterpwwnd_emb.h \ 73getmasterpwwnd_emb.h \
74getmasterpwwndimpl.h \ 74getmasterpwwndimpl.h \
75globalstuff.h \ 75globalstuff.h \
76gpasmanfile.h \ 76gpasmanfile.h \
77htmlgen.h \ 77htmlgen.h \
78htmlparse.h \ 78htmlparse.h \
79ipc.h \ 79ipc.h \
80libgcryptif.h \ 80libgcryptif.h \
81listobjselectwnd.h \ 81listobjselectwnd.h \
82listviewpwm.h \ 82listviewpwm.h \
83printtext.h \ 83printtext.h \
84pwgenwnd_emb.h \ 84pwgenwnd_emb.h \
85pwgenwndimpl.h \ 85pwgenwndimpl.h \
86pwmdoc.h \ 86pwmdoc.h \
87pwmdocui.h \ 87pwmdocui.h \
88pwmexception.h \ 88pwmexception.h \
89pwm.h \ 89pwm.h \
90pwminit.h \ 90pwminit.h \
91pwmprefs.h \ 91pwmprefs.h \
92pwmprint.h \ 92pwmprint.h \
93pwmtray.h \ 93pwmtray.h \
94pwmview.h \ 94pwmview.h \
95pwmviewstyle_0.h \ 95pwmviewstyle_0.h \
96pwmviewstyle_1.h \ 96pwmviewstyle_1.h \
97pwmviewstyle.h \ 97pwmviewstyle.h \
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,86 +1,88 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2003, 2004 by Michael Buesch * 3 * copyright (C) 2003, 2004 by Michael Buesch *
4 * email: mbuesch@freenet.de * 4 * email: mbuesch@freenet.de *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License version 2 * 7 * it under the terms of the GNU General Public License version 2 *
8 * as published by the Free Software Foundation. * 8 * as published by the Free Software Foundation. *
9 * * 9 * *
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12/*************************************************************************** 12/***************************************************************************
13 * copyright (C) 2004 by Ulf Schenk 13 * copyright (C) 2004 by Ulf Schenk
14 * This file is originaly based on version 1.1 of pwmanager 14 * This file is originaly based on version 1.1 of pwmanager
15 * and was modified to run on embedded devices that run microkde 15 * and was modified to run on embedded devices that run microkde
16 * 16 *
17 * $Id$ 17 * $Id$
18 **************************************************************************/ 18 **************************************************************************/
19 19
20#ifndef __PWMDOC_H 20#ifndef __PWMDOC_H
21#define __PWMDOC_H 21#define __PWMDOC_H
22 22#ifdef _WIN32_
23#define ssize_t unsigned int
24#endif
23 #define PWM_FILE_VER (static_cast<char>(0x05)) 25 #define PWM_FILE_VER (static_cast<char>(0x05))
24 26
25 #define PWM_HASH_SHA1 (static_cast<char>(0x01)) 27 #define PWM_HASH_SHA1 (static_cast<char>(0x01))
26 #define PWM_HASH_SHA256 (static_cast<char>(0x02)) 28 #define PWM_HASH_SHA256 (static_cast<char>(0x02))
27 #define PWM_HASH_SHA384 (static_cast<char>(0x03)) 29 #define PWM_HASH_SHA384 (static_cast<char>(0x03))
28 #define PWM_HASH_SHA512 (static_cast<char>(0x04)) 30 #define PWM_HASH_SHA512 (static_cast<char>(0x04))
29 #define PWM_HASH_MD5 (static_cast<char>(0x05)) 31 #define PWM_HASH_MD5 (static_cast<char>(0x05))
30 #define PWM_HASH_RMD160 (static_cast<char>(0x06)) 32 #define PWM_HASH_RMD160 (static_cast<char>(0x06))
31 #define PWM_HASH_TIGER (static_cast<char>(0x07)) 33 #define PWM_HASH_TIGER (static_cast<char>(0x07))
32 34
33 #define PWM_CRYPT_BLOWFISH(static_cast<char>(0x01)) 35 #define PWM_CRYPT_BLOWFISH(static_cast<char>(0x01))
34 #define PWM_CRYPT_AES128(static_cast<char>(0x02)) 36 #define PWM_CRYPT_AES128(static_cast<char>(0x02))
35 #define PWM_CRYPT_AES192(static_cast<char>(0x03)) 37 #define PWM_CRYPT_AES192(static_cast<char>(0x03))
36 #define PWM_CRYPT_AES256(static_cast<char>(0x04)) 38 #define PWM_CRYPT_AES256(static_cast<char>(0x04))
37 #define PWM_CRYPT_3DES (static_cast<char>(0x05)) 39 #define PWM_CRYPT_3DES (static_cast<char>(0x05))
38 #define PWM_CRYPT_TWOFISH(static_cast<char>(0x06)) 40 #define PWM_CRYPT_TWOFISH(static_cast<char>(0x06))
39 #define PWM_CRYPT_TWOFISH128(static_cast<char>(0x07)) 41 #define PWM_CRYPT_TWOFISH128(static_cast<char>(0x07))
40 42
41 #define PWM_COMPRESS_NONE(static_cast<char>(0x00)) 43 #define PWM_COMPRESS_NONE(static_cast<char>(0x00))
42 #define PWM_COMPRESS_GZIP(static_cast<char>(0x01)) 44 #define PWM_COMPRESS_GZIP(static_cast<char>(0x01))
43 #define PWM_COMPRESS_BZIP2(static_cast<char>(0x02)) 45 #define PWM_COMPRESS_BZIP2(static_cast<char>(0x02))
44 46
45 #define DEFAULT_MAX_ENTRIES(~(static_cast<unsigned int>(0))) 47 #define DEFAULT_MAX_ENTRIES(~(static_cast<unsigned int>(0)))
46 #define FILE_ID_HEADER "PWM_PASSWORD_FILE" 48 #define FILE_ID_HEADER "PWM_PASSWORD_FILE"
47 49
48 50
49#include "pwmexception.h" 51#include "pwmexception.h"
50#include "pwmdocui.h" 52#include "pwmdocui.h"
51 53
52#include <qobject.h> 54#include <qobject.h>
53#include <qtimer.h> 55#include <qtimer.h>
54#include <qdatetime.h> 56#include <qdatetime.h>
55 57
56#include <kprocess.h> 58#include <kprocess.h>
57 59
58#ifndef PWM_EMBEDDED 60#ifndef PWM_EMBEDDED
59#include "configuration.h" 61#include "configuration.h"
60#else 62#else
61#include <kapplication.h> 63#include <kapplication.h>
62#include <ksyncmanager.h> 64#include <ksyncmanager.h>
63#endif 65#endif
64 66
65#include <string> 67#include <string>
66#include <vector> 68#include <vector>
67#include <utility> 69#include <utility>
68 70
69using std::vector; 71using std::vector;
70using std::string; 72using std::string;
71using std::pair; 73using std::pair;
72 74
73/* used in findEntry() function */ 75/* used in findEntry() function */
74 #define SEARCH_IN_DESC (1) 76 #define SEARCH_IN_DESC (1)
75 #define SEARCH_IN_NAME (1 << 1) 77 #define SEARCH_IN_NAME (1 << 1)
76 #define SEARCH_IN_PW (1 << 2) 78 #define SEARCH_IN_PW (1 << 2)
77 #define SEARCH_IN_COMMENT(1 << 3) 79 #define SEARCH_IN_COMMENT(1 << 3)
78 #define SEARCH_IN_URL (1 << 4) 80 #define SEARCH_IN_URL (1 << 4)
79 #define SEARCH_IN_LAUNCHER(1 << 5) 81 #define SEARCH_IN_LAUNCHER(1 << 5)
80 #define SEARCH_IN_ALL (SEARCH_IN_DESC | SEARCH_IN_NAME| \ 82 #define SEARCH_IN_ALL (SEARCH_IN_DESC | SEARCH_IN_NAME| \
81 SEARCH_IN_PW | SEARCH_IN_COMMENT| \ 83 SEARCH_IN_PW | SEARCH_IN_COMMENT| \
82 SEARCH_IN_URL| SEARCH_IN_LAUNCHER) 84 SEARCH_IN_URL| SEARCH_IN_LAUNCHER)
83 85
84/** document deeplocked. Data is out for lunch to disk */ 86/** document deeplocked. Data is out for lunch to disk */
85 #define DOC_STAT_DEEPLOCKED (1) 87 #define DOC_STAT_DEEPLOCKED (1)
86/** encrypted document on disk is dirty. data has to go to disk. */ 88/** encrypted document on disk is dirty. data has to go to disk. */
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,103 +1,107 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2003, 2004 by Michael Buesch * 3 * copyright (C) 2003, 2004 by Michael Buesch *
4 * email: mbuesch@freenet.de * 4 * email: mbuesch@freenet.de *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License version 2 * 7 * it under the terms of the GNU General Public License version 2 *
8 * as published by the Free Software Foundation. * 8 * as published by the Free Software Foundation. *
9 * * 9 * *
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12/*************************************************************************** 12/***************************************************************************
13 * copyright (C) 2004 by Ulf Schenk 13 * copyright (C) 2004 by Ulf Schenk
14 * This file is originaly based on version 1.1 of pwmanager 14 * This file is originaly based on version 1.1 of pwmanager
15 * and was modified to run on embedded devices that run microkde 15 * and was modified to run on embedded devices that run microkde
16 * 16 *
17 * $Id$ 17 * $Id$
18 **************************************************************************/ 18 **************************************************************************/
19 19
20#include "randomizer.h" 20#include "randomizer.h"
21#include "pwmexception.h" 21#include "pwmexception.h"
22 22
23#include <qfile.h> 23#include <qfile.h>
24 24
25#include <kapplication.h> 25#include <kapplication.h>
26 26
27#include <stdlib.h> 27#include <stdlib.h>
28#include <time.h> 28#include <time.h>
29 29
30 30
31#ifdef PWM_EMBEDDED 31#ifdef PWM_EMBEDDED
32 32
33#ifndef Q_LONG 33#ifndef Q_LONG
34#define Q_LONG long 34#define Q_LONG long
35#endif 35#endif
36 36
37#endif //PWM_EMBEDDED 37#endif //PWM_EMBEDDED
38 38#ifdef _WIN32_
39 39int rand_r( uint * seed ) {
40 srand(*seed);
41 return rand();
42}
43#endif
40Randomizer * Randomizer::rndObj (0); 44Randomizer * Randomizer::rndObj (0);
41 45
42Randomizer::Randomizer() 46Randomizer::Randomizer()
43{ 47{
44 rndDev = new QFile; 48 rndDev = new QFile;
45 seed = time(0); 49 seed = time(0);
46 50
47#if 1 // set to 0 to test rand_r() fallback 51#if 1 // set to 0 to test rand_r() fallback
48 52
49 // probe for /dev/urandom 53 // probe for /dev/urandom
50 rndDev->setName("/dev/urandom"); 54 rndDev->setName("/dev/urandom");
51 if (rndDev->exists() && 55 if (rndDev->exists() &&
52 rndDev->open(IO_ReadOnly)) { 56 rndDev->open(IO_ReadOnly)) {
53 printDebug("Randomizer: using /dev/urandom"); 57 printDebug("Randomizer: using /dev/urandom");
54 return; 58 return;
55 } 59 }
56 60
57 // probe for /dev/random 61 // probe for /dev/random
58 rndDev->setName("/dev/random"); 62 rndDev->setName("/dev/random");
59 if (rndDev->exists() && 63 if (rndDev->exists() &&
60 rndDev->open(IO_ReadOnly)) { 64 rndDev->open(IO_ReadOnly)) {
61 printDebug("Randomizer: using /dev/random"); 65 printDebug("Randomizer: using /dev/random");
62 return; 66 return;
63 } 67 }
64 68
65 // probe for EGD 69 // probe for EGD
66 char *fn = getenv("RANDFILE"); 70 char *fn = getenv("RANDFILE");
67 if (fn) { 71 if (fn) {
68 rndDev->setName(fn); 72 rndDev->setName(fn);
69 if (rndDev->exists() && 73 if (rndDev->exists() &&
70 rndDev->open(IO_ReadOnly)) { 74 rndDev->open(IO_ReadOnly)) {
71 printDebug(string("Randomizer: using $RANDFILE \"") 75 printDebug(string("Randomizer: using $RANDFILE \"")
72 + fn 76 + fn
73 + "\" (aka EGD)"); 77 + "\" (aka EGD)");
74 return; 78 return;
75 } 79 }
76 } 80 }
77#endif 81#endif
78 82
79 /* no secure randomizer found. 83 /* no secure randomizer found.
80 * Fall back to stdlib randomizer. 84 * Fall back to stdlib randomizer.
81 */ 85 */
82 delete_and_null(rndDev); 86 delete_and_null(rndDev);
83 printWarn("neither /dev/*random nor EGD found! " 87 printWarn("neither /dev/*random nor EGD found! "
84 "Falling back to insecure rand_r()!"); 88 "Falling back to insecure rand_r()!");
85} 89}
86 90
87Randomizer::~Randomizer() 91Randomizer::~Randomizer()
88{ 92{
89#ifndef PWM_EMBEDDED 93#ifndef PWM_EMBEDDED
90 while (mutex.locked()) { 94 while (mutex.locked()) {
91 /* wait for the mutex to unlock. 95 /* wait for the mutex to unlock.
92 * Don't block the GUI here, so processEvents() 96 * Don't block the GUI here, so processEvents()
93 */ 97 */
94 kapp->processEvents(); 98 kapp->processEvents();
95 } 99 }
96#endif 100#endif
97 if (rndDev) { 101 if (rndDev) {
98 rndDev->close(); 102 rndDev->close();
99 delete rndDev; 103 delete rndDev;
100 } 104 }
101} 105}
102 106
103char Randomizer::genRndChar() 107char Randomizer::genRndChar()
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 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2003 by Michael Buesch * 3 * copyright (C) 2003 by Michael Buesch *
4 * email: mbuesch@freenet.de * 4 * email: mbuesch@freenet.de *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License version 2 * 7 * it under the terms of the GNU General Public License version 2 *
8 * as published by the Free Software Foundation. * 8 * as published by the Free Software Foundation. *
9 * * 9 * *
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12 12
13/*************************************************************************** 13/***************************************************************************
14 * copyright (C) 2004 by Ulf Schenk 14 * copyright (C) 2004 by Ulf Schenk
15 * This file is originaly based on version 1.0.1 of pwmanager 15 * This file is originaly based on version 1.0.1 of pwmanager
16 * and was modified to run on embedded devices that run microkde 16 * and was modified to run on embedded devices that run microkde
17 * 17 *
18 * $Id$ 18 * $Id$
19 **************************************************************************/ 19 **************************************************************************/
20 20
21#ifndef SETMASTERPWWNDIMPL_H 21#ifndef SETMASTERPWWNDIMPL_H
22#define SETMASTERPWWNDIMPL_H 22#define SETMASTERPWWNDIMPL_H
23 23
24#ifndef PWM_EMBEDDED 24#ifndef PWM_EMBEDDED
25#include "setmasterpwwnd.h" 25#include "setmasterpwwnd.h"
26#else 26#else
27#include "setmasterpwwnd_emb.h" 27#include "setmasterpwwnd_emb.h"
28#endif 28#endif
29 29
30#include <klocale.h> 30#include <klocale.h>
31 31
32#ifdef _WIN32_
33#define uint32_t Q_UINT32
34#else
32#include <stdint.h> 35#include <stdint.h>
36#endif
33#include <string> 37#include <string>
34using std::string; 38using std::string;
35 39
36class PwMKeyCard; 40class PwMKeyCard;
37 41
38/** set master pw wnd */ 42/** set master pw wnd */
39class SetMasterPwWndImpl : public setMasterPwWnd 43class SetMasterPwWndImpl : public setMasterPwWnd
40{ 44{
41 Q_OBJECT 45 Q_OBJECT
42public: 46public:
43 SetMasterPwWndImpl(QWidget* parent = 0, const char *name = 0); 47 SetMasterPwWndImpl(QWidget* parent = 0, const char *name = 0);
44 ~SetMasterPwWndImpl(); 48 ~SetMasterPwWndImpl();
45 49
46 static QString string_cardNone() 50 static QString string_cardNone()
47 { return i18n("NONE"); } 51 { return i18n("NONE"); }
48 52
49 /** returns the selected pw (or the key on the card) */ 53 /** returns the selected pw (or the key on the card) */
50 string getPw(bool *useCard); 54 string getPw(bool *useCard);
51 /** set pointer to the keycard-access object */ 55 /** set pointer to the keycard-access object */
52 void setPwMKeyCard(PwMKeyCard *_keyCard) 56 void setPwMKeyCard(PwMKeyCard *_keyCard)
53 { keyCard = _keyCard; } 57 { keyCard = _keyCard; }
54 58
55public slots: 59public slots:
56 /** ok button pressed */ 60 /** ok button pressed */
57 void okButton_slot(); 61 void okButton_slot();
58 /** cancel button pressed */ 62 /** cancel button pressed */
59 void cancelButton_slot(); 63 void cancelButton_slot();
60 /** "generate a new card" button pressed */ 64 /** "generate a new card" button pressed */
61 void genCardButton_slot(); 65 void genCardButton_slot();
62 /** "select current card" button pressed */ 66 /** "select current card" button pressed */
63 void selCardButton_slot(); 67 void selCardButton_slot();
64 68
65#ifdef PWM_EMBEDDED 69#ifdef PWM_EMBEDDED
66 virtual void slotOk(); 70 virtual void slotOk();
67#endif 71#endif
68 72
69protected slots: 73protected slots:
70 /** key from PwMKeyCard is available */ 74 /** key from PwMKeyCard is available */
71 void keyAvailable_slot(uint32_t cardId, const string &key); 75 void keyAvailable_slot(uint32_t cardId, const string &key);
72 76
73protected: 77protected:
74 /** key of currently inserted card */ 78 /** key of currently inserted card */
75 string curCardKey; 79 string curCardKey;
76 /** pointer to the keycard-access object */ 80 /** pointer to the keycard-access object */
77 PwMKeyCard *keyCard; 81 PwMKeyCard *keyCard;
78}; 82};
79 83
80#endif 84#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 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2003 by Michael Buesch * 3 * copyright (C) 2003 by Michael Buesch *
4 * email: mbuesch@freenet.de * 4 * email: mbuesch@freenet.de *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License version 2 * 7 * it under the terms of the GNU General Public License version 2 *
8 * as published by the Free Software Foundation. * 8 * as published by the Free Software Foundation. *
9 * * 9 * *
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12/*************************************************************************** 12/***************************************************************************
13 * copyright (C) 2004 by Ulf Schenk 13 * copyright (C) 2004 by Ulf Schenk
14 * This file is originaly based on version 1.0.1 of pwmanager 14 * This file is originaly based on version 1.0.1 of pwmanager
15 * and was modified to run on embedded devices that run microkde 15 * and was modified to run on embedded devices that run microkde
16 * 16 *
17 * $Id$ 17 * $Id$
18 **************************************************************************/ 18 **************************************************************************/
19 19
20#ifndef SHA1_H 20#ifndef SHA1_H
21#define SHA1_H 21#define SHA1_H
22 22#ifdef _WIN32_
23#define uint32_t unsigned int
24 #define uint8_tunsigned char
25 #define byteunsigned char
26#else
23#include <stdint.h> 27#include <stdint.h>
28 typedef uint8_t byte;
29#endif
24#include <string> 30#include <string>
25using std::string; 31using std::string;
26 32
27 typedef uint8_t byte;
28 33
29 #define SHA1_HASH_LEN_BIT160 34 #define SHA1_HASH_LEN_BIT160
30 #define SHA1_HASH_LEN_BYTE(SHA1_HASH_LEN_BIT / 8) 35 #define SHA1_HASH_LEN_BYTE(SHA1_HASH_LEN_BIT / 8)
31 36
32/** sha1 hash algorithm. 37/** sha1 hash algorithm.
33 * Derived from libgcrypt-1.1.12 38 * Derived from libgcrypt-1.1.12
34 */ 39 */
35class Sha1 40class Sha1
36{ 41{
37 struct SHA1_CONTEXT 42 struct SHA1_CONTEXT
38 { 43 {
39 uint32_t h0,h1,h2,h3,h4; 44 uint32_t h0,h1,h2,h3,h4;
40 uint32_t nblocks; 45 uint32_t nblocks;
41 byte buf[64]; 46 byte buf[64];
42 int count; 47 int count;
43 }; 48 };
44 49
45public: 50public:
46 Sha1() { sha1_init(); } 51 Sha1() { sha1_init(); }
47 static bool selfTest(); 52 static bool selfTest();
48 53
49 void sha1_write(const byte *inbuf, uint32_t inlen); 54 void sha1_write(const byte *inbuf, uint32_t inlen);
50 string sha1_read(); 55 string sha1_read();
51 56
52protected: 57protected:
53 void sha1_init(); 58 void sha1_init();
54 void sha1_final(); 59 void sha1_final();
55 void burn_stack (int bytes); 60 void burn_stack (int bytes);
56 void transform(const byte *data); 61 void transform(const byte *data);
57 62
58 /** Rotate a 32 bit integer by n bytes */ 63 /** Rotate a 32 bit integer by n bytes */
59 uint32_t rol(uint32_t x, int n) 64 uint32_t rol(uint32_t x, int n)
60 { 65 {
61#if defined(__GNUC__) && defined(__i386__) 66#if defined(__GNUC__) && defined(__i386__)
62 __asm__("roll %%cl,%0" 67 __asm__("roll %%cl,%0"
63 :"=r" (x) 68 :"=r" (x)
64 :"0" (x),"c" (n)); 69 :"0" (x),"c" (n));
65 return x; 70 return x;
66#else 71#else
67 return ((x) << (n)) | ((x) >> (32-(n))); 72 return ((x) << (n)) | ((x) >> (32-(n)));
68#endif 73#endif
69 } 74 }
70 75
71protected: 76protected:
72 struct SHA1_CONTEXT ctx; 77 struct SHA1_CONTEXT ctx;
73}; 78};
74 79
75#endif 80#endif