summaryrefslogtreecommitdiffabout
path: root/pwmanager
Unidiff
Diffstat (limited to 'pwmanager') (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/libcrypt/cipher/serpent.c4
-rw-r--r--pwmanager/pwmanager/binentrygen.cpp5
-rw-r--r--pwmanager/pwmanager/binentrygen.h2
-rw-r--r--pwmanager/pwmanager/blowfish.cpp2
-rw-r--r--pwmanager/pwmanager/blowfish.h4
-rw-r--r--pwmanager/pwmanager/genpasswd.cpp1
-rw-r--r--pwmanager/pwmanager/libgcryptif.h4
-rw-r--r--pwmanager/pwmanager/pwmexception.h3
-rw-r--r--pwmanager/pwmanager/randomizer.h1
9 files changed, 17 insertions, 9 deletions
diff --git a/pwmanager/libcrypt/cipher/serpent.c b/pwmanager/libcrypt/cipher/serpent.c
index d606d9f..fb5df20 100644
--- a/pwmanager/libcrypt/cipher/serpent.c
+++ b/pwmanager/libcrypt/cipher/serpent.c
@@ -664,39 +664,39 @@ serpent_subkeys_generate (serpent_key_t key, serpent_subkeys_t subkeys)
664 664
665/* Initialize CONTEXT with the key KEY of KEY_LENGTH bits. */ 665/* Initialize CONTEXT with the key KEY of KEY_LENGTH bits. */
666static void 666static void
667serpent_setkey_internal (serpent_context_t *context, 667serpent_setkey_internal (serpent_context_t *context,
668 const byte_t *key, unsigned int key_length) 668 const byte_t *key, unsigned int key_length)
669{ 669{
670 serpent_key_t key_prepared; 670 serpent_key_t key_prepared;
671 671
672 serpent_key_prepare (key, key_length, key_prepared); 672 serpent_key_prepare (key, key_length, key_prepared);
673 serpent_subkeys_generate (key_prepared, context->keys); 673 serpent_subkeys_generate (key_prepared, context->keys);
674 _gcry_burn_stack (272 * sizeof (u32_t)); 674 _gcry_burn_stack (272 * sizeof (u32_t));
675} 675}
676 676 static const char *serpent_test (void);
677/* Initialize CTX with the key KEY of KEY_LENGTH bytes. */ 677/* Initialize CTX with the key KEY of KEY_LENGTH bytes. */
678static gcry_err_code_t 678static gcry_err_code_t
679serpent_setkey (void *ctx, 679serpent_setkey (void *ctx,
680 const byte_t *key, unsigned int key_length) 680 const byte_t *key, unsigned int key_length)
681{ 681{
682 serpent_context_t *context = ctx; 682 serpent_context_t *context = ctx;
683 static const char *serpent_test_ret; 683 static const char *serpent_test_ret;
684 static int serpent_init_done; 684 static int serpent_init_done;
685 gcry_err_code_t ret = GPG_ERR_NO_ERROR; 685 gcry_err_code_t ret = GPG_ERR_NO_ERROR;
686 686
687 if (! serpent_init_done) 687 if (! serpent_init_done)
688 { 688 {
689 /* Execute a self-test the first time, Serpent is used. */ 689 /* Execute a self-test the first time, Serpent is used. */
690 static const char *serpent_test (void); 690
691 691
692 serpent_test_ret = serpent_test (); 692 serpent_test_ret = serpent_test ();
693 if (serpent_test_ret) 693 if (serpent_test_ret)
694 log_error ("Serpent test failure: %s\n", serpent_test_ret); 694 log_error ("Serpent test failure: %s\n", serpent_test_ret);
695 serpent_init_done = 1; 695 serpent_init_done = 1;
696 } 696 }
697 697
698 if (serpent_test_ret) 698 if (serpent_test_ret)
699 ret = GPG_ERR_SELFTEST_FAILED; 699 ret = GPG_ERR_SELFTEST_FAILED;
700 else 700 else
701 { 701 {
702 serpent_setkey_internal (context, key, key_length); 702 serpent_setkey_internal (context, key, key_length);
diff --git a/pwmanager/pwmanager/binentrygen.cpp b/pwmanager/pwmanager/binentrygen.cpp
index 7d5ae45..f156a5e 100644
--- a/pwmanager/pwmanager/binentrygen.cpp
+++ b/pwmanager/pwmanager/binentrygen.cpp
@@ -8,29 +8,29 @@
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
21#include "binentrygen.h" 20#include "binentrygen.h"
22#include "base64.h" 21#include "base64.h"
23#include "pwmexception.h"
24 22
23#include "pwmexception.h"
24#include "globalstuff.h"
25 25
26void BinEntryGen::encode(const QByteArray &data, 26void BinEntryGen::encode(const QByteArray &data,
27 PwMDataItem *ret, 27 PwMDataItem *ret,
28 DataType type) 28 DataType type)
29{ 29{
30 ret->clear(); 30 ret->clear();
31 ret->name = tostr(static_cast<int>(type)); 31 ret->name = tostr(static_cast<int>(type));
32 ret->binary = true; 32 ret->binary = true;
33 if (data.size() == 0) 33 if (data.size() == 0)
34 return; 34 return;
35 Base64 b64; 35 Base64 b64;
36 string d(data.data(), data.size()); 36 string d(data.data(), data.size());
@@ -60,12 +60,13 @@ void BinEntryGen::decode(const PwMDataItem &data,
60 Base64 b64; 60 Base64 b64;
61 string d(b64.decode(data.pw)); 61 string d(b64.decode(data.pw));
62 ret->duplicate(d.c_str(), d.length()); 62 ret->duplicate(d.c_str(), d.length());
63} 63}
64 64
65BinEntryGen::DataType BinEntryGen::binType(const PwMDataItem &data) 65BinEntryGen::DataType BinEntryGen::binType(const PwMDataItem &data)
66{ 66{
67 if (!data.binary) 67 if (!data.binary)
68 return None; 68 return None;
69 int type = strtol(data.name.c_str(), 0, 10); 69 int type = strtol(data.name.c_str(), 0, 10);
70 return (static_cast<DataType>(type)); 70 return (static_cast<DataType>(type));
71} 71}
72
diff --git a/pwmanager/pwmanager/binentrygen.h b/pwmanager/pwmanager/binentrygen.h
index a58cd42..49288aa 100644
--- a/pwmanager/pwmanager/binentrygen.h
+++ b/pwmanager/pwmanager/binentrygen.h
@@ -11,28 +11,28 @@
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 __BINENTRYGEN_H 20#ifndef __BINENTRYGEN_H
21#define __BINENTRYGEN_H 21#define __BINENTRYGEN_H
22 22
23#include "pwmdoc.h"
24 23
25#include <qcstring.h> 24#include <qcstring.h>
26 25
26#include "pwmdoc.h"
27 27
28/** Binary entry generator. 28/** Binary entry generator.
29 * This generator generates a normal struct PwMDataItem 29 * This generator generates a normal struct PwMDataItem
30 * from binary data (using base64 encoding). 30 * from binary data (using base64 encoding).
31 * This mechanism is used to support the binary interface functions 31 * This mechanism is used to support the binary interface functions
32 * of the KWallet emulation, for example. 32 * of the KWallet emulation, for example.
33 * 33 *
34 * The format of the encoded binary data as a PwMDataItem is as follows: 34 * The format of the encoded binary data as a PwMDataItem is as follows:
35 * 35 *
36 * PwMDataItem::desc contains the normal description string for 36 * PwMDataItem::desc contains the normal description string for
37 * this entry. Nothing surprising. 37 * this entry. Nothing surprising.
38 * PwMDataItem::name contains the "DataType" number in ascii format. 38 * PwMDataItem::name contains the "DataType" number in ascii format.
diff --git a/pwmanager/pwmanager/blowfish.cpp b/pwmanager/pwmanager/blowfish.cpp
index 2ca58ce..ee29756 100644
--- a/pwmanager/pwmanager/blowfish.cpp
+++ b/pwmanager/pwmanager/blowfish.cpp
@@ -34,27 +34,27 @@
34/*************************************************************************** 34/***************************************************************************
35 * copyright (C) 2004 by Ulf Schenk 35 * copyright (C) 2004 by Ulf Schenk
36 * This file is originaly based on version 1.0.1 of pwmanager 36 * This file is originaly based on version 1.0.1 of pwmanager
37 * and was modified to run on embedded devices that run microkde 37 * and was modified to run on embedded devices that run microkde
38 * 38 *
39 * $Id$ 39 * $Id$
40 **************************************************************************/ 40 **************************************************************************/
41 41
42 42
43#include <string.h> 43#include <string.h>
44#include <stdlib.h> 44#include <stdlib.h>
45 45
46#include "blowfish.h"
47#include "globalstuff.h" 46#include "globalstuff.h"
48 47
48#include "blowfish.h"
49 49
50/* precomputed S boxes */ 50/* precomputed S boxes */
51static const uint32_t ks0[256] = { 51static const uint32_t ks0[256] = {
52 0xD1310BA6, 0x98DFB5AC, 0x2FFD72DB, 0xD01ADFB7, 0xB8E1AFED, 0x6A267E96, 52 0xD1310BA6, 0x98DFB5AC, 0x2FFD72DB, 0xD01ADFB7, 0xB8E1AFED, 0x6A267E96,
53 0xBA7C9045, 0xF12C7F99, 0x24A19947, 0xB3916CF7, 0x0801F2E2, 0x858EFC16, 53 0xBA7C9045, 0xF12C7F99, 0x24A19947, 0xB3916CF7, 0x0801F2E2, 0x858EFC16,
54 0x636920D8, 0x71574E69, 0xA458FEA3, 0xF4933D7E, 0x0D95748F, 0x728EB658, 54 0x636920D8, 0x71574E69, 0xA458FEA3, 0xF4933D7E, 0x0D95748F, 0x728EB658,
55 0x718BCD58, 0x82154AEE, 0x7B54A41D, 0xC25A59B5, 0x9C30D539, 0x2AF26013, 55 0x718BCD58, 0x82154AEE, 0x7B54A41D, 0xC25A59B5, 0x9C30D539, 0x2AF26013,
56 0xC5D1B023, 0x286085F0, 0xCA417918, 0xB8DB38EF, 0x8E79DCB0, 0x603A180E, 56 0xC5D1B023, 0x286085F0, 0xCA417918, 0xB8DB38EF, 0x8E79DCB0, 0x603A180E,
57 0x6C9E0E8B, 0xB01E8A3E, 0xD71577C1, 0xBD314B27, 0x78AF2FDA, 0x55605C60, 57 0x6C9E0E8B, 0xB01E8A3E, 0xD71577C1, 0xBD314B27, 0x78AF2FDA, 0x55605C60,
58 0xE65525F3, 0xAA55AB94, 0x57489862, 0x63E81440, 0x55CA396A, 0x2AAB10B6, 58 0xE65525F3, 0xAA55AB94, 0x57489862, 0x63E81440, 0x55CA396A, 0x2AAB10B6,
59 0xB4CC5C34, 0x1141E8CE, 0xA15486AF, 0x7C72E993, 0xB3EE1411, 0x636FBC2A, 59 0xB4CC5C34, 0x1141E8CE, 0xA15486AF, 0x7C72E993, 0xB3EE1411, 0x636FBC2A,
60 0x2BA9C55D, 0x741831F6, 0xCE5C3E16, 0x9B87931E, 0xAFD6BA33, 0x6C24CF5C, 60 0x2BA9C55D, 0x741831F6, 0xCE5C3E16, 0x9B87931E, 0xAFD6BA33, 0x6C24CF5C,
diff --git a/pwmanager/pwmanager/blowfish.h b/pwmanager/pwmanager/blowfish.h
index 5129eab..862cccb 100644
--- a/pwmanager/pwmanager/blowfish.h
+++ b/pwmanager/pwmanager/blowfish.h
@@ -14,45 +14,47 @@
14 14
15/*************************************************************************** 15/***************************************************************************
16 * copyright (C) 2004 by Ulf Schenk 16 * copyright (C) 2004 by Ulf Schenk
17 * This file is originaly based on version 1.0.1 of pwmanager 17 * This file is originaly based on version 1.0.1 of pwmanager
18 * and was modified to run on embedded devices that run microkde 18 * and was modified to run on embedded devices that run microkde
19 * 19 *
20 * $Id$ 20 * $Id$
21 **************************************************************************/ 21 **************************************************************************/
22 22
23#ifndef BLOWFISH_H 23#ifndef BLOWFISH_H
24#define BLOWFISH_H 24#define BLOWFISH_H
25 25
26#include "pwmexception.h" 26//#include "pwmexception.h"
27#ifndef _WIN32_ 27#ifndef _WIN32_
28#include <stdint.h> 28#include <stdint.h>
29#else 29#else
30 30
31#endif 31#endif
32#include <string> 32#include <string>
33using std::string; 33using std::string;
34 34
35 #define BLOWFISH_BLOCKSIZE8 35 #define BLOWFISH_BLOCKSIZE8
36 #define BLOWFISH_ROUNDS 16 36 #define BLOWFISH_ROUNDS 16
37 #define CIPHER_ALGO_BLOWFISH 4/* blowfish 128 bit key */ 37 #define CIPHER_ALGO_BLOWFISH 4/* blowfish 128 bit key */
38 38
39#ifndef _WIN32_ 39#ifndef _WIN32_
40 typedef uint8_t byte; 40 typedef uint8_t byte;
41#else 41#else
42#define uint8_t Q_UINT8 42#define uint8_t Q_UINT8
43#define byte Q_UINT8 43#define byte Q_UINT8
44#define uint32_t Q_UINT32 44#define uint32_t Q_UINT32
45#endif 45#endif
46 46
47//#include "pwmexception.h"
48
47/** blowfish encryption algorithm. 49/** blowfish encryption algorithm.
48 * Derived from libgcrypt-1.1.12 50 * Derived from libgcrypt-1.1.12
49 */ 51 */
50class Blowfish 52class Blowfish
51{ 53{
52 struct BLOWFISH_context 54 struct BLOWFISH_context
53 { 55 {
54 uint32_t s0[256]; 56 uint32_t s0[256];
55 uint32_t s1[256]; 57 uint32_t s1[256];
56 uint32_t s2[256]; 58 uint32_t s2[256];
57 uint32_t s3[256]; 59 uint32_t s3[256];
58 uint32_t p[BLOWFISH_ROUNDS+2]; 60 uint32_t p[BLOWFISH_ROUNDS+2];
diff --git a/pwmanager/pwmanager/genpasswd.cpp b/pwmanager/pwmanager/genpasswd.cpp
index b0cceff..41078b3 100644
--- a/pwmanager/pwmanager/genpasswd.cpp
+++ b/pwmanager/pwmanager/genpasswd.cpp
@@ -11,24 +11,25 @@
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#include "genpasswd.h" 20#include "genpasswd.h"
21#include "pwmexception.h" 21#include "pwmexception.h"
22#include "randomizer.h" 22#include "randomizer.h"
23#include "globalstuff.h"
23 24
24 25
25/* how often can a char of the same charset be reused in order */ 26/* how often can a char of the same charset be reused in order */
26 #define FILTER_MAX_CHARSET_REUSE3 27 #define FILTER_MAX_CHARSET_REUSE3
27/* re-randomize all charsets on every iteration (0/1) */ 28/* re-randomize all charsets on every iteration (0/1) */
28 #define RERAND_CHARSET 0 29 #define RERAND_CHARSET 0
29 30
30 31
31struct staticCharsetStruct 32struct staticCharsetStruct
32{ 33{
33 const char *lower; 34 const char *lower;
34 const char *upper; 35 const char *upper;
diff --git a/pwmanager/pwmanager/libgcryptif.h b/pwmanager/pwmanager/libgcryptif.h
index 9a987a2..a08d678 100644
--- a/pwmanager/pwmanager/libgcryptif.h
+++ b/pwmanager/pwmanager/libgcryptif.h
@@ -15,40 +15,42 @@
15 15
16/*************************************************************************** 16/***************************************************************************
17 * copyright (C) 2004 by Ulf Schenk 17 * copyright (C) 2004 by Ulf Schenk
18 * This file is originaly based on version 1.1 of pwmanager 18 * This file is originaly based on version 1.1 of pwmanager
19 * and was modified to run on embedded devices that run microkde 19 * and was modified to run on embedded devices that run microkde
20 * 20 *
21 * $Id$ 21 * $Id$
22 **************************************************************************/ 22 **************************************************************************/
23 23
24#ifndef __LIBGCRYPTIF_H 24#ifndef __LIBGCRYPTIF_H
25#define __LIBGCRYPTIF_H 25#define __LIBGCRYPTIF_H
26 26
27#include "pwmexception.h"
28 27
29//#undef CONFIG_PWMANAGER_GCRY // for debugging only. 28//#undef CONFIG_PWMANAGER_GCRY // for debugging only.
30#ifdef CONFIG_PWMANAGER_GCRY 29#ifdef CONFIG_PWMANAGER_GCRY
31 30
32#include <stddef.h> 31#include <stddef.h>
33#include <sys/types.h> 32#include <sys/types.h>
34#ifndef _WIN32_ 33#ifndef _WIN32_
35#include <stdint.h> 34#include <stdint.h>
36#else 35#else
37#define uint8_t Q_UINT8 36#define uint8_t Q_UINT8
38#define byte Q_UINT8 37#define byte Q_UINT8
39#define uint32_t Q_UINT32 38#define uint32_t Q_UINT32
40#endif 39#endif
41 #define STRING2KEY_SALTLEN8 40 #define STRING2KEY_SALTLEN8
42 41
42#include "pwmexception.h"
43
44
43/** interface class for the libgcrypt cipher and hash algorithms 45/** interface class for the libgcrypt cipher and hash algorithms
44 * NOTE: Always allocate 1024 extra bytes for the inBuf (for padding) 46 * NOTE: Always allocate 1024 extra bytes for the inBuf (for padding)
45 */ 47 */
46class LibGCryptIf 48class LibGCryptIf
47{ 49{
48protected: 50protected:
49 struct STRING2KEY 51 struct STRING2KEY
50 { 52 {
51 int mode; 53 int mode;
52 int hash_algo; 54 int hash_algo;
53 uint8_t salt[STRING2KEY_SALTLEN]; 55 uint8_t salt[STRING2KEY_SALTLEN];
54 uint32_t count; 56 uint32_t count;
diff --git a/pwmanager/pwmanager/pwmexception.h b/pwmanager/pwmanager/pwmexception.h
index 301ebd7..7f5a3a6 100644
--- a/pwmanager/pwmanager/pwmexception.h
+++ b/pwmanager/pwmanager/pwmexception.h
@@ -11,25 +11,25 @@
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 __PWMEXCEPTION_H 20#ifndef __PWMEXCEPTION_H
21#define __PWMEXCEPTION_H 21#define __PWMEXCEPTION_H
22 22
23#include "globalstuff.h" 23//#include "globalstuff.h"
24 24
25#include <iostream> 25#include <iostream>
26#include <string> 26#include <string>
27using std::string; 27using std::string;
28using std::cerr; 28using std::cerr;
29using std::cout; 29using std::cout;
30using std::endl; 30using std::endl;
31 31
32/* This is an internal function to reduce code-overhead 32/* This is an internal function to reduce code-overhead
33 * of the BUG(), WARN(), TOD0() and FiXME() macros. Please use 33 * of the BUG(), WARN(), TOD0() and FiXME() macros. Please use
34 * these macros instead of calling this function directly. 34 * these macros instead of calling this function directly.
35 */ 35 */
@@ -205,13 +205,14 @@ void __printError(const string &msg);
205 205
206#ifdef PWM_DEBUG 206#ifdef PWM_DEBUG
207 void __printDebug(const string &msg); 207 void __printDebug(const string &msg);
208 # define printDebug(x)__printDebug(x) 208 # define printDebug(x)__printDebug(x)
209#else 209#else
210 # define printDebug(x)do { } while (0) 210 # define printDebug(x)do { } while (0)
211#endif 211#endif
212 212
213 #define printInfo(x)__printInfo(x) 213 #define printInfo(x)__printInfo(x)
214 #define printWarn(x)__printWarn(x) 214 #define printWarn(x)__printWarn(x)
215 #define printError(x)__printError(x) 215 #define printError(x)__printError(x)
216 216
217#include "globalstuff.h"
217#endif // __PWMEXCEPTION_H 218#endif // __PWMEXCEPTION_H
diff --git a/pwmanager/pwmanager/randomizer.h b/pwmanager/pwmanager/randomizer.h
index f2a6015..44cc28e 100644
--- a/pwmanager/pwmanager/randomizer.h
+++ b/pwmanager/pwmanager/randomizer.h
@@ -12,24 +12,25 @@
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 __RANDOMIZER_H 20#ifndef __RANDOMIZER_H
21#define __RANDOMIZER_H 21#define __RANDOMIZER_H
22 22
23#include "pwmexception.h" 23#include "pwmexception.h"
24#include "globalstuff.h"
24 25
25#ifndef PWM_EMBEDDED 26#ifndef PWM_EMBEDDED
26#include <qmutex.h> 27#include <qmutex.h>
27#endif 28#endif
28 29
29#include <string> 30#include <string>
30 31
31using std::string; 32using std::string;
32 33
33class QFile; 34class QFile;
34 35
35/** Randomizer to get random values. 36/** Randomizer to get random values.