2
** Copyright (c) 2005-2008 Sendmail, Inc. and its suppliers.
3
** All rights reserved.
5
** Copyright (c) 2009, The OpenDKIM Project. All rights reserved.
9
static char t_test73_c_id[] = "@(#)$Id: t-test73.c,v 1.3 2009/07/23 17:40:24 cm-msk Exp $";
13
#include <sys/types.h>
20
/* libopendkim includes */
22
#include "t-testdata.h"
24
#define MAXHEADER 4096
26
#define SIG2 "v=1; a=rsa-sha256; c=simple/simple; d=example.com; s=test;\r\n\tt=1172620939; bh=yHBAX+3IwxTZIynBuB/5tlsBInJq9n8qz5fgAycHi80=;\r\n\th=Received:Received:Received:From:To:Date:Subject:Message-ID; b=Y3y\r\n\tVeA3WZdCZl1sGuOZNC3BBRhtGCOExkZdw5xQoGPvSX/q6AC1SAJvOUWOri95AZAUGs0\r\n\t/bIDzzt23ei9jc+rptlavrl/5ijMrl6ShmvkACk6It62KPkJcDpoGfi5AZkrfX1Ou/z\r\n\tqGg5xJX86Kqd7FgNolMg7PbfyWliK2Yb84="
29
** MAIN -- program mainline
39
main(int argc, char **argv)
41
#ifndef DKIM_SIGN_RSASHA256
42
printf("*** simple/simple rsa-sha256 verifying with extra signature spaces and reportinfo (failure) SKIPPED\n");
44
#else /* ! DKIM_SIGN_RSASHA256 */
48
dkim_policy_t pcode = DKIM_POLICY_NONE;
54
dkim_query_t qtype = DKIM_QUERY_FILE;
55
unsigned char hdr[MAXHEADER + 1];
56
unsigned char addr[MAXADDRESS + 1];
57
unsigned char fmt[BUFRSZ];
58
unsigned char opts[BUFRSZ];
59
unsigned char smtp[BUFRSZ];
61
printf("*** simple/simple rsa-sha256 verifying with extra signature spaces and reportinfo (failure)\n");
63
/* instantiate the library */
64
lib = dkim_init(NULL, NULL);
68
flags = DKIM_LIBFLAGS_TMPFILES;
69
# ifdef TEST_KEEP_FILES
70
flags |= DKIM_LIBFLAGS_KEEPFILES;
71
# endif /* TEST_KEEP_FILES */
72
(void) dkim_options(lib, DKIM_OP_SETOPT, DKIM_OPTS_FLAGS, &flags,
75
(void) dkim_options(lib, DKIM_OP_SETOPT, DKIM_OPTS_QUERYMETHOD,
76
&qtype, sizeof qtype);
77
(void) dkim_options(lib, DKIM_OP_SETOPT, DKIM_OPTS_QUERYINFO,
78
KEYFILE, strlen(KEYFILE));
80
dkim = dkim_verify(lib, JOBID, NULL, &status);
83
snprintf(hdr, sizeof hdr, "%s: %s", DKIM_SIGNHEADER, SIG2);
84
status = dkim_header(dkim, hdr, strlen(hdr));
85
assert(status == DKIM_STAT_OK);
87
status = dkim_header(dkim, HEADER01, strlen(HEADER01));
88
assert(status == DKIM_STAT_OK);
90
status = dkim_header(dkim, HEADER02, strlen(HEADER02));
91
assert(status == DKIM_STAT_OK);
93
status = dkim_header(dkim, HEADER03, strlen(HEADER03));
94
assert(status == DKIM_STAT_OK);
96
status = dkim_header(dkim, HEADER04, strlen(HEADER04));
97
assert(status == DKIM_STAT_OK);
99
status = dkim_header(dkim, HEADER05, strlen(HEADER05));
100
assert(status == DKIM_STAT_OK);
102
status = dkim_header(dkim, HEADER06, strlen(HEADER06));
103
assert(status == DKIM_STAT_OK);
105
status = dkim_header(dkim, HEADER07, strlen(HEADER07));
106
assert(status == DKIM_STAT_OK);
108
status = dkim_header(dkim, HEADER08, strlen(HEADER08));
109
assert(status == DKIM_STAT_OK);
111
status = dkim_header(dkim, HEADER09, strlen(HEADER09));
112
assert(status == DKIM_STAT_OK);
114
status = dkim_eoh(dkim);
115
assert(status == DKIM_STAT_OK);
117
status = dkim_body(dkim, BODY00, strlen(BODY00));
118
assert(status == DKIM_STAT_OK);
120
status = dkim_body(dkim, BODY01, strlen(BODY01));
121
assert(status == DKIM_STAT_OK);
123
status = dkim_body(dkim, BODY01A, strlen(BODY01A));
124
assert(status == DKIM_STAT_OK);
125
status = dkim_body(dkim, BODY01B, strlen(BODY01B));
126
assert(status == DKIM_STAT_OK);
127
status = dkim_body(dkim, BODY01C, strlen(BODY01C));
128
assert(status == DKIM_STAT_OK);
129
status = dkim_body(dkim, BODY01D, strlen(BODY01D));
130
assert(status == DKIM_STAT_OK);
131
status = dkim_body(dkim, BODY01E, strlen(BODY01E));
132
assert(status == DKIM_STAT_OK);
134
status = dkim_body(dkim, BODY02, strlen(BODY02));
135
assert(status == DKIM_STAT_OK);
137
status = dkim_body(dkim, BODY03, strlen(BODY03));
138
assert(status == DKIM_STAT_OK);
140
status = dkim_body(dkim, BODY04, strlen(BODY04));
141
assert(status == DKIM_STAT_OK);
143
status = dkim_body(dkim, BODY03, strlen(BODY03));
144
assert(status == DKIM_STAT_OK);
146
status = dkim_body(dkim, BODY03, strlen(BODY03));
147
assert(status == DKIM_STAT_OK);
149
status = dkim_body(dkim, BODY05, strlen(BODY05));
150
assert(status == DKIM_STAT_OK);
152
status = dkim_body(dkim, BODY03, strlen(BODY03));
153
assert(status == DKIM_STAT_OK);
155
status = dkim_body(dkim, BODY03, strlen(BODY03));
156
assert(status == DKIM_STAT_OK);
158
status = dkim_eom(dkim, NULL);
159
assert(status == DKIM_STAT_BADSIG);
161
/* set up for the rest */
164
sig = dkim_getsignature(dkim);
167
/* policy query, verify correct result */
168
status = dkim_policy(dkim, &pcode, NULL);
169
assert(status == DKIM_STAT_OK);
170
assert(pcode == DKIM_POLICY_ALL);
172
/* request report info, verify valid descriptors and address */
173
memset(addr, '\0', sizeof addr);
174
memset(fmt, '\0', sizeof fmt);
175
memset(opts, '\0', sizeof opts);
176
memset(smtp, '\0', sizeof smtp);
177
status = dkim_sig_getreportinfo(dkim, sig, &hfd, &bfd,
181
smtp, sizeof smtp, NULL);
182
assert(status == DKIM_STAT_OK);
185
assert(strcmp(addr, REPLYADDRESS) == 0);
186
assert(strcmp(smtp, SMTPTOKEN) == 0);
188
/* test descriptors */
189
status = lseek(hfd, 0, SEEK_CUR);
191
status = lseek(bfd, 0, SEEK_CUR);
194
status = dkim_free(dkim);
195
assert(status == DKIM_STAT_OK);
198
#endif /* ! DKIM_SIGN_RSASHA256 */