/*
* Exim - an Internet mail transport agent
*
- * Copyright (C) 2010 - 2018 Exim maintainers
+ * Copyright (c) The Exim Maintainers 2010 - 2023
* Copyright (c) University of Cambridge 1995 - 2009
+ * SPDX-License-Identifier: GPL-2.0-or-later
*
* Hash interface functions
*/
/******************************************************************************/
#ifdef SHA_OPENSSL
+# define HAVE_PARTIAL_SHA
BOOL
exim_sha_init(hctx * h, hashmethod m)
#elif defined(SHA_GNUTLS)
+# define HAVE_PARTIAL_SHA
/******************************************************************************/
BOOL
#elif defined(SHA_GCRYPT)
+# define HAVE_PARTIAL_SHA
/******************************************************************************/
BOOL
#elif defined(SHA_POLARSSL)
+# define HAVE_PARTIAL_SHA
/******************************************************************************/
BOOL
*/
static void
-native_sha1_end(sha1 *base, const uschar *text, int length, uschar *digest)
+native_sha1_end(sha1 * base, const uschar * text, int length, uschar * digest)
{
uschar work[64];
padding. If it has less than 56 bytes, we pad it out to 56 bytes as the
final chunk. */
-memcpy(work, text, length);
+if (length) memcpy(work, text, length);
work[length] = 0x80;
if (length > 55)
memset(work, 0, 56);
}
else
- {
memset(work+length+1, 0, 55-length);
- }
/* The final 8 bytes of the final chunk are a 64-bit representation of the
length of the input string *bits*, before padding, high order word first, and
+#ifdef HAVE_PARTIAL_SHA
+# undef HAVE_PARTIAL_SHA
+void
+exim_sha_update_string(hctx * h, const uschar * s)
+{
+if (s) exim_sha_update(h, s, Ustrlen(s));
+}
+#endif
**************************************************
*************************************************/
-# ifdef STAND_ALONE
+#ifdef STAND_ALONE
/* Test values. The first 128 may contain binary zeros and have increasing
length. */
if (strcmp(s, atest) != 0) printf("*** No match ***\n");
}
-# endif /*STAND_ALONE*/
+#endif /*STAND_ALONE*/
/* End of File */