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