Removing dependency to gnutls, only gcrypt is required now.

This commit is contained in:
lotodore
2011-03-08 18:42:57 +00:00
parent 629ec5929d
commit 4ec5f4eae9
6 changed files with 40 additions and 18 deletions
+5 -4
View File
@@ -323,7 +323,9 @@ win32 {
-lSDLmain \
-ltinyxml \
-lz \
-lgnutls-openssl -lgnutls -lgcrypt -lgpg-error -lgsasl -lidn
-lgcrypt \
-lgsasl \
-lidn
debug:LIBPATH += debug/lib
release:LIBPATH += release/lib
win32-g++-cross {
@@ -446,14 +448,13 @@ unix:!mac {
-lSDL_mixer \
-lgsasl
!isEmpty( BSD ):isEmpty( kFreeBSD ):LIBS += -lcrypto
else:LIBS += -lgnutls-openssl \
-lgcrypt
else:LIBS += -lgcrypt
TARGETDEPS += ./lib/libpokerth_lib.a \
./lib/libpokerth_db.a \
./lib/libpokerth_protocol.a
# #### My release static libs
# LIBS += -lgcrypt_static -lgpg-error_static -lgnutls-openssl_static -lgnutls_static -lSDL_mixer_static -lSDL -lmikmod -lcurl
# LIBS += -lgcrypt_static -lSDL_mixer_static -lSDL -lmikmod -lcurl
# ### INSTALL ####
binary.path += $${PREFIX}/bin/
binary.files += pokerth
+2 -2
View File
@@ -126,7 +126,7 @@ win32 {
debug:LIBPATH += debug/lib
release:LIBPATH += release/lib
LIBS += -lgnutls-openssl -lgnutls -lgcrypt -lgpg-error -lgsasl -lidn -ltinyxml
LIBS += -lgcrypt -lgsasl -lidn -ltinyxml
win32-g++-cross {
LIBS += -lsqlite3
LIBS += -lntlm
@@ -269,7 +269,7 @@ unix : !mac {
!isEmpty( BSD ): isEmpty( kFreeBSD ){
LIBS += -lcrypto -liconv
} else {
LIBS += -lgnutls-openssl -lgcrypt
LIBS += -lgcrypt
}
TARGETDEPS += ./lib/libpokerth_lib.a \
+16 -3
View File
@@ -165,16 +165,29 @@ CryptHelper::MD5Sum(const std::string &fileName, MD5Buf &buf)
if (file) {
// Calculate MD5 sum of file.
unsigned char readBuf[8192];
MD5_CTX context;
unsigned char *readBuf = new unsigned char[8192];
int numBytes;
#ifdef HAVE_OPENSSL
MD5_CTX context;
MD5_Init(&context);
while ((numBytes = fread(readBuf, 1, sizeof(readBuf), file)) > 0)
while ((numBytes = fread(readBuf, 1, sizeof(readBuf), file)) > 0) {
MD5_Update(&context, readBuf, numBytes);
}
MD5_Final(buf.GetData(), &context);
#else
gcry_md_hd_t hash;
gcry_md_open(&hash, GCRY_MD_MD5, 0);
while ((numBytes = fread(readBuf, 1, sizeof(readBuf), file)) > 0) {
gcry_md_write(hash, readBuf, numBytes);
}
memcpy(buf.GetData(), gcry_md_read(hash, GCRY_MD_MD5), MD5_DATA_SIZE);
gcry_md_close(hash);
#endif
retVal = ferror(file) == 0;
delete[] readBuf;
fclose(file);
}
return retVal;
+1 -3
View File
@@ -67,10 +67,8 @@ typedef int pid_t;
#include <openssl/rand.h>
#include <openssl/evp.h>
#else
// For all other systems, we use GnuTLS.
#include <gnutls/openssl.h>
// For all other systems, we use gcrypt.
#include <gcrypt.h>
#define PKTH_USE_GNUTLS
#endif
#endif
+8
View File
@@ -109,9 +109,13 @@ void Tools::getRandNumber(int start, int end, int howMany, int* randArray, bool
int counter(0);
while(counter < howMany) {
#ifdef HAVE_OPENSSL
if(!RAND_bytes(rand_buf, 4)) {
LOG_MSG("RAND_bytes failed!");
}
#else
gcry_randomize(rand_buf, 4, GCRY_VERY_STRONG_RANDOM);
#endif
randNumber = 0;
for(i=0; i<4; i++) {
@@ -138,9 +142,13 @@ void Tools::getRandNumber(int start, int end, int howMany, int* randArray, bool
int counter(0);
while (counter < howMany) {
#ifdef HAVE_OPENSSL
if(!RAND_bytes(rand_buf, 4)) {
LOG_MSG("RAND_bytes failed!");
}
#else
gcry_randomize(rand_buf, 4, GCRY_VERY_STRONG_RANDOM);
#endif
randNumber = 0;
for(i=0; i<4; i++) {
+8 -6
View File
@@ -23,9 +23,7 @@
#include <net/socket_startup.h>
#include <core/openssl_wrapper.h>
#ifdef PKTH_USE_GNUTLS
#include <gcrypt.h>
#ifndef HAVE_OPENSSL
extern "C" {
@@ -60,16 +58,20 @@ extern "C" {
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
};
}
#endif // PKTH_USE_GNUTLS
#endif // not HAVE_OPENSSL
bool
socket_startup()
{
#ifdef PKTH_USE_GNUTLS
#ifdef HAVE_OPENSSL
return SSL_library_init() == 1;
#else
gcry_check_version(NULL);
gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_boost);
gcry_control(GCRYCTL_ENABLE_QUICK_RANDOM, 0);
gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
return true;
#endif
return SSL_library_init() == 1;
}
void