2 * Exim - an Internet mail transport agent
3 * Copyright (c) The Exim Maintainers 1995 - 2022
4 * SPDX-License-Identifier: GPL-2.0-or-later
6 * Hash interface functions
11 #if !defined(HASH_H) /* entire file */
17 # include <openssl/sha.h>
18 #elif defined SHA_GNUTLS
19 # include <gnutls/crypto.h>
20 #elif defined(SHA_GCRYPT)
22 #elif defined(SHA_POLARSSL)
23 # include "pdkim/pdkim.h" /*XXX ugly */
24 # include "pdkim/polarssl/sha1.h"
25 # include "pdkim/polarssl/sha2.h"
29 /* Hash context for the exim_sha_* routines */
31 typedef enum hashmethod {
52 SHA_CTX sha1; /* SHA1 block */
53 SHA256_CTX sha2_256; /* SHA256 or 224 block */
54 SHA512_CTX sha2_512; /* SHA512 or 384 block */
56 EVP_MD_CTX * mctx; /* SHA3 block */
60 #elif defined(SHA_GNUTLS)
61 gnutls_hash_hd_t sha; /* Either SHA1 or SHA256 block */
63 #elif defined(SHA_GCRYPT)
64 gcry_md_hd_t sha; /* Either SHA1 or SHA256 block */
66 #elif defined(SHA_POLARSSL)
68 sha1_context sha1; /* SHA1 block */
69 sha2_context sha2; /* SHA256 block */
72 #elif defined(SHA_NATIVE)
78 extern BOOL exim_sha_init(hctx *, hashmethod);
79 extern void exim_sha_update(hctx *, const uschar *a, int);
80 extern void exim_sha_update_string(hctx *, const uschar *a);
81 extern void exim_sha_finish(hctx *, blob *);