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
+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