-rw-r--r-- | pwmanager/pwmanager/libgcryptif.cpp | 25 | ||||
-rw-r--r-- | pwmanager/pwmanager/libgcryptif.h | 12 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.cpp | 20 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.h | 8 |
4 files changed, 46 insertions, 19 deletions
diff --git a/pwmanager/pwmanager/libgcryptif.cpp b/pwmanager/pwmanager/libgcryptif.cpp index ff94bf6..15f6cef 100644 --- a/pwmanager/pwmanager/libgcryptif.cpp +++ b/pwmanager/pwmanager/libgcryptif.cpp | |||
@@ -43,3 +43,5 @@ PwMerror LibGCryptIf::encrypt(unsigned char **outBuf, | |||
43 | size_t keylen, | 43 | size_t keylen, |
44 | char _algo) | 44 | char _algo, |
45 | char _hashalgo //US BUG: pass _hashalgo because we need it in hashPassphrase | ||
46 | ) | ||
45 | { | 47 | { |
@@ -107,3 +109,3 @@ PwMerror LibGCryptIf::encrypt(unsigned char **outBuf, | |||
107 | hashedKey = new unsigned char[cipherKeylen]; | 109 | hashedKey = new unsigned char[cipherKeylen]; |
108 | hashPassphrase(key, keylen, salt, hashedKey, cipherKeylen, true); | 110 | hashPassphrase(key, keylen, salt, hashedKey, cipherKeylen, true, _hashalgo); |
109 | // so now set the hashed key | 111 | // so now set the hashed key |
@@ -154,3 +156,5 @@ PwMerror LibGCryptIf::decrypt(unsigned char **outBuf, | |||
154 | size_t keylen, | 156 | size_t keylen, |
155 | char _algo) | 157 | char _algo, |
158 | char _hashalgo //US BUG: pass _hashalgo because we need it in hashPassphrase | ||
159 | ) | ||
156 | { | 160 | { |
@@ -203,3 +207,3 @@ PwMerror LibGCryptIf::decrypt(unsigned char **outBuf, | |||
203 | hashedKey = new unsigned char[cipherKeylen]; | 207 | hashedKey = new unsigned char[cipherKeylen]; |
204 | hashPassphrase(key, keylen, salt, hashedKey, cipherKeylen, false); | 208 | hashPassphrase(key, keylen, salt, hashedKey, cipherKeylen, false, _hashalgo); |
205 | // so now set the hashed key | 209 | // so now set the hashed key |
@@ -316,3 +320,5 @@ bool LibGCryptIf::hashPassphrase(const unsigned char *pw, | |||
316 | size_t keylen, | 320 | size_t keylen, |
317 | bool create) | 321 | bool create, |
322 | char _hashalgo //US BUG: pass _hashalgo because we need it in hashPassphrase | ||
323 | ) | ||
318 | { | 324 | { |
@@ -324,3 +330,6 @@ bool LibGCryptIf::hashPassphrase(const unsigned char *pw, | |||
324 | s2k.mode = 1; | 330 | s2k.mode = 1; |
325 | s2k.hash_algo = mapHashId(conf()->confGlobHashAlgo()); | 331 | //US bug: do not use the global hash algo here. Use the passed ago instead. The hashalgo stored in the file can |
332 | // be different from the one in the configuration. | ||
333 | s2k.hash_algo = mapHashId(_hashalgo //conf()->confGlobHashAlgo() | ||
334 | ); | ||
326 | s2k.count = 0; | 335 | s2k.count = 0; |
@@ -441,3 +450,3 @@ void LibGCryptIf::unpadData(const unsigned char *buf, | |||
441 | while (buf[pos] != static_cast<char>(0x01)) { | 450 | while (buf[pos] != static_cast<char>(0x01)) { |
442 | qDebug("pos %d %d %d", pos, buf[pos], static_cast<char>(0x01) ); | 451 | //qDebug("pos %d %d %d", pos, buf[pos], static_cast<char>(0x01) ); |
443 | BUG_ON(!pos); | 452 | BUG_ON(!pos); |
@@ -449,3 +458,3 @@ void LibGCryptIf::unpadData(const unsigned char *buf, | |||
449 | *bufLen = pos; | 458 | *bufLen = pos; |
450 | qDebug("ente "); | 459 | //qDebug("ente "); |
451 | } | 460 | } |
diff --git a/pwmanager/pwmanager/libgcryptif.h b/pwmanager/pwmanager/libgcryptif.h index 1a7b658..9a987a2 100644 --- a/pwmanager/pwmanager/libgcryptif.h +++ b/pwmanager/pwmanager/libgcryptif.h | |||
@@ -75,3 +75,5 @@ public: | |||
75 | size_t keylen, | 75 | size_t keylen, |
76 | char _algo); | 76 | char _algo, |
77 | char _hashalgo //US BUG: pass _hashalgo because we need it in hashPassphrase | ||
78 | ); | ||
77 | /** decrypt data. _algo is the PWM_CRYPT_* ID | 79 | /** decrypt data. _algo is the PWM_CRYPT_* ID |
@@ -85,3 +87,5 @@ public: | |||
85 | size_t keylen, | 87 | size_t keylen, |
86 | char _algo); | 88 | char _algo, |
89 | char _hashalgo //US BUG: pass _hashalgo because we need it in hashPassphrase | ||
90 | ); | ||
87 | /** hash data. _algo is the PWM_HASH_* ID of the hash */ | 91 | /** hash data. _algo is the PWM_HASH_* ID of the hash */ |
@@ -126,3 +130,5 @@ protected: | |||
126 | size_t keylen, | 130 | size_t keylen, |
127 | bool create); | 131 | bool create, |
132 | char _hashalgo //US BUG: pass _hashalgo because we need it in hashPassphrase | ||
133 | ); | ||
128 | /** hash a passphrase to a cipher key */ | 134 | /** hash a passphrase to a cipher key */ |
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp index 17cb74a..a740d6d 100644 --- a/pwmanager/pwmanager/pwmdoc.cpp +++ b/pwmanager/pwmanager/pwmdoc.cpp | |||
@@ -489,3 +489,3 @@ PwMerror PwMDoc::saveDoc(char compress, const QString *file) | |||
489 | } | 489 | } |
490 | e = encrypt(&serialized, ¤tPw, &f, cryptAlgo); | 490 | e = encrypt(&serialized, ¤tPw, &f, cryptAlgo, hashAlgo); |
491 | if (e == e_weakPw) { | 491 | if (e == e_weakPw) { |
@@ -609,3 +609,3 @@ PwMerror PwMDoc::openDoc(const QString *file, int openLocked) | |||
609 | } | 609 | } |
610 | ret = decrypt(&decrypted, headerLen, ¤tPw, cryptAlgo, &f); | 610 | ret = decrypt(&decrypted, headerLen, ¤tPw, cryptAlgo, dataHashType, &f); |
611 | if (ret == e_cryptNotImpl) { | 611 | if (ret == e_cryptNotImpl) { |
@@ -1309,3 +1309,5 @@ bool PwMDoc::decompressDta(string *d, char algo) | |||
1309 | 1309 | ||
1310 | PwMerror PwMDoc::encrypt(string *d, const QString *pw, QFile *f, char algo) | 1310 | PwMerror PwMDoc::encrypt(string *d, const QString *pw, QFile *f, char algo, |
1311 | char hashalgo //US BUG: pass _hashalgo because we need it in hashPassphrase | ||
1312 | ) | ||
1311 | { | 1313 | { |
@@ -1350,3 +1352,5 @@ PwMerror PwMDoc::encrypt(string *d, const QString *pw, QFile *f, char algo) | |||
1350 | pw->length(), | 1352 | pw->length(), |
1351 | algo); | 1353 | algo, |
1354 | hashalgo //US BUG: pass _hashalgo because we need it in hashPassphrase | ||
1355 | ); | ||
1352 | delete [] plain; | 1356 | delete [] plain; |
@@ -1373,3 +1377,5 @@ PwMerror PwMDoc::encrypt(string *d, const QString *pw, QFile *f, char algo) | |||
1373 | PwMerror PwMDoc::decrypt(string *d, unsigned int pos, const QString *pw, | 1377 | PwMerror PwMDoc::decrypt(string *d, unsigned int pos, const QString *pw, |
1374 | char algo, QFile *f) | 1378 | char algo, |
1379 | char hashalgo, //US BUG: pass _hashalgo because we need it in hashPassphrase | ||
1380 | QFile *f) | ||
1375 | { | 1381 | { |
@@ -1425,3 +1431,5 @@ PwMerror PwMDoc::decrypt(string *d, unsigned int pos, const QString *pw, | |||
1425 | pw->length(), | 1431 | pw->length(), |
1426 | algo); | 1432 | algo, |
1433 | hashalgo //US BUG: pass _hashalgo because we need it in hashPassphrase | ||
1434 | ); | ||
1427 | if (err != e_success) { | 1435 | if (err != e_success) { |
diff --git a/pwmanager/pwmanager/pwmdoc.h b/pwmanager/pwmanager/pwmdoc.h index 138dd3d..9fcdda7 100644 --- a/pwmanager/pwmanager/pwmdoc.h +++ b/pwmanager/pwmanager/pwmdoc.h | |||
@@ -738,5 +738,9 @@ protected: | |||
738 | /** encrypt data "d" and write to "filename" */ | 738 | /** encrypt data "d" and write to "filename" */ |
739 | PwMerror encrypt(string *d, const QString *pw, QFile *f, char algo); | 739 | PwMerror encrypt(string *d, const QString *pw, QFile *f, char algo, |
740 | char _hashalgo //US BUG: pass _hashalgo because we need it in hashPassphrase | ||
741 | ); | ||
740 | /** read data from file beginning at "pos", decrypt and return it */ | 742 | /** read data from file beginning at "pos", decrypt and return it */ |
741 | PwMerror decrypt(string *d, unsigned int pos, const QString *pw, char algo, QFile *f); | 743 | PwMerror decrypt(string *d, unsigned int pos, const QString *pw, char algo, |
744 | char _hashalgo, //US BUG: pass _hashalgo because we need it in hashPassphrase | ||
745 | QFile *f); | ||
742 | /** compress the data */ | 746 | /** compress the data */ |