Changeset: 570a2bbcecc8 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=570a2bbcecc8 Modified Files: NT/monetdb_config.h.in buildtools/ChangeLog.Jun2016 clients/mapilib/mapi.c common/utils/mcrypt.c common/utils/muuid.c configure.ag monetdb5/mal/mal_authorize.c monetdb5/modules/atoms/uuid.c monetdb5/modules/mal/mal_mapi.c tools/merovingian/utils/control.c tools/merovingian/utils/utils.c tools/mserver/monet_version.c.in Branch: default Log Message:
Merge with Jun2016 branch. diffs (truncated from 1061 to 300 lines): diff --git a/NT/monetdb_config.h.in b/NT/monetdb_config.h.in --- a/NT/monetdb_config.h.in +++ b/NT/monetdb_config.h.in @@ -345,8 +345,8 @@ /* Define to 1 if you have the `mallopt' function. */ /* #undef HAVE_MALLOPT */ -/* Define to 1 if you have the `MD5' function. */ -#define HAVE_MD5 1 +/* Define to 1 if you have the `MD5_Update' function. */ +#define HAVE_MD5_UPDATE 1 /* Define to 1 if you have the <memory.h> header file. */ #define HAVE_MEMORY_H 1 @@ -430,8 +430,8 @@ /* Define if the compiler supports the restrict keyword */ /* #undef HAVE_RESTRICT */ -/* Define to 1 if you have the `RIPEMD160' function. */ -#define HAVE_RIPEMD160 1 +/* Define to 1 if you have the `RIPEMD160_Update' function. */ +#define HAVE_RIPEMD160_UPDATE 1 /* Define to 1 if you have the `round' function. */ #if !defined(_MSC_VER) || _MSC_VER > 1600 @@ -459,20 +459,20 @@ /* Define to 1 if you have the `setsid' function. */ /* #undef HAVE_SETSID */ -/* Define to 1 if you have the `SHA1' function. */ -#define HAVE_SHA1 1 +/* Define to 1 if you have the `SHA1_Update' function. */ +#define HAVE_SHA1_UPDATE 1 -/* Define to 1 if you have the `SHA224' function. */ -#define HAVE_SHA224 1 +/* Define to 1 if you have the `SHA224_Update' function. */ +#define HAVE_SHA224_UPDATE 1 -/* Define to 1 if you have the `SHA256' function. */ -#define HAVE_SHA256 1 +/* Define to 1 if you have the `SHA256_Update' function. */ +#define HAVE_SHA256_UPDATE 1 -/* Define to 1 if you have the `SHA384' function. */ -#define HAVE_SHA384 1 +/* Define to 1 if you have the `SHA384_Update' function. */ +#define HAVE_SHA384_UPDATE 1 -/* Define to 1 if you have the `SHA512' function. */ -#define HAVE_SHA512 1 +/* Define to 1 if you have the `SHA512_Update' function. */ +#define HAVE_SHA512_UPDATE 1 /* Define to 1 if you have the `shutdown' function. */ #define HAVE_SHUTDOWN 1 diff --git a/buildtools/ChangeLog.Jun2016 b/buildtools/ChangeLog.Jun2016 --- a/buildtools/ChangeLog.Jun2016 +++ b/buildtools/ChangeLog.Jun2016 @@ -1,3 +1,7 @@ # ChangeLog file for buildtools # This file is updated with Maddlog +* Mon Sep 26 2016 Sjoerd Mullender <sjo...@acm.org> +- We now use the CommonCrypto library instead of the OpenSSL library + on Darwin. + diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c --- a/clients/mapilib/mapi.c +++ b/clients/mapilib/mapi.c @@ -2587,9 +2587,15 @@ mapi_reconnect(Mapi mid) char *byteo = NULL; char *serverhash = NULL; char *algsv[] = { +#ifdef HAVE_RIPEMD160_UPDATE "RIPEMD160", +#endif +#ifdef HAVE_SHA1_UPDATE "SHA1", +#endif +#ifdef HAVE_MD5_UPDATE "MD5", +#endif NULL }; char **algs = algsv; @@ -2643,28 +2649,49 @@ mapi_reconnect(Mapi mid) /* hash password, if not already */ if (mid->password[0] != '\1') { char *pwdhash = NULL; +#ifdef HAVE_RIPEMD160_UPDATE if (strcmp(serverhash, "RIPEMD160") == 0) { pwdhash = mcrypt_RIPEMD160Sum(mid->password, strlen(mid->password)); - } else if (strcmp(serverhash, "SHA512") == 0) { + } else +#endif +#ifdef HAVE_SHA512_UPDATE + if (strcmp(serverhash, "SHA512") == 0) { pwdhash = mcrypt_SHA512Sum(mid->password, strlen(mid->password)); - } else if (strcmp(serverhash, "SHA384") == 0) { + } else +#endif +#ifdef HAVE_SHA384_UPDATE + if (strcmp(serverhash, "SHA384") == 0) { pwdhash = mcrypt_SHA384Sum(mid->password, strlen(mid->password)); - } else if (strcmp(serverhash, "SHA256") == 0) { + } else +#endif +#ifdef HAVE_SHA256_UPDATE + if (strcmp(serverhash, "SHA256") == 0) { pwdhash = mcrypt_SHA256Sum(mid->password, strlen(mid->password)); - } else if (strcmp(serverhash, "SHA224") == 0) { + } else +#endif +#ifdef HAVE_SHA224_UPDATE + if (strcmp(serverhash, "SHA224") == 0) { pwdhash = mcrypt_SHA224Sum(mid->password, strlen(mid->password)); - } else if (strcmp(serverhash, "SHA1") == 0) { + } else +#endif +#ifdef HAVE_SHA1_UPDATE + if (strcmp(serverhash, "SHA1") == 0) { pwdhash = mcrypt_SHA1Sum(mid->password, strlen(mid->password)); - } else if (strcmp(serverhash, "MD5") == 0) { + } else +#endif +#ifdef HAVE_MD5_UPDATE + if (strcmp(serverhash, "MD5") == 0) { pwdhash = mcrypt_MD5Sum(mid->password, strlen(mid->password)); - } else { + } else +#endif + { snprintf(buf, BLOCK, "server requires unknown hash '%.100s'", serverhash); close_connection(mid); diff --git a/common/utils/mcrypt.c b/common/utils/mcrypt.c --- a/common/utils/mcrypt.c +++ b/common/utils/mcrypt.c @@ -13,10 +13,16 @@ #include "mcrypt.h" #include <string.h> +#if defined(HAVE_OPENSSL) || defined(HAVE_COMMONCRYPTO) + #ifdef HAVE_OPENSSL #include <openssl/md5.h> #include <openssl/sha.h> #include <openssl/ripemd.h> +#else +#define COMMON_DIGEST_FOR_OPENSSL +#include <CommonCrypto/CommonDigest.h> +#endif /** * Returns a comma separated list of supported hash algorithms suitable @@ -34,7 +40,35 @@ mcrypt_getHashAlgorithms(void) * Better/stronger/faster algorithms can be added in the future upon * desire. */ - return strdup("RIPEMD160,SHA256,SHA1,MD5"); +#if defined(HAVE_RIPEMD160_UPDATE) || defined(HAVE_SHA256_UPDATE) || defined(HAVE_SHA1_UPDATE) || defined(HAVE_MD5_UPDATE) + return strdup( +#ifdef HAVE_RIPEMD160_UPDATE + "RIPEMD160" +#endif +#ifdef HAVE_SHA256_UPDATE +#if defined(HAVE_RIPEMD160_UPDATE) + "," +#endif + "SHA256" +#endif +#ifdef HAVE_SHA1_UPDATE +#if defined(HAVE_RIPEMD160_UPDATE) || defined(HAVE_SHA256_UPDATE) + "," +#endif + "SHA1" +#endif +#ifdef HAVE_MD5_UPDATE +#if defined(HAVE_RIPEMD160_UPDATE) || defined(HAVE_SHA256_UPDATE) || defined(HAVE_SHA1_UPDATE) + "," +#endif + "MD5" +#endif + ); +#else + fprintf(stderr, "There are no digest functions available.\n"); + exit(1); + return NULL; +#endif } /** @@ -44,11 +78,17 @@ mcrypt_getHashAlgorithms(void) char * mcrypt_MD5Sum(const char *string, size_t len) { - unsigned char md[16]; /* should be MD5_DIGEST_LENGTH */ +#ifdef HAVE_MD5_UPDATE + MD5_CTX c; + unsigned char md[MD5_DIGEST_LENGTH]; char *ret; - MD5((unsigned const char*)string, len, md); - ret = malloc(sizeof(char) * (16 * 2 + 1)); + assert(MD5_DIGEST_LENGTH == 16); + MD5_Init(&c); + MD5_Update(&c, string, len); + MD5_Final(md, &c); + + ret = malloc(sizeof(char) * (MD5_DIGEST_LENGTH * 2 + 1)); sprintf(ret, "%02x%02x%02x%02x%02x%02x%02x%02x" "%02x%02x%02x%02x%02x%02x%02x%02x", md[0], md[1], md[2], md[3], @@ -58,6 +98,13 @@ mcrypt_MD5Sum(const char *string, size_t ); return ret; +#else + (void) string; + (void) len; + fprintf(stderr, "No MD5 digest function available.\n"); + exit(1); + return NULL; +#endif } /** @@ -67,11 +114,17 @@ mcrypt_MD5Sum(const char *string, size_t char * mcrypt_SHA1Sum(const char *string, size_t len) { - unsigned char md[20]; /* should be SHA_DIGEST_LENGTH */ +#ifdef HAVE_SHA1_UPDATE + SHA_CTX c; + unsigned char md[SHA_DIGEST_LENGTH]; char *ret; - SHA1((unsigned const char*)string, len, md); - ret = malloc(sizeof(char) * (20 * 2 + 1)); + assert(SHA_DIGEST_LENGTH == 20); + SHA1_Init(&c); + SHA1_Update(&c, string, len); + SHA1_Final(md, &c); + + ret = malloc(sizeof(char) * (SHA_DIGEST_LENGTH * 2 + 1)); sprintf(ret, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x" "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", md[0], md[1], md[2], md[3], md[4], @@ -81,6 +134,13 @@ mcrypt_SHA1Sum(const char *string, size_ ); return ret; +#else + (void) string; + (void) len; + fprintf(stderr, "No SHA1 digest function available.\n"); + exit(1); + return NULL; +#endif } /** @@ -90,11 +150,17 @@ mcrypt_SHA1Sum(const char *string, size_ char * mcrypt_SHA224Sum(const char *string, size_t len) { - unsigned char md[28]; +#ifdef HAVE_SHA224_UPDATE + SHA256_CTX c; + unsigned char md[SHA224_DIGEST_LENGTH]; char *ret; - SHA224((unsigned const char*)string, len, md); - ret = malloc(sizeof(char) * (sizeof(md) * 2 + 1)); + assert(SHA224_DIGEST_LENGTH == 28); + SHA224_Init(&c); + SHA224_Update(&c, string, len); + SHA224_Final(md, &c); + + ret = malloc(sizeof(char) * (SHA224_DIGEST_LENGTH * 2 + 1)); sprintf(ret, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x" "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x" @@ -108,6 +174,13 @@ mcrypt_SHA224Sum(const char *string, siz ); return ret; +#else + (void) string; + (void) len; + fprintf(stderr, "No SHA224 digest function available.\n"); + exit(1); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list