Unbreak non-DKIM build
[exim.git] / src / src / hash.h
... / ...
CommitLineData
1/*
2 * Exim - an Internet mail transport agent
3 *
4 * Copyright (C) 2016 Exim maintainers
5 *
6 * Hash interface functions
7 */
8
9#include "exim.h"
10
11#if !defined(HASH_H) /* entire file */
12#define HASH_H
13
14#include "sha_ver.h"
15
16#ifdef SHA_OPENSSL
17# include <openssl/sha.h>
18#elif defined SHA_GNUTLS
19# include <gnutls/crypto.h>
20#elif defined(SHA_GCRYPT)
21# include <gcrypt.h>
22#elif defined(SHA_POLARSSL)
23# include "pdkim/pdkim.h" /*XXX ugly */
24# include "pdkim/polarssl/sha1.h"
25# include "pdkim/polarssl/sha2.h"
26#endif
27
28
29/* Hash context for the exim_sha_* routines */
30
31typedef enum hashmethod {
32 HASH_BADTYPE,
33 HASH_SHA1,
34
35 HASH_SHA2_256,
36 HASH_SHA2_384,
37 HASH_SHA2_512,
38
39 HASH_SHA3_224,
40 HASH_SHA3_256,
41 HASH_SHA3_384,
42 HASH_SHA3_512,
43} hashmethod;
44
45typedef struct {
46 hashmethod method;
47 int hashlen;
48
49#ifdef SHA_OPENSSL
50 union {
51 SHA_CTX sha1; /* SHA1 block */
52 SHA256_CTX sha2_256; /* SHA256 or 224 block */
53 SHA512_CTX sha2_512; /* SHA512 or 384 block */
54 } u;
55
56#elif defined(SHA_GNUTLS)
57 gnutls_hash_hd_t sha; /* Either SHA1 or SHA256 block */
58
59#elif defined(SHA_GCRYPT)
60 gcry_md_hd_t sha; /* Either SHA1 or SHA256 block */
61
62#elif defined(SHA_POLARSSL)
63 union {
64 sha1_context sha1; /* SHA1 block */
65 sha2_context sha2; /* SHA256 block */
66 } u;
67
68#elif defined(SHA_NATIVE)
69 sha1 sha1;
70#endif
71
72} hctx;
73
74extern BOOL exim_sha_init(hctx *, hashmethod);
75extern void exim_sha_update(hctx *, const uschar *a, int);
76extern void exim_sha_finish(hctx *, blob *);
77
78#endif
79/* End of File */