1 /* 2 ** Copyright (c) 2009, 2012, 2014, The Trusted Domain Project. 3 ** All rights reserved. 4 */ 5 6 #ifndef _DKIM_INTERNAL_H_ 7 #define _DKIM_INTERNAL_H_ 8 9 /* libopendkim includes */ 10 #include "dkim.h" 11 12 /* the basics */ 13 #ifndef NULL 14 # define NULL 0 15 #endif /* ! NULL */ 16 #ifndef FALSE 17 # define FALSE 0 18 #endif /* ! FALSE */ 19 #ifndef TRUE 20 # define TRUE 1 21 #endif /* ! TRUE */ 22 #ifndef MAXPATHLEN 23 # define MAXPATHLEN 256 24 #endif /* ! MAXPATHLEN */ 25 26 #ifndef ULONG_MAX 27 # define ULONG_MAX 0xffffffffL 28 #endif /* ! ULONG_MAX */ 29 #ifndef ULLONG_MAX 30 # define ULLONG_MAX 0xffffffffffffffffLL 31 #endif /* ! ULLONG_MAX */ 32 33 #ifndef MIN 34 # define MIN(x,y) ((x) < (y) ? (x) : (y)) 35 #endif /* ! MIN */ 36 #ifndef MAX 37 # define MAX(x,y) ((x) > (y) ? (x) : (y)) 38 #endif /* ! MAX */ 39 40 #ifdef __STDC__ 41 # ifndef __P 42 # define __P(x) x 43 # endif /* ! __P */ 44 #else /* __STDC__ */ 45 # ifndef __P 46 # define __P(x) () 47 # endif /* ! __P */ 48 #endif /* __STDC__ */ 49 50 /* limits, macros, etc. */ 51 #define BUFRSZ 1024 /* base temp buffer size */ 52 #define BASE64SIZE(x) (((x + 2) / 3) * 4) 53 /* base64 encoding growth ratio */ 54 #define MAXADDRESS 256 /* biggest user@host we accept */ 55 #define MAXBUFRSZ 65536 /* max temp buffer size */ 56 #define MAXCNAMEDEPTH 3 /* max. CNAME recursion we allow */ 57 #define MAXHEADERS 32768 /* buffer for caching headers */ 58 #define MAXLABELS 16 /* max. labels we allow */ 59 #define MAXTAGNAME 8 /* biggest tag name */ 60 61 #define NPRINTABLE 95 /* number of printable characters */ 62 63 #define DKIM_MAXHEADER 4096 /* buffer for caching one header */ 64 #define DKIM_MAXHOSTNAMELEN 256 /* max. FQDN we support */ 65 66 /* defaults */ 67 #define DEFERRLEN 64 /* default error string length */ 68 #define DEFTMPDIR "/tmp" /* default temporary directory */ 69 70 /* version */ 71 #define DKIM_VERSION_KEY "DKIM1" /* current version token for keys */ 72 #define DKIM_VERSION_SIG "1" /* current version token for sigs */ 73 #define DKIM_VERSION_SIGOLD "0.5" /* old version token for sigs */ 74 75 /* headers */ 76 #define DKIM_DATEHEADER "Date" /* Date: header */ 77 #define DKIM_FROMHEADER "From" /* From: header */ 78 79 #define DKIM_DATEHEADER_LEN (sizeof(DKIM_DATEHEADER) - 1) 80 #define DKIM_FROMHEADER_LEN (sizeof(DKIM_FROMHEADER) - 1) 81 #define DKIM_SIGNHEADER_LEN (sizeof(DKIM_SIGNHEADER) - 1) 82 /* 83 ** DKIM_KEY -- known key parameters 84 */ 85 86 typedef int dkim_key_t; 87 88 #define DKIM_KEY_VERSION 0 /* v */ 89 #define DKIM_KEY_GRANULARITY 1 /* g */ 90 #define DKIM_KEY_ALGORITHM 2 /* a */ 91 #define DKIM_KEY_NOTES 3 /* n */ 92 #define DKIM_KEY_DATA 4 /* p */ 93 #define DKIM_KEY_SERVICE 5 /* s */ 94 #define DKIM_KEY_FLAGS 6 /* t */ 95 96 /* 97 ** DKIM_SETTYPE -- types of sets 98 */ 99 100 typedef int dkim_set_t; 101 102 #define DKIM_SETTYPE_ANY (-1) 103 #define DKIM_SETTYPE_SIGNATURE 0 104 #define DKIM_SETTYPE_KEY 1 105 #define DKIM_SETTYPE_SIGREPORT 2 106 107 /* 108 ** DKIM_HASHTYPE -- types of hashes 109 */ 110 111 #define DKIM_HASHTYPE_UNKNOWN (-1) 112 #define DKIM_HASHTYPE_SHA1 0 113 #define DKIM_HASHTYPE_SHA256 1 114 115 /* 116 ** DKIM_KEYTYPE -- types of keys 117 */ 118 119 #define DKIM_KEYTYPE_UNKNOWN (-1) 120 #define DKIM_KEYTYPE_RSA 0 121 122 /* 123 ** DKIM_SET -- a set of parameters and values 124 */ 125 126 struct dkim_set; 127 typedef struct dkim_set DKIM_SET; 128 129 /* 130 ** DKIM_PLIST -- a parameter/value pair, as a linked list 131 */ 132 133 struct dkim_plist; 134 typedef struct dkim_plist DKIM_PLIST; 135 136 /* 137 ** DKIM_KEY -- contents of a published key record 138 */ 139 140 struct dkim_key; 141 typedef struct dkim_key DKIM_KEY; 142 143 /* 144 ** DKIM_CANON -- canonicalization 145 */ 146 147 struct dkim_canon; 148 typedef struct dkim_canon DKIM_CANON; 149 150 /* prototypes */ 151 extern DKIM_STAT dkim_process_set __P((DKIM *, dkim_set_t, u_char *, size_t, 152 void *, _Bool, const char *)); 153 extern DKIM_STAT dkim_siglist_setup __P((DKIM *)); 154 155 #endif /* ! _DKIM_INTERNAL_H_ */ 156