-
Notifications
You must be signed in to change notification settings - Fork 3
/
signing-milter.h
144 lines (126 loc) · 3.71 KB
/
signing-milter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
* signing-milter - signing-milter.h
* Copyright (C) 2010-2021 Andreas Schulze
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; only version 2 of the License is applicable.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Authors:
* Andreas Schulze <signing-milter at andreasschulze.de>
*
*/
#ifndef _SIGNING_MILTER_H_INCLUDED_
#define _SIGNING_MILTER_H_INCLUDED_
#include <cdb.h>
#include <openssl/x509.h>
#include "config.h"
#define STR_PROGNAME "signing-milter"
#ifdef NDEBUG
#define STR_PROGVERSION "20210822"
#else
#define STR_PROGVERSION "20210822-debug"
#endif
/*
* Name of the header added by -x cmdline switch
*/
#define HEADERNAME_XHEADER "X-Signed-by"
/*
* Name of the header used as signeraddress
* if opt_signerfromheader is enabled
*/
#define HEADERNAME_SIGNER "X-Signer"
/*
* Name of the header used to signal the
* desire to not sign a particular message
*/
#define HEADERNAME_SKIP_SIGNING "X-Skip-Signing"
/* buffer for caching one header */
#define MAXHEADERLEN 4096
/* ======= CDB ======================= */
/* übliche Länge des Speichers der für dict.buffer allokiert wird */
#define DICT_BUFFER_LEN 512
typedef struct DICT {
char* name;
int flags;
int stat_fd;
time_t mtime;
struct cdb cdb;
char* buffer;
char* result;
unsigned result_len;
} DICT;
#define DICT_FLAG_TRY0NULL (1<<2) /* do not append 0 to key/value */
#define DICT_FLAG_TRY1NULL (1<<3) /* append 0 to key/value */
/* ======= NODES ======================= */
/*
* - Zeiger auf den naechsten Knoten
* - Type des Knoten
*/
struct node_t {
struct node_t* next;
char* headerf;
char* headerv;
};
#define NODE struct node_t
/* ======= CALLBACK ================== */
struct ctxdata {
char* pemfilename;
NODE* headerchain;
unsigned char* data2sign;
size_t data2sign_len;
X509* cert;
EVP_PKEY* key;
STACK_OF(X509)* chain;
BIO* inbio;
BIO* outbio;
PKCS7* pkcs7;
int pkcs7flags;
int mailflags;
char* buffer;
size_t buffer_len;
char* queueid;
int first_bodychunk_seen;
char* keepdir;
};
#define CTXDATA struct ctxdata
/* Werte fuer ctxdata.mailflags */
#define MF_TYPE_MIME (1<<0)
#define MF_TYPE_MULTIPART (1<<1)
#define MF_SIGNMODE_OPAQUE (1<<2)
#define MF_SIGNER_FROM_HEADER (1<<3)
#define MF_SKIP_SIGNING (1<<4)
/*
* globale Variablen
* koennen durch Kommandozeienparameter
* veraendert werden
*/
extern char* opt_clientgroup;
extern int opt_loglevel;
extern int opt_logdest;
extern char* opt_group;
extern char* opt_keepdir;
extern char* opt_signingtable;
extern char* opt_modetable;
extern char* opt_miltersocket;
extern int opt_timeout;
extern char* opt_user;
extern int opt_addxheader;
extern int opt_signerfromheader;
extern struct DICT dict_signingtable;
extern struct DICT dict_modetable;
/*
* where logging goes
*/
#define LOG_DEST_SYSLOG 1
#define LOG_DEST_STDOUT 2
#endif