summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-10-19 18:20:21 (UTC)
committer ulf69 <ulf69>2004-10-19 18:20:21 (UTC)
commit53cc32b6e7b1f672bf91b2baf2df6c1e8baf3e0a (patch) (unidiff)
tree9f34ae85da2727e3b6c4c886a6bdb0025398d7bd
parent3b4dc5931f729bd1385ec83f8c9b82a1eb42ef36 (diff)
downloadkdepimpi-53cc32b6e7b1f672bf91b2baf2df6c1e8baf3e0a.zip
kdepimpi-53cc32b6e7b1f672bf91b2baf2df6c1e8baf3e0a.tar.gz
kdepimpi-53cc32b6e7b1f672bf91b2baf2df6c1e8baf3e0a.tar.bz2
comment change
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/libgcryptif.cpp2
-rw-r--r--pwmanager/pwmanager/libgcryptif.h2
2 files changed, 2 insertions, 2 deletions
diff --git a/pwmanager/pwmanager/libgcryptif.cpp b/pwmanager/pwmanager/libgcryptif.cpp
index 8175510..eafd318 100644
--- a/pwmanager/pwmanager/libgcryptif.cpp
+++ b/pwmanager/pwmanager/libgcryptif.cpp
@@ -1,66 +1,66 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 2004 by Michael Buesch *
4 * email: mbuesch@freenet.de * 4 * email: mbuesch@freenet.de *
5 * * 5 * *
6 * hashPassphrase() is derived from GnuPG and is * 6 * hashPassphrase() is derived from GnuPG and is *
7 * Copyright (C) 1998, 1999, 2000, 2001, 2003 * 7 * Copyright (C) 1998, 1999, 2000, 2001, 2003 *
8 * Free Software Foundation, Inc. * 8 * Free Software Foundation, Inc. *
9 * * 9 * *
10 * This program is free software; you can redistribute it and/or modify * 10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License version 2 * 11 * it under the terms of the GNU General Public License version 2 *
12 * as published by the Free Software Foundation. * 12 * as published by the Free Software Foundation. *
13 * * 13 * *
14 ***************************************************************************/ 14 ***************************************************************************/
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 2.0 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#include "libgcryptif.h" 24#include "libgcryptif.h"
25 25
26#ifdef CONFIG_PWMANAGER_GCRY 26#ifdef CONFIG_PWMANAGER_GCRY
27 27
28#include "pwmdoc.h" 28#include "pwmdoc.h"
29#include "randomizer.h" 29#include "randomizer.h"
30 30
31#include <gcrypt.h> 31#include <gcrypt.h>
32 32
33#ifdef PWM_EMBEDDED 33#ifdef PWM_EMBEDDED
34#include <pwmprefs.h> 34#include <pwmprefs.h>
35#endif 35#endif
36 36
37 37
38PwMerror LibGCryptIf::encrypt(unsigned char **outBuf, 38PwMerror LibGCryptIf::encrypt(unsigned char **outBuf,
39 size_t *outBufLen, 39 size_t *outBufLen,
40 unsigned char *inBuf, 40 unsigned char *inBuf,
41 size_t inBufLen, 41 size_t inBufLen,
42 const unsigned char *key, 42 const unsigned char *key,
43 size_t keylen, 43 size_t keylen,
44 char _algo) 44 char _algo)
45{ 45{
46 PwMerror ret = e_success; 46 PwMerror ret = e_success;
47 gcry_error_t err; 47 gcry_error_t err;
48 gcry_cipher_hd_t handle; 48 gcry_cipher_hd_t handle;
49 size_t blklen; 49 size_t blklen;
50 size_t unpaddedLen = inBufLen; 50 size_t unpaddedLen = inBufLen;
51 size_t cipherKeylen; 51 size_t cipherKeylen;
52 unsigned char *hashedKey; 52 unsigned char *hashedKey;
53 unsigned char salt[STRING2KEY_SALTLEN]; 53 unsigned char salt[STRING2KEY_SALTLEN];
54 int algo = mapCipherId(_algo); 54 int algo = mapCipherId(_algo);
55 55
56 if (!inBufLen || !keylen) 56 if (!inBufLen || !keylen)
57 return e_invalidArg; 57 return e_invalidArg;
58 58
59 // test if algo is ready for encryption 59 // test if algo is ready for encryption
60 err = gcry_cipher_algo_info(algo, 60 err = gcry_cipher_algo_info(algo,
61 GCRYCTL_TEST_ALGO, 61 GCRYCTL_TEST_ALGO,
62 0, 0); 62 0, 0);
63 if (err != GPG_ERR_NO_ERROR) { 63 if (err != GPG_ERR_NO_ERROR) {
64 printDebug(string("LibGCryptIf::doEncrypt(): GCRYCTL_TEST_ALGO failed: ") 64 printDebug(string("LibGCryptIf::doEncrypt(): GCRYCTL_TEST_ALGO failed: ")
65 + gcry_strerror(err)); 65 + gcry_strerror(err));
66 ret = e_cryptNotImpl; 66 ret = e_cryptNotImpl;
diff --git a/pwmanager/pwmanager/libgcryptif.h b/pwmanager/pwmanager/libgcryptif.h
index ce76675..dffd55b 100644
--- a/pwmanager/pwmanager/libgcryptif.h
+++ b/pwmanager/pwmanager/libgcryptif.h
@@ -1,66 +1,66 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 2004 by Michael Buesch *
4 * email: mbuesch@freenet.de * 4 * email: mbuesch@freenet.de *
5 * * 5 * *
6 * hashPassphrase() is derived from GnuPG and is * 6 * hashPassphrase() is derived from GnuPG and is *
7 * Copyright (C) 1998, 1999, 2000, 2001, 2003 * 7 * Copyright (C) 1998, 1999, 2000, 2001, 2003 *
8 * Free Software Foundation, Inc. * 8 * Free Software Foundation, Inc. *
9 * * 9 * *
10 * This program is free software; you can redistribute it and/or modify * 10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License version 2 * 11 * it under the terms of the GNU General Public License version 2 *
12 * as published by the Free Software Foundation. * 12 * as published by the Free Software Foundation. *
13 * * 13 * *
14 ***************************************************************************/ 14 ***************************************************************************/
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 2.0 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" 27#include "pwmexception.h"
28 28
29//#undef CONFIG_PWMANAGER_GCRY // for debugging only. 29//#undef CONFIG_PWMANAGER_GCRY // for debugging only.
30#ifdef CONFIG_PWMANAGER_GCRY 30#ifdef CONFIG_PWMANAGER_GCRY
31 31
32#include <stddef.h> 32#include <stddef.h>
33#include <sys/types.h> 33#include <sys/types.h>
34#include <stdint.h> 34#include <stdint.h>
35 35
36 #define STRING2KEY_SALTLEN8 36 #define STRING2KEY_SALTLEN8
37 37
38/** interface class for the libgcrypt cipher and hash algorithms 38/** interface class for the libgcrypt cipher and hash algorithms
39 * NOTE: Always allocate 1024 extra bytes for the inBuf (for padding) 39 * NOTE: Always allocate 1024 extra bytes for the inBuf (for padding)
40 */ 40 */
41class LibGCryptIf 41class LibGCryptIf
42{ 42{
43protected: 43protected:
44 struct STRING2KEY 44 struct STRING2KEY
45 { 45 {
46 int mode; 46 int mode;
47 int hash_algo; 47 int hash_algo;
48 uint8_t salt[STRING2KEY_SALTLEN]; 48 uint8_t salt[STRING2KEY_SALTLEN];
49 uint32_t count; 49 uint32_t count;
50 }; 50 };
51 struct DEK 51 struct DEK
52 { 52 {
53 size_t keylen; 53 size_t keylen;
54 uint8_t key[32]; // this is the largest used keylen (256 bit) 54 uint8_t key[32]; // this is the largest used keylen (256 bit)
55 }; 55 };
56 56
57public: 57public:
58 LibGCryptIf() { } 58 LibGCryptIf() { }
59 /** is libgcrypt available? */ 59 /** is libgcrypt available? */
60 static bool available() 60 static bool available()
61 { return true; } 61 { return true; }
62 /** encrypt data. _algo is the PWM_CRYPT_* ID 62 /** encrypt data. _algo is the PWM_CRYPT_* ID
63 * of the algorithm. 63 * of the algorithm.
64 */ 64 */
65 PwMerror encrypt(unsigned char **outBuf, 65 PwMerror encrypt(unsigned char **outBuf,
66 size_t *outBufLen, 66 size_t *outBufLen,