Changeset: 3a473a6e2111 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3a473a6e2111
Modified Files:
        common/utils/mcrypt.c
        common/utils/mcrypt.h
        configure.ag
Branch: Jun2020
Log Message:

Cleanup some crypt stuff.


diffs (200 lines):

diff --git a/common/utils/mcrypt.c b/common/utils/mcrypt.c
--- a/common/utils/mcrypt.c
+++ b/common/utils/mcrypt.c
@@ -84,7 +84,7 @@ mcrypt_getHashAlgorithms(void)
 char *
 mcrypt_MD5Sum(const char *string, size_t len)
 {
-#if !defined(HAVE_EMBEDDED)
+#ifndef HAVE_EMBEDDED
        MD5_CTX c;
        unsigned char md[MD5_DIGEST_LENGTH];
        char *ret;
@@ -114,6 +114,7 @@ mcrypt_MD5Sum(const char *string, size_t
 }
 #endif
 
+#ifdef HAVE_SHA1_UPDATE
 /**
  * Returns a malloced string representing the hex representation of
  * the SHA-1 hash of the given string.
@@ -121,7 +122,7 @@ mcrypt_MD5Sum(const char *string, size_t
 char *
 mcrypt_SHA1Sum(const char *string, size_t len)
 {
-#if !defined(HAVE_EMBEDDED) && defined(HAVE_SHA1_UPDATE)
+#ifndef HAVE_EMBEDDED
        SHA_CTX c;
        unsigned char md[SHA_DIGEST_LENGTH];
        char *ret;
@@ -149,7 +150,9 @@ mcrypt_SHA1Sum(const char *string, size_
        return NULL;
 #endif
 }
+#endif
 
+#ifdef HAVE_SHA224_UPDATE
 /**
  * Returns a malloced string representing the hex representation of
  * the SHA-224 hash of the given string.
@@ -157,7 +160,7 @@ mcrypt_SHA1Sum(const char *string, size_
 char *
 mcrypt_SHA224Sum(const char *string, size_t len)
 {
-#if !defined(HAVE_EMBEDDED) && defined(HAVE_SHA224_UPDATE)
+#ifndef HAVE_EMBEDDED
        SHA256_CTX c;
        unsigned char md[SHA224_DIGEST_LENGTH];
        char *ret;
@@ -188,7 +191,9 @@ mcrypt_SHA224Sum(const char *string, siz
        return NULL;
 #endif
 }
+#endif
 
+#ifdef HAVE_SHA256_UPDATE
 /**
  * Returns a malloced string representing the hex representation of
  * the SHA-256 hash of the given string.
@@ -196,7 +201,7 @@ mcrypt_SHA224Sum(const char *string, siz
 char *
 mcrypt_SHA256Sum(const char *string, size_t len)
 {
-#if !defined(HAVE_EMBEDDED) && defined(HAVE_SHA256_UPDATE)
+#ifndef HAVE_EMBEDDED
        SHA256_CTX c;
        unsigned char md[SHA256_DIGEST_LENGTH];
        char *ret;
@@ -229,7 +234,9 @@ mcrypt_SHA256Sum(const char *string, siz
        return NULL;
 #endif
 }
+#endif
 
+#ifdef HAVE_SHA384_UPDATE
 /**
  * Returns a malloced string representing the hex representation of
  * the SHA-384 hash of the given string.
@@ -237,7 +244,7 @@ mcrypt_SHA256Sum(const char *string, siz
 char *
 mcrypt_SHA384Sum(const char *string, size_t len)
 {
-#if !defined(HAVE_EMBEDDED) && defined(HAVE_SHA384_UPDATE)
+#ifndef HAVE_EMBEDDED
        SHA512_CTX c;
        unsigned char md[SHA384_DIGEST_LENGTH];
        char *ret;
@@ -274,7 +281,9 @@ mcrypt_SHA384Sum(const char *string, siz
        return NULL;
 #endif
 }
+#endif
 
+#ifdef HAVE_SHA512_UPDATE
 /**
  * Returns a malloced string representing the hex representation of
  * the SHA-512 hash of the given string.
@@ -282,7 +291,7 @@ mcrypt_SHA384Sum(const char *string, siz
 char *
 mcrypt_SHA512Sum(const char *string, size_t len)
 {
-#if !defined(HAVE_EMBEDDED) && defined(HAVE_SHA512_UPDATE)
+#ifndef HAVE_EMBEDDED
        SHA512_CTX c;
        unsigned char md[SHA512_DIGEST_LENGTH];
        char *ret;
@@ -321,11 +330,12 @@ mcrypt_SHA512Sum(const char *string, siz
 #else
        (void) string;
        (void) len;
-       fprintf(stderr, "No SHA512 digest function available.\n");
        return NULL;
 #endif
 }
+#endif
 
+#ifdef HAVE_RIPEMD160_UPDATE
 /**
  * Returns a malloced string representing the hex representation of
  * the RIPEMD-160 hash of the given string.
@@ -333,7 +343,7 @@ mcrypt_SHA512Sum(const char *string, siz
 char *
 mcrypt_RIPEMD160Sum(const char *string, size_t len)
 {
-#if !defined(HAVE_EMBEDDED) && defined(HAVE_RIPEMD160_UPDATE)
+#ifndef HAVE_EMBEDDED
        RIPEMD160_CTX c;
        unsigned char md[RIPEMD160_DIGEST_LENGTH];
        char *ret;
@@ -358,10 +368,10 @@ mcrypt_RIPEMD160Sum(const char *string, 
 #else
        (void) string;
        (void) len;
-       fprintf(stderr, "No RIPEMD160 digest function available.\n");
        return NULL;
 #endif
 }
+#endif
 
 /**
  * Returns a malloced string representing the hex representation of
@@ -377,7 +387,6 @@ mcrypt_BackendSum(const char *string, si
 #else
        (void) string;
        (void) len;
-       fprintf(stderr, "No digest function available.\n");
        return NULL;
 #endif
 }
diff --git a/common/utils/mcrypt.h b/common/utils/mcrypt.h
--- a/common/utils/mcrypt.h
+++ b/common/utils/mcrypt.h
@@ -21,13 +21,27 @@
 
 mcrypt_export const char *mcrypt_getHashAlgorithms(void)
        __attribute__((__const__));
+#ifdef HAVE_MD5_UPDATE
 mcrypt_export char *mcrypt_MD5Sum(const char *string, size_t len);
+#endif
+#ifdef HAVE_SHA1_UPDATE
 mcrypt_export char *mcrypt_SHA1Sum(const char *string, size_t len);
+#endif
+#ifdef HAVE_SHA224_UPDATE
 mcrypt_export char *mcrypt_SHA224Sum(const char *string, size_t len);
+#endif
+#ifdef HAVE_SHA256_UPDATE
 mcrypt_export char *mcrypt_SHA256Sum(const char *string, size_t len);
+#endif
+#ifdef HAVE_SHA384_UPDATE
 mcrypt_export char *mcrypt_SHA384Sum(const char *string, size_t len);
+#endif
+#ifdef HAVE_SHA512_UPDATE
 mcrypt_export char *mcrypt_SHA512Sum(const char *string, size_t len);
+#endif
+#ifdef HAVE_RIPEMD160_UPDATE
 mcrypt_export char *mcrypt_RIPEMD160Sum(const char *string, size_t len);
+#endif
 mcrypt_export char *mcrypt_BackendSum(const char *string, size_t len);
 mcrypt_export char *mcrypt_hashPassword(const char *algo, const char 
*password, const char *challenge);
 #endif
diff --git a/configure.ag b/configure.ag
--- a/configure.ag
+++ b/configure.ag
@@ -314,14 +314,14 @@ AC_ARG_ENABLE([static-analysis],
 MONETDB5_PASSWDHASH="SHA512"
 AC_ARG_WITH([password-backend],
        [AS_HELP_STRING([--with-password-backend=HASHALG],
-               [password hash algorithm, one of MD5, SHA1, RIPEMD160, SHA224, 
SHA256, SHA384, SHA512, defaults to SHA512])],
+               [password hash algorithm, one of SHA1, RIPEMD160, SHA224, 
SHA256, SHA384, SHA512, defaults to SHA512])],
        [password_backend="$withval"])
 AS_CASE([$password_backend],
        [yes|no|auto|""],
                [],
-       [MD5|SHA1|RIPEMD160|SHA224|SHA256|SHA384|SHA512],
+       [SHA1|RIPEMD160|SHA224|SHA256|SHA384|SHA512],
                [MONETDB5_PASSWDHASH="$password_backend"],
-       [AC_MSG_ERROR(['$password_backend' invalid, choose one of MD5, SHA1, 
RIPEMD160, SHA224, SHA256, SHA384, SHA512])])
+       [AC_MSG_ERROR(['$password_backend' invalid, choose one of SHA1, 
RIPEMD160, SHA224, SHA256, SHA384, SHA512])])
 AC_DEFINE_UNQUOTED([MONETDB5_PASSWDHASH], ["$MONETDB5_PASSWDHASH"],
        [The used password hash algorithm])
 AC_DEFINE_UNQUOTED([MONETDB5_PASSWDHASH_TOKEN], [$MONETDB5_PASSWDHASH],
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to