author | ulf69 <ulf69> | 2004-10-16 01:05:12 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-10-16 01:05:12 (UTC) |
commit | a6b0eba5c1aac3ba170b99c2b773fcabe10d8a40 (patch) (unidiff) | |
tree | 874b41d93e8cf796125038ea4fb5861788cfb2dd | |
parent | 6f229ba483beece68b9c408fb754864c8f0e3167 (diff) | |
download | kdepimpi-a6b0eba5c1aac3ba170b99c2b773fcabe10d8a40.zip kdepimpi-a6b0eba5c1aac3ba170b99c2b773fcabe10d8a40.tar.gz kdepimpi-a6b0eba5c1aac3ba170b99c2b773fcabe10d8a40.tar.bz2 |
removed references to bzip2 compressformat
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp index a5df8f0..0ac5517 100644 --- a/pwmanager/pwmanager/pwmdoc.cpp +++ b/pwmanager/pwmanager/pwmdoc.cpp | |||
@@ -1,92 +1,92 @@ | |||
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 2.0 of pwmanager | 14 | * This file is originaly based on version 2.0 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 "pwmdoc.h" | 20 | #include "pwmdoc.h" |
21 | #include "pwmview.h" | 21 | #include "pwmview.h" |
22 | #include "blowfish.h" | 22 | #include "blowfish.h" |
23 | #include "sha1.h" | 23 | #include "sha1.h" |
24 | #include "globalstuff.h" | 24 | #include "globalstuff.h" |
25 | #include "gpasmanfile.h" | 25 | #include "gpasmanfile.h" |
26 | #include "serializer.h" | 26 | #include "serializer.h" |
27 | #include "compressgzip.h" | 27 | #include "compressgzip.h" |
28 | #include "compressbzip2.h" | 28 | //US#include "compressbzip2.h" |
29 | #include "randomizer.h" | 29 | #include "randomizer.h" |
30 | #include "pwminit.h" | 30 | #include "pwminit.h" |
31 | #include "libgcryptif.h" | 31 | #include "libgcryptif.h" |
32 | #ifdef PWM_EMBEDDED | 32 | #ifdef PWM_EMBEDDED |
33 | #include "pwmprefs.h" | 33 | #include "pwmprefs.h" |
34 | #include "kglobal.h" | 34 | #include "kglobal.h" |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | #include <kmessagebox.h> | 37 | #include <kmessagebox.h> |
38 | #include <libkcal/syncdefines.h> | 38 | #include <libkcal/syncdefines.h> |
39 | 39 | ||
40 | 40 | ||
41 | #ifdef CONFIG_KWALLETIF | 41 | #ifdef CONFIG_KWALLETIF |
42 | # include "kwalletemu.h" | 42 | # include "kwalletemu.h" |
43 | #endif // CONFIG_KWALLETIF | 43 | #endif // CONFIG_KWALLETIF |
44 | 44 | ||
45 | #include <qdatetime.h> | 45 | #include <qdatetime.h> |
46 | #include <qsize.h> | 46 | #include <qsize.h> |
47 | #include <qfileinfo.h> | 47 | #include <qfileinfo.h> |
48 | #include <qfile.h> | 48 | #include <qfile.h> |
49 | 49 | ||
50 | #include <stdio.h> | 50 | #include <stdio.h> |
51 | #include <stdlib.h> | 51 | #include <stdlib.h> |
52 | #include <errno.h> | 52 | #include <errno.h> |
53 | #include <string.h> | 53 | #include <string.h> |
54 | //US#include <iostream> | 54 | //US#include <iostream> |
55 | #include <algorithm> | 55 | #include <algorithm> |
56 | #include <sys/types.h> | 56 | #include <sys/types.h> |
57 | #include <sys/stat.h> | 57 | #include <sys/stat.h> |
58 | #include <unistd.h> | 58 | #include <unistd.h> |
59 | #include <stdint.h> | 59 | #include <stdint.h> |
60 | 60 | ||
61 | 61 | ||
62 | #ifdef PWM_EMBEDDED | 62 | #ifdef PWM_EMBEDDED |
63 | #ifndef Q_LONG | 63 | #ifndef Q_LONG |
64 | #define Q_LONG long | 64 | #define Q_LONG long |
65 | #endif | 65 | #endif |
66 | 66 | ||
67 | #ifndef Q_ULONG | 67 | #ifndef Q_ULONG |
68 | #define Q_ULONG unsigned long | 68 | #define Q_ULONG unsigned long |
69 | #endif | 69 | #endif |
70 | #endif //PWM_EMBEDDED | 70 | #endif //PWM_EMBEDDED |
71 | 71 | ||
72 | 72 | ||
73 | //TODO: reset to its normal value. | 73 | //TODO: reset to its normal value. |
74 | #define META_CHECK_TIMER_INTERVAL10/*300*/ /* sek */ | 74 | #define META_CHECK_TIMER_INTERVAL10/*300*/ /* sek */ |
75 | 75 | ||
76 | using namespace std; | 76 | using namespace std; |
77 | 77 | ||
78 | 78 | ||
79 | void PwMDocList::add(PwMDoc *doc, const string &id) | 79 | void PwMDocList::add(PwMDoc *doc, const string &id) |
80 | { | 80 | { |
81 | #ifdef PWM_DEBUG | 81 | #ifdef PWM_DEBUG |
82 | // check for existance of object in debug mode only. | 82 | // check for existance of object in debug mode only. |
83 | vector<listItem>::iterator begin = docList.begin(), | 83 | vector<listItem>::iterator begin = docList.begin(), |
84 | end = docList.end(), | 84 | end = docList.end(), |
85 | i = begin; | 85 | i = begin; |
86 | while (i != end) { | 86 | while (i != end) { |
87 | if (i->doc == doc) { | 87 | if (i->doc == doc) { |
88 | BUG(); | 88 | BUG(); |
89 | return; | 89 | return; |
90 | } | 90 | } |
91 | ++i; | 91 | ++i; |
92 | } | 92 | } |
@@ -1158,150 +1158,152 @@ bool PwMDoc::getEntry(const QString &category, unsigned int index, | |||
1158 | if (!findCategory(category, &cat)) { | 1158 | if (!findCategory(category, &cat)) { |
1159 | BUG(); | 1159 | BUG(); |
1160 | return false; | 1160 | return false; |
1161 | } | 1161 | } |
1162 | 1162 | ||
1163 | return getEntry(cat, index, d, unlockIfLocked); | 1163 | return getEntry(cat, index, d, unlockIfLocked); |
1164 | } | 1164 | } |
1165 | 1165 | ||
1166 | bool PwMDoc::getEntry(unsigned int category, unsigned int index, | 1166 | bool PwMDoc::getEntry(unsigned int category, unsigned int index, |
1167 | PwMDataItem *d, bool unlockIfLocked) | 1167 | PwMDataItem *d, bool unlockIfLocked) |
1168 | { | 1168 | { |
1169 | if (index > dti.dta[category].d.size() - 1) | 1169 | if (index > dti.dta[category].d.size() - 1) |
1170 | return false; | 1170 | return false; |
1171 | 1171 | ||
1172 | bool locked = isLocked(category, index); | 1172 | bool locked = isLocked(category, index); |
1173 | if (locked) { | 1173 | if (locked) { |
1174 | /* this entry is locked. We don't return a password, | 1174 | /* this entry is locked. We don't return a password, |
1175 | * until it's unlocked by the user by inserting | 1175 | * until it's unlocked by the user by inserting |
1176 | * chipcard or entering the mpw | 1176 | * chipcard or entering the mpw |
1177 | */ | 1177 | */ |
1178 | if (unlockIfLocked) { | 1178 | if (unlockIfLocked) { |
1179 | if (!lockAt(category, index, false)) { | 1179 | if (!lockAt(category, index, false)) { |
1180 | return false; | 1180 | return false; |
1181 | } | 1181 | } |
1182 | locked = false; | 1182 | locked = false; |
1183 | } | 1183 | } |
1184 | } | 1184 | } |
1185 | 1185 | ||
1186 | *d = dti.dta[category].d[index]; | 1186 | *d = dti.dta[category].d[index]; |
1187 | if (locked) | 1187 | if (locked) |
1188 | d->pw = LOCKED_STRING.latin1(); | 1188 | d->pw = LOCKED_STRING.latin1(); |
1189 | 1189 | ||
1190 | return true; | 1190 | return true; |
1191 | } | 1191 | } |
1192 | 1192 | ||
1193 | PwMerror PwMDoc::getCommentByLvp(const QString &category, int listViewPos, | 1193 | PwMerror PwMDoc::getCommentByLvp(const QString &category, int listViewPos, |
1194 | string *foundComment) | 1194 | string *foundComment) |
1195 | { | 1195 | { |
1196 | PWM_ASSERT(foundComment); | 1196 | PWM_ASSERT(foundComment); |
1197 | unsigned int cat = 0; | 1197 | unsigned int cat = 0; |
1198 | 1198 | ||
1199 | if (!findCategory(category, &cat)) | 1199 | if (!findCategory(category, &cat)) |
1200 | return e_invalidArg; | 1200 | return e_invalidArg; |
1201 | 1201 | ||
1202 | unsigned int i, entries = numEntries(cat); | 1202 | unsigned int i, entries = numEntries(cat); |
1203 | for (i = 0; i < entries; ++i) { | 1203 | for (i = 0; i < entries; ++i) { |
1204 | if (dti.dta[cat].d[i].listViewPos == listViewPos) { | 1204 | if (dti.dta[cat].d[i].listViewPos == listViewPos) { |
1205 | *foundComment = dti.dta[cat].d[i].comment; | 1205 | *foundComment = dti.dta[cat].d[i].comment; |
1206 | if (dti.dta[cat].d[i].binary) | 1206 | if (dti.dta[cat].d[i].binary) |
1207 | return e_binEntry; | 1207 | return e_binEntry; |
1208 | return e_normalEntry; | 1208 | return e_normalEntry; |
1209 | } | 1209 | } |
1210 | } | 1210 | } |
1211 | BUG(); | 1211 | BUG(); |
1212 | return e_generic; | 1212 | return e_generic; |
1213 | } | 1213 | } |
1214 | 1214 | ||
1215 | bool PwMDoc::compressDta(string *d, char algo) | 1215 | bool PwMDoc::compressDta(string *d, char algo) |
1216 | { | 1216 | { |
1217 | PWM_ASSERT(d); | 1217 | PWM_ASSERT(d); |
1218 | switch (algo) { | 1218 | switch (algo) { |
1219 | case PWM_COMPRESS_GZIP: { | 1219 | case PWM_COMPRESS_GZIP: { |
1220 | CompressGzip comp; | 1220 | CompressGzip comp; |
1221 | return comp.compress(d); | 1221 | return comp.compress(d); |
1222 | } case PWM_COMPRESS_BZIP2: { | 1222 | /*US } case PWM_COMPRESS_BZIP2: { |
1223 | CompressBzip2 comp; | 1223 | CompressBzip2 comp; |
1224 | return comp.compress(d); | 1224 | return comp.compress(d); |
1225 | */ | ||
1225 | } case PWM_COMPRESS_NONE: { | 1226 | } case PWM_COMPRESS_NONE: { |
1226 | return true; | 1227 | return true; |
1227 | } default: { | 1228 | } default: { |
1228 | BUG(); | 1229 | BUG(); |
1229 | } | 1230 | } |
1230 | } | 1231 | } |
1231 | return false; | 1232 | return false; |
1232 | } | 1233 | } |
1233 | 1234 | ||
1234 | bool PwMDoc::decompressDta(string *d, char algo) | 1235 | bool PwMDoc::decompressDta(string *d, char algo) |
1235 | { | 1236 | { |
1236 | PWM_ASSERT(d); | 1237 | PWM_ASSERT(d); |
1237 | switch (algo) { | 1238 | switch (algo) { |
1238 | case PWM_COMPRESS_GZIP: { | 1239 | case PWM_COMPRESS_GZIP: { |
1239 | CompressGzip comp; | 1240 | CompressGzip comp; |
1240 | return comp.decompress(d); | 1241 | return comp.decompress(d); |
1241 | } case PWM_COMPRESS_BZIP2: { | 1242 | /*US } case PWM_COMPRESS_BZIP2: { |
1242 | CompressBzip2 comp; | 1243 | CompressBzip2 comp; |
1243 | return comp.decompress(d); | 1244 | return comp.decompress(d); |
1245 | */ | ||
1244 | } case PWM_COMPRESS_NONE: { | 1246 | } case PWM_COMPRESS_NONE: { |
1245 | return true; | 1247 | return true; |
1246 | } | 1248 | } |
1247 | } | 1249 | } |
1248 | return false; | 1250 | return false; |
1249 | } | 1251 | } |
1250 | 1252 | ||
1251 | PwMerror PwMDoc::encrypt(string *d, const QString *pw, QFile *f, char algo) | 1253 | PwMerror PwMDoc::encrypt(string *d, const QString *pw, QFile *f, char algo) |
1252 | { | 1254 | { |
1253 | PWM_ASSERT(d); | 1255 | PWM_ASSERT(d); |
1254 | PWM_ASSERT(pw); | 1256 | PWM_ASSERT(pw); |
1255 | PWM_ASSERT(f); | 1257 | PWM_ASSERT(f); |
1256 | 1258 | ||
1257 | size_t encSize; | 1259 | size_t encSize; |
1258 | byte *encrypted = 0; | 1260 | byte *encrypted = 0; |
1259 | 1261 | ||
1260 | switch (algo) { | 1262 | switch (algo) { |
1261 | case PWM_CRYPT_BLOWFISH: { | 1263 | case PWM_CRYPT_BLOWFISH: { |
1262 | Blowfish::padNull(d); | 1264 | Blowfish::padNull(d); |
1263 | encSize = d->length(); | 1265 | encSize = d->length(); |
1264 | encrypted = new byte[encSize]; | 1266 | encrypted = new byte[encSize]; |
1265 | Blowfish bf; | 1267 | Blowfish bf; |
1266 | if (bf.bf_setkey((byte *) pw->latin1(), pw->length())) { | 1268 | if (bf.bf_setkey((byte *) pw->latin1(), pw->length())) { |
1267 | delete [] encrypted; | 1269 | delete [] encrypted; |
1268 | return e_weakPw; | 1270 | return e_weakPw; |
1269 | } | 1271 | } |
1270 | bf.bf_encrypt((byte *) encrypted, (byte *) d->c_str(), encSize); | 1272 | bf.bf_encrypt((byte *) encrypted, (byte *) d->c_str(), encSize); |
1271 | break; | 1273 | break; |
1272 | } | 1274 | } |
1273 | case PWM_CRYPT_AES128: | 1275 | case PWM_CRYPT_AES128: |
1274 | /*... fall through */ | 1276 | /*... fall through */ |
1275 | case PWM_CRYPT_AES192: | 1277 | case PWM_CRYPT_AES192: |
1276 | case PWM_CRYPT_AES256: | 1278 | case PWM_CRYPT_AES256: |
1277 | case PWM_CRYPT_3DES: | 1279 | case PWM_CRYPT_3DES: |
1278 | case PWM_CRYPT_TWOFISH: | 1280 | case PWM_CRYPT_TWOFISH: |
1279 | case PWM_CRYPT_TWOFISH128: { | 1281 | case PWM_CRYPT_TWOFISH128: { |
1280 | if (!LibGCryptIf::available()) | 1282 | if (!LibGCryptIf::available()) |
1281 | return e_cryptNotImpl; | 1283 | return e_cryptNotImpl; |
1282 | LibGCryptIf gc; | 1284 | LibGCryptIf gc; |
1283 | PwMerror err; | 1285 | PwMerror err; |
1284 | unsigned char *plain = new unsigned char[d->length() + 1024]; | 1286 | unsigned char *plain = new unsigned char[d->length() + 1024]; |
1285 | memcpy(plain, d->c_str(), d->length()); | 1287 | memcpy(plain, d->c_str(), d->length()); |
1286 | err = gc.encrypt(&encrypted, | 1288 | err = gc.encrypt(&encrypted, |
1287 | &encSize, | 1289 | &encSize, |
1288 | plain, | 1290 | plain, |
1289 | d->length(), | 1291 | d->length(), |
1290 | reinterpret_cast<const unsigned char *>(pw->latin1()), | 1292 | reinterpret_cast<const unsigned char *>(pw->latin1()), |
1291 | pw->length(), | 1293 | pw->length(), |
1292 | algo); | 1294 | algo); |
1293 | delete [] plain; | 1295 | delete [] plain; |
1294 | if (err != e_success) | 1296 | if (err != e_success) |
1295 | return e_cryptNotImpl; | 1297 | return e_cryptNotImpl; |
1296 | break; | 1298 | break; |
1297 | } | 1299 | } |
1298 | default: { | 1300 | default: { |
1299 | delete_ifnot_null_array(encrypted); | 1301 | delete_ifnot_null_array(encrypted); |
1300 | return e_cryptNotImpl; | 1302 | return e_cryptNotImpl; |
1301 | } } | 1303 | } } |
1302 | 1304 | ||
1303 | // write encrypted data to file | 1305 | // write encrypted data to file |
1304 | if (f->writeBlock(reinterpret_cast<const char *>(encrypted), | 1306 | if (f->writeBlock(reinterpret_cast<const char *>(encrypted), |
1305 | static_cast<Q_ULONG>(encSize)) | 1307 | static_cast<Q_ULONG>(encSize)) |
1306 | != static_cast<Q_LONG>(encSize)) { | 1308 | != static_cast<Q_LONG>(encSize)) { |
1307 | delete_ifnot_null_array(encrypted); | 1309 | delete_ifnot_null_array(encrypted); |