X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/4191cb150300d310ab5fa22ce2cfb02b6f6051b0..f5730918ef684baafbd9e606a1d4eb06914563cc:/src/src/hash.c diff --git a/src/src/hash.c b/src/src/hash.c index b5323b69c..10af1b43d 100644 --- a/src/src/hash.c +++ b/src/src/hash.c @@ -1,8 +1,9 @@ /* * 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 + * SPDX-License-Identifier: GPL-2.0-or-later * * Hash interface functions */ @@ -29,6 +30,7 @@ sha1; /******************************************************************************/ #ifdef SHA_OPENSSL +# define HAVE_PARTIAL_SHA BOOL exim_sha_init(hctx * h, hashmethod m) @@ -146,6 +148,7 @@ EVP_MD_CTX_free(h->u.mctx); #elif defined(SHA_GNUTLS) +# define HAVE_PARTIAL_SHA /******************************************************************************/ BOOL @@ -186,6 +189,7 @@ gnutls_hash_output(h->sha, b->data); #elif defined(SHA_GCRYPT) +# define HAVE_PARTIAL_SHA /******************************************************************************/ BOOL @@ -224,6 +228,7 @@ memcpy(b->data, gcry_md_read(h->sha, 0), h->hashlen); #elif defined(SHA_POLARSSL) +# define HAVE_PARTIAL_SHA /******************************************************************************/ BOOL @@ -432,9 +437,7 @@ 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 @@ -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. */ @@ -880,6 +891,6 @@ printf("Computed: %s\n", s); if (strcmp(s, atest) != 0) printf("*** No match ***\n"); } -# endif /*STAND_ALONE*/ +#endif /*STAND_ALONE*/ /* End of File */