git://git.exim.org
/
exim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
tidying
[exim.git]
/
src
/
src
/
hash.c
diff --git
a/src/src/hash.c
b/src/src/hash.c
index c50c49aadb50c0f651a4c4cd79bb609a15f32c68..10af1b43d5bcc828cd9c5331bce1f1269996299b 100644
(file)
--- a/
src/src/hash.c
+++ b/
src/src/hash.c
@@
-1,8
+1,9
@@
/*
* Exim - an Internet mail transport agent
*
/*
* Exim - an Internet mail transport agent
*
- * Copyright (
C) 2010 - 2018 Exim maintainers
+ * Copyright (
c) The Exim Maintainers 2010 - 2022
* Copyright (c) University of Cambridge 1995 - 2009
* Copyright (c) University of Cambridge 1995 - 2009
+ * SPDX-License-Identifier: GPL-2.0-or-later
*
* Hash interface functions
*/
*
* Hash interface functions
*/
@@
-29,6
+30,7
@@
sha1;
/******************************************************************************/
#ifdef SHA_OPENSSL
/******************************************************************************/
#ifdef SHA_OPENSSL
+# define HAVE_PARTIAL_SHA
BOOL
exim_sha_init(hctx * h, hashmethod m)
BOOL
exim_sha_init(hctx * h, hashmethod m)
@@
-116,7
+118,7
@@
void
exim_sha_finish(hctx * h, blob * b)
{
/* Hashing is sufficient to purify any tainted input */
exim_sha_finish(hctx * h, blob * b)
{
/* Hashing is sufficient to purify any tainted input */
-b->data = store_get(b->len = h->hashlen,
FALSE
);
+b->data = store_get(b->len = h->hashlen,
GET_UNTAINTED
);
# if OPENSSL_VERSION_NUMBER < 0x30000000L
switch (h->method)
# if OPENSSL_VERSION_NUMBER < 0x30000000L
switch (h->method)
@@
-146,6
+148,7
@@
EVP_MD_CTX_free(h->u.mctx);
#elif defined(SHA_GNUTLS)
#elif defined(SHA_GNUTLS)
+# define HAVE_PARTIAL_SHA
/******************************************************************************/
BOOL
/******************************************************************************/
BOOL
@@
-179,13
+182,14
@@
gnutls_hash(h->sha, data, len);
void
exim_sha_finish(hctx * h, blob * b)
{
void
exim_sha_finish(hctx * h, blob * b)
{
-b->data = store_get(b->len = h->hashlen,
FALSE
);
+b->data = store_get(b->len = h->hashlen,
GET_UNTAINTED
);
gnutls_hash_output(h->sha, b->data);
}
#elif defined(SHA_GCRYPT)
gnutls_hash_output(h->sha, b->data);
}
#elif defined(SHA_GCRYPT)
+# define HAVE_PARTIAL_SHA
/******************************************************************************/
BOOL
/******************************************************************************/
BOOL
@@
-216,7
+220,7
@@
gcry_md_write(h->sha, data, len);
void
exim_sha_finish(hctx * h, blob * b)
{
void
exim_sha_finish(hctx * h, blob * b)
{
-b->data = store_get(b->len = h->hashlen,
FALSE
);
+b->data = store_get(b->len = h->hashlen,
GET_UNTAINTED
);
memcpy(b->data, gcry_md_read(h->sha, 0), h->hashlen);
}
memcpy(b->data, gcry_md_read(h->sha, 0), h->hashlen);
}
@@
-224,6
+228,7
@@
memcpy(b->data, gcry_md_read(h->sha, 0), h->hashlen);
#elif defined(SHA_POLARSSL)
#elif defined(SHA_POLARSSL)
+# define HAVE_PARTIAL_SHA
/******************************************************************************/
BOOL
/******************************************************************************/
BOOL
@@
-254,7
+259,7
@@
switch (h->method)
void
exim_sha_finish(hctx * h, blob * b)
{
void
exim_sha_finish(hctx * h, blob * b)
{
-b->data = store_get(b->len = h->hashlen,
FALSE
);
+b->data = store_get(b->len = h->hashlen,
GET_INTAINTED
);
switch (h->method)
{
case HASH_SHA1: sha1_finish(h->u.sha1, b->data); break;
switch (h->method)
{
case HASH_SHA1: sha1_finish(h->u.sha1, b->data); break;
@@
-432,9
+437,7
@@
if (length > 55)
memset(work, 0, 56);
}
else
memset(work, 0, 56);
}
else
- {
memset(work+length+1, 0, 55-length);
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
/* 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
@@
-492,7
+495,7
@@
native_sha1_mid(&h->sha1, US data); /* implicit size always 64 */
void
exim_sha_finish(hctx * h, blob * b)
{
void
exim_sha_finish(hctx * h, blob * b)
{
-b->data = store_get(b->len = h->hashlen,
FALSE
);
+b->data = store_get(b->len = h->hashlen,
GET_UNTAINTED
);
native_sha1_end(&h->sha1, NULL, 0, b->data);
}
native_sha1_end(&h->sha1, NULL, 0, b->data);
}
@@
-556,6
+559,14
@@
memcpy(digest, b.data, 20);
+#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
@@
-565,7
+576,7
@@
memcpy(digest, b.data, 20);
**************************************************
*************************************************/
**************************************************
*************************************************/
-#
ifdef STAND_ALONE
+#ifdef STAND_ALONE
/* Test values. The first 128 may contain binary zeros and have increasing
length. */
/* Test values. The first 128 may contain binary zeros and have increasing
length. */
@@
-880,6
+891,6
@@
printf("Computed: %s\n", s);
if (strcmp(s, atest) != 0) printf("*** No match ***\n");
}
if (strcmp(s, atest) != 0) printf("*** No match ***\n");
}
-#
endif
/*STAND_ALONE*/
+#
endif
/*STAND_ALONE*/
/* End of File */
/* End of File */