~ubuntu-branches/ubuntu/maverick/opendkim/maverick

« back to all changes in this revision

Viewing changes to libopendkim/t-test15.c

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-04-11 22:01:02 UTC
  • mfrom: (1.2.1 upstream) (3.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20100411220102-jbukmeir0w7xych9
Tags: 2.0.1+dfsg-0ubuntu1
* New upstream bugfix release (fixes bug that made previous package non-
  operable with Yahoo!)
  - Remove non-free IETF drafts and RFCs and repack tarball
  - Adjust Makefile.in to not build with removed documentation
  - Set default socket to localhost port 8891 to work with Postfix and match
    Ubuntu default for dkim-filter

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
**  Copyright (c) 2005-2008 Sendmail, Inc. and its suppliers.
3
 
**    All rights reserved.
4
 
**
5
 
**  Copyright (c) 2009, The OpenDKIM Project.  All rights reserved.
6
 
*/
7
 
 
8
 
#ifndef lint
9
 
static char t_test15_c_id[] = "@(#)$Id: t-test15.c,v 1.3 2009/07/23 17:40:24 cm-msk Exp $";
10
 
#endif /* !lint */
11
 
 
12
 
/* system includes */
13
 
#include <sys/types.h>
14
 
#include <assert.h>
15
 
#include <string.h>
16
 
#include <stdio.h>
17
 
 
18
 
 
19
 
/* libopendkim includes */
20
 
#include "dkim.h"
21
 
#include "t-testdata.h"
22
 
 
23
 
#define MAXHEADER       4096
24
 
 
25
 
#define SIG2 "v=1; a=rsa-sha1; c=simple/simple; d=example.com; s=test;\r\n\tt=1172620939; bh=ll/0h2aWgG+D3ewmE4Y3pY7Ukz8=; l=343; h=Received:\r\n\t Received:Received:From:To:Date:Subject:Message-ID; b=RrR6zc3KAYHOj\r\n\tFdWv9JRXIYmvOSBRZ9kR3M4y/S0KqrsUKFycJq9NcbY8lHyAGoJVgKFxmXOhC3+RVjy\r\n\tLOKPPJGikY+mgLvHgAS+lBK5tuQBWXb+W2uSACVCk0KfTeQv+9RaAecyBeX1CpjQHnc\r\n\tSIKKfWhjY7GdLyyg1mIb3rN4="
26
 
 
27
 
/*
28
 
**  MAIN -- program mainline
29
 
**
30
 
**  Parameters:
31
 
**      The usual.
32
 
**
33
 
**  Return value:
34
 
**      Exit status.
35
 
*/
36
 
 
37
 
int
38
 
main(int argc, char **argv)
39
 
{
40
 
        u_int flags;
41
 
        DKIM_STAT status;
42
 
        DKIM *dkim;
43
 
        DKIM_LIB *lib;
44
 
        dkim_query_t qtype = DKIM_QUERY_FILE;
45
 
        unsigned char hdr[MAXHEADER + 1];
46
 
 
47
 
        printf("*** simple/simple rsa-sha1 verifying with lengths plus extra data\n");
48
 
 
49
 
        /* instantiate the library */
50
 
        lib = dkim_init(NULL, NULL);
51
 
        assert(lib != NULL);
52
 
 
53
 
#ifdef TEST_KEEP_FILES
54
 
        /* set flags */
55
 
        flags = (DKIM_LIBFLAGS_TMPFILES|DKIM_LIBFLAGS_KEEPFILES);
56
 
        (void) dkim_options(lib, DKIM_OP_SETOPT, DKIM_OPTS_FLAGS, &flags,
57
 
                            sizeof flags);
58
 
#endif /* TEST_KEEP_FILES */
59
 
 
60
 
        (void) dkim_options(lib, DKIM_OP_GETOPT, DKIM_OPTS_FLAGS, &flags,
61
 
                            sizeof flags);
62
 
        flags |= DKIM_LIBFLAGS_SIGNLEN;
63
 
        (void) dkim_options(lib, DKIM_OP_SETOPT, DKIM_OPTS_FLAGS, &flags,
64
 
                            sizeof flags);
65
 
 
66
 
        (void) dkim_options(lib, DKIM_OP_SETOPT, DKIM_OPTS_QUERYMETHOD,
67
 
                            &qtype, sizeof qtype);
68
 
        (void) dkim_options(lib, DKIM_OP_SETOPT, DKIM_OPTS_QUERYINFO,
69
 
                            KEYFILE, strlen(KEYFILE));
70
 
 
71
 
        dkim = dkim_verify(lib, JOBID, NULL, &status);
72
 
        assert(dkim != NULL);
73
 
 
74
 
        snprintf(hdr, sizeof hdr, "%s: %s", DKIM_SIGNHEADER, SIG2);
75
 
        status = dkim_header(dkim, hdr, strlen(hdr));
76
 
        assert(status == DKIM_STAT_OK);
77
 
 
78
 
        status = dkim_header(dkim, HEADER01, strlen(HEADER01));
79
 
        assert(status == DKIM_STAT_OK);
80
 
 
81
 
        status = dkim_header(dkim, HEADER02, strlen(HEADER02));
82
 
        assert(status == DKIM_STAT_OK);
83
 
 
84
 
        status = dkim_header(dkim, HEADER03, strlen(HEADER03));
85
 
        assert(status == DKIM_STAT_OK);
86
 
 
87
 
        status = dkim_header(dkim, HEADER04, strlen(HEADER04));
88
 
        assert(status == DKIM_STAT_OK);
89
 
 
90
 
        status = dkim_header(dkim, HEADER05, strlen(HEADER05));
91
 
        assert(status == DKIM_STAT_OK);
92
 
 
93
 
        status = dkim_header(dkim, HEADER06, strlen(HEADER06));
94
 
        assert(status == DKIM_STAT_OK);
95
 
 
96
 
        status = dkim_header(dkim, HEADER07, strlen(HEADER07));
97
 
        assert(status == DKIM_STAT_OK);
98
 
 
99
 
        status = dkim_header(dkim, HEADER08, strlen(HEADER08));
100
 
        assert(status == DKIM_STAT_OK);
101
 
 
102
 
        status = dkim_header(dkim, HEADER09, strlen(HEADER09));
103
 
        assert(status == DKIM_STAT_OK);
104
 
 
105
 
        status = dkim_eoh(dkim);
106
 
        assert(status == DKIM_STAT_OK);
107
 
 
108
 
        status = dkim_body(dkim, BODY00, strlen(BODY00));
109
 
        assert(status == DKIM_STAT_OK);
110
 
 
111
 
        status = dkim_body(dkim, BODY01, strlen(BODY01));
112
 
        assert(status == DKIM_STAT_OK);
113
 
 
114
 
        status = dkim_body(dkim, BODY01A, strlen(BODY01A));
115
 
        assert(status == DKIM_STAT_OK);
116
 
        status = dkim_body(dkim, BODY01B, strlen(BODY01B));
117
 
        assert(status == DKIM_STAT_OK);
118
 
        status = dkim_body(dkim, BODY01C, strlen(BODY01C));
119
 
        assert(status == DKIM_STAT_OK);
120
 
        status = dkim_body(dkim, BODY01D, strlen(BODY01D));
121
 
        assert(status == DKIM_STAT_OK);
122
 
        status = dkim_body(dkim, BODY01E, strlen(BODY01E));
123
 
        assert(status == DKIM_STAT_OK);
124
 
 
125
 
        status = dkim_body(dkim, BODY02, strlen(BODY02));
126
 
        assert(status == DKIM_STAT_OK);
127
 
 
128
 
        status = dkim_body(dkim, BODY03, strlen(BODY03));
129
 
        assert(status == DKIM_STAT_OK);
130
 
 
131
 
        status = dkim_body(dkim, BODY04, strlen(BODY04));
132
 
        assert(status == DKIM_STAT_OK);
133
 
 
134
 
        status = dkim_body(dkim, BODY03, strlen(BODY03));
135
 
        assert(status == DKIM_STAT_OK);
136
 
 
137
 
        status = dkim_body(dkim, BODY03, strlen(BODY03));
138
 
        assert(status == DKIM_STAT_OK);
139
 
 
140
 
        status = dkim_body(dkim, BODY05, strlen(BODY05));
141
 
        assert(status == DKIM_STAT_OK);
142
 
 
143
 
        status = dkim_body(dkim, BODY03, strlen(BODY03));
144
 
        assert(status == DKIM_STAT_OK);
145
 
 
146
 
        status = dkim_body(dkim, BODY03, strlen(BODY03));
147
 
        assert(status == DKIM_STAT_OK);
148
 
 
149
 
        status = dkim_body(dkim, BODY06, strlen(BODY06));
150
 
        assert(status == DKIM_STAT_OK);
151
 
 
152
 
        status = dkim_eom(dkim, NULL);
153
 
        assert(status == DKIM_STAT_OK);
154
 
 
155
 
        status = dkim_free(dkim);
156
 
        assert(status == DKIM_STAT_OK);
157
 
 
158
 
        dkim_close(lib);
159
 
 
160
 
        return 0;
161
 
}