Changeset: 327250b4d795 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/327250b4d795
Modified Files:
gdk/gdk_batop.c
gdk/gdk_join.c
monetdb5/modules/mal/clients.c
sql/server/rel_schema.c
Branch: default
Log Message:
Merge with Jul2021 branch.
diffs (truncated from 1971 to 300 lines):
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -2648,9 +2648,7 @@ mapi_reconnect(Mapi mid)
#ifdef HAVE_RIPEMD160_UPDATE
"RIPEMD160",
#endif
-#ifdef HAVE_SHA512_UPDATE
"SHA512",
-#endif
#ifdef HAVE_SHA384_UPDATE
"SHA384",
#endif
@@ -2709,12 +2707,10 @@ mapi_reconnect(Mapi mid)
strlen(mid->password));
} else
#endif
-#ifdef HAVE_SHA512_UPDATE
if (strcmp(serverhash, "SHA512") == 0) {
pwdhash = mcrypt_SHA512Sum(mid->password,
strlen(mid->password));
} else
-#endif
#ifdef HAVE_SHA384_UPDATE
if (strcmp(serverhash, "SHA384") == 0) {
pwdhash = mcrypt_SHA384Sum(mid->password,
@@ -2747,7 +2743,6 @@ mapi_reconnect(Mapi mid)
return mapi_setError(mid, buf, __func__, MERROR);
}
-#if defined(HAVE_RIPEMD160_UPDATE) || defined(HAVE_SHA512_UPDATE) ||
defined(HAVE_SHA384_UPDATE) || defined(HAVE_SHA256_UPDATE) ||
defined(HAVE_SHA224_UPDATE) || defined(HAVE_SHA1_UPDATE)
if (pwdhash == NULL) {
snprintf(buf, sizeof(buf), "allocation failure or
unknown hash '%.100s'",
serverhash);
@@ -2759,7 +2754,6 @@ mapi_reconnect(Mapi mid)
mid->password = malloc(1 + strlen(pwdhash) + 1);
sprintf(mid->password, "\1%s", pwdhash);
free(pwdhash);
-#endif
}
diff --git a/common/utils/mcrypt.c b/common/utils/mcrypt.c
--- a/common/utils/mcrypt.c
+++ b/common/utils/mcrypt.c
@@ -60,9 +60,7 @@ mcrypt_getHashAlgorithms(void)
#ifdef HAVE_RIPEMD160_UPDATE
",RIPEMD160"
#endif
-#ifdef HAVE_SHA512_UPDATE
",SHA512"
-#endif
#ifdef HAVE_SHA384_UPDATE
",SHA384"
#endif
@@ -306,6 +304,44 @@ mcrypt_SHA512Sum(const char *string, siz
return ret;
}
+#else
+/* return private copy of SHA512 hash functions */
+#include "sha.h"
+char *
+mcrypt_SHA512Sum(const char *string, size_t len)
+{
+ static_assert(SHA512HashSize == 64, "SHA512HashSize should be 64");
+ char *ret = malloc(SHA512HashSize * 2 + 1);
+ if (ret) {
+ SHA512Context sc;
+ uint8_t md[SHA512HashSize];
+ SHA512Reset(&sc);
+ SHA512Input(&sc, (const uint8_t *) string, (unsigned int) len);
+ SHA512Result(&sc, md);
+ snprintf(ret, SHA512HashSize * 2 + 1,
+ "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
+ "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
+ "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
+ "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
+ "%02x%02x%02x%02x%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],
+ md[5], md[6], md[7], md[8], md[9],
+ md[10], md[11], md[12], md[13], md[14],
+ md[15], md[16], md[17], md[18], md[19],
+ md[20], md[21], md[22], md[23], md[24],
+ md[25], md[26], md[27], md[28], md[29],
+ md[30], md[31], md[32], md[33], md[34],
+ md[35], md[36], md[37], md[38], md[39],
+ md[40], md[41], md[42], md[43], md[44],
+ md[45], md[46], md[47], md[48], md[49],
+ md[50], md[51], md[52], md[53], md[54],
+ md[55], md[56], md[57], md[58], md[59],
+ md[60], md[61], md[62], md[63]);
+ }
+ return ret;
+}
#endif
#ifdef HAVE_RIPEMD160_UPDATE
@@ -371,7 +407,6 @@ mcrypt_hashPassword(
const char *password,
const char *challenge)
{
-#if (defined(HAVE_OPENSSL) || defined(HAVE_COMMONCRYPTO))
unsigned char md[64]; /* should be SHA512_DIGEST_LENGTH */
char ret[sizeof(md) * 2 + 1];
int len;
@@ -391,18 +426,24 @@ mcrypt_hashPassword(
len = 40;
} else
#endif
+ if (strcmp(algo, "SHA512") == 0) {
#ifdef HAVE_SHA512_UPDATE
- if (strcmp(algo, "SHA512") == 0) {
SHA512_CTX c;
SHA512_Init(&c);
SHA512_Update(&c, password, strlen(password));
SHA512_Update(&c, challenge, strlen(challenge));
SHA512_Final(md, &c);
+#else
+ SHA512Context sc;
+ SHA512Reset(&sc);
+ SHA512Input(&sc, (const uint8_t *) password, (unsigned int)
strlen(password));
+ SHA512Input(&sc, (const uint8_t *) challenge,
strlen(challenge));
+ SHA512Result(&sc, md);
+#endif
len = 128;
} else
-#endif
#ifdef HAVE_SHA384_UPDATE
if (strcmp(algo, "SHA384") == 0) {
SHA512_CTX c;
@@ -463,7 +504,6 @@ mcrypt_hashPassword(
len = 32;
} else
#endif
-#endif
{
(void) algo;
(void) password;
@@ -502,3 +542,7 @@ mcrypt_hashPassword(
return strdup(ret);
#endif
}
+
+#ifndef HAVE_SHA512_UPDATE
+#include "sha384-512.c"
+#endif
diff --git a/common/utils/mcrypt.h b/common/utils/mcrypt.h
--- a/common/utils/mcrypt.h
+++ b/common/utils/mcrypt.h
@@ -36,12 +36,15 @@ mcrypt_export char *mcrypt_SHA256Sum(con
#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);
+
+#ifndef SHA512_DIGEST_LENGTH
+#define SHA512_DIGEST_LENGTH 64
#endif
+
+#endif
diff --git a/common/utils/sha-private.h b/common/utils/sha-private.h
new file mode 100644
--- /dev/null
+++ b/common/utils/sha-private.h
@@ -0,0 +1,28 @@
+/************************ sha-private.h ************************/
+/***************** See RFC 6234 for details. *******************/
+#ifndef _SHA_PRIVATE__H
+#define _SHA_PRIVATE__H
+/*
+ * These definitions are defined in FIPS 180-3, section 4.1.
+ * Ch() and Maj() are defined identically in sections 4.1.1,
+ * 4.1.2, and 4.1.3.
+ *
+ * The definitions used in FIPS 180-3 are as follows:
+ */
+
+#ifndef USE_MODIFIED_MACROS
+#define SHA_Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z)))
+#define SHA_Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
+#else /* USE_MODIFIED_MACROS */
+/*
+ * The following definitions are equivalent and potentially faster.
+ */
+
+#define SHA_Ch(x, y, z) (((x) & ((y) ^ (z))) ^ (z))
+#define SHA_Maj(x, y, z) (((x) & ((y) | (z))) | ((y) & (z)))
+
+#endif /* USE_MODIFIED_MACROS */
+
+#define SHA_Parity(x, y, z) ((x) ^ (y) ^ (z))
+
+#endif /* _SHA_PRIVATE__H */
diff --git a/common/utils/sha.h b/common/utils/sha.h
new file mode 100644
--- /dev/null
+++ b/common/utils/sha.h
@@ -0,0 +1,357 @@
+/**************************** sha.h ****************************/
+/***************** See RFC 6234 for details. *******************/
+/*
+ Copyright (c) 2011 IETF Trust and the persons identified as
+ authors of the code. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or
+ without modification, are permitted provided that the following
+ conditions are met:
+
+ - Redistributions of source code must retain the above
+ copyright notice, this list of conditions and
+ the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ - Neither the name of Internet Society, IETF or IETF Trust, nor
+ the names of specific contributors, may be used to endorse or
+ promote products derived from this software without specific
+ prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+#ifndef _SHA_H_
+#define _SHA_H_
+
+/*
+ * Description:
+ * This file implements the Secure Hash Algorithms
+ * as defined in the U.S. National Institute of Standards
+ * and Technology Federal Information Processing Standards
+ * Publication (FIPS PUB) 180-3 published in October 2008
+ * and formerly defined in its predecessors, FIPS PUB 180-1
+ * and FIP PUB 180-2.
+ *
+ * A combined document showing all algorithms is available at
+ * http://csrc.nist.gov/publications/fips/
+ * fips180-3/fips180-3_final.pdf
+ *
+ * The five hashes are defined in these sizes:
+ * SHA-1 20 byte / 160 bit
+ * SHA-224 28 byte / 224 bit
+ * SHA-256 32 byte / 256 bit
+ * SHA-384 48 byte / 384 bit
+ * SHA-512 64 byte / 512 bit
+ *
+ * Compilation Note:
+ * These files may be compiled with two options:
+ * USE_32BIT_ONLY - use 32-bit arithmetic only, for systems
+ * without 64-bit integers
+ *
+ * USE_MODIFIED_MACROS - use alternate form of the SHA_Ch()
+ * and SHA_Maj() macros that are equivalent
+ * and potentially faster on many systems
+ *
+ */
+
+#include <stdint.h>
+/*
+ * If you do not have the ISO standard stdint.h header file, then you
+ * must typedef the following:
+ * name meaning
+ * uint64_t unsigned 64-bit integer
+ * uint32_t unsigned 32-bit integer
+ * uint8_t unsigned 8-bit integer (i.e., unsigned char)
+ * int_least16_t integer of >= 16 bits
+ *
+ * See stdint-example.h
+ */
+
+#ifndef _SHA_enum_
+#define _SHA_enum_
+/*
+ * All SHA functions return one of these values.
+ */
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list