wip - see failed-summary.log.list_match_value. Pretty much ok.
[exim.git] / src / src / hash.h
1 /*
2 * Exim - an Internet mail transport agent
3 *
4 * Copyright (C) 1995 - 2018 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
31 typedef enum hashmethod {
32 HASH_BADTYPE,
33 HASH_NULL,
34 HASH_SHA1,
35
36 HASH_SHA2_256,
37 HASH_SHA2_384,
38 HASH_SHA2_512,
39
40 HASH_SHA3_224,
41 HASH_SHA3_256,
42 HASH_SHA3_384,
43 HASH_SHA3_512,
44 } hashmethod;
45
46 typedef struct {
47 hashmethod method;
48 int hashlen;
49
50 #ifdef SHA_OPENSSL
51 union {
52 SHA_CTX sha1; /* SHA1 block */
53 SHA256_CTX sha2_256; /* SHA256 or 224 block */
54 SHA512_CTX sha2_512; /* SHA512 or 384 block */
55 #ifdef EXIM_HAVE_SHA3
56 EVP_MD_CTX * mctx; /* SHA3 block */
57 #endif
58 } u;
59
60 #elif defined(SHA_GNUTLS)
61 gnutls_hash_hd_t sha; /* Either SHA1 or SHA256 block */
62
63 #elif defined(SHA_GCRYPT)
64 gcry_md_hd_t sha; /* Either SHA1 or SHA256 block */
65
66 #elif defined(SHA_POLARSSL)
67 union {
68 sha1_context sha1; /* SHA1 block */
69 sha2_context sha2; /* SHA256 block */
70 } u;
71
72 #elif defined(SHA_NATIVE)
73 sha1 sha1;
74 #endif
75
76 } hctx;
77
78 extern BOOL exim_sha_init(hctx *, hashmethod);
79 extern void exim_sha_update(hctx *, const uschar *a, int);
80 extern void exim_sha_finish(hctx *, blob *);
81
82 #endif
83 /* End of File */