~ubuntu-branches/ubuntu/lucid/opendkim/lucid-backports

« back to all changes in this revision

Viewing changes to libopendkim/t-test61.c

  • Committer: Bazaar Package Importer
  • Author(s): Mike Markley
  • Date: 2010-03-17 13:04:28 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100317130428-i5klbz2debsy0aku
Tags: 2.0.0+dfsg-1
* New upstream version.
* The libopendkim ABI has changed, resulting in an soname change.
  - libopendkim0 package renamed to libopendkim1.
* New LDAP and Lua support have been enabled.
* Wrote clearer package descriptions. Closes: #572725
* Added build-dependency on autotools-dev. For now, the package ships with
  very old config.sub and config.guess files, but this will be resolved
  upstream in the near future.
  - Also removed extraneous top-level config.{sub,guess} files.
* Applied two upstream patches for off-by-one errors, including one that can
  cause crashes when signing.
* debian/copyright file was not accurate; it has been updated to reflect the
  fork from the dkim-milter project. The dkim-milter license should be fully
  compatible with the BSD license of this fork.

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_test61_c_id[] = "@(#)$Id: t-test61.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-sha0; c=relaxed/simple; d=example.com; s=test;\r\n\tt=1172620939; bh=ll/0h2aWgG+D3ewmE4Y3pY7Ukz8=; h=Received:Received:\r\n\t Received:From:To:Date:Subject:Message-ID; b=bj9kVUbnBYfe9sVzH9lT45\r\n\tTFKO3eQnDbXLfgmgu/b5QgxcnhT9ojnV2IAM4KUO8+hOo5sDEu5Co/0GASH0vHpSV4P\r\n\t377Iwew3FxvLpHsVbVKgXzoKD4QSbHRpWNxyL6LypaaqFa96YqjXuYXr0vpb88hticn\r\n\t6I16//WThMz8fMU="
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
 
#ifdef TEST_KEEP_FILES
41
 
        u_int flags;
42
 
#endif /* TEST_KEEP_FILES */
43
 
        DKIM_STAT status;
44
 
        DKIM *dkim;
45
 
        DKIM_LIB *lib;
46
 
        dkim_query_t qtype = DKIM_QUERY_FILE;
47
 
        unsigned char hdr[MAXHEADER + 1];
48
 
 
49
 
        printf("*** relaxed/simple verifying with bogus signature algorithm\n");
50
 
 
51
 
        /* instantiate the library */
52
 
        lib = dkim_init(NULL, NULL);
53
 
        assert(lib != NULL);
54
 
 
55
 
#ifdef TEST_KEEP_FILES
56
 
        /* set flags */
57
 
        flags = (DKIM_LIBFLAGS_TMPFILES|DKIM_LIBFLAGS_KEEPFILES);
58
 
        (void) dkim_options(lib, DKIM_OP_SETOPT, DKIM_OPTS_FLAGS, &flags,
59
 
                            sizeof flags);
60
 
#endif /* TEST_KEEP_FILES */
61
 
 
62
 
        (void) dkim_options(lib, DKIM_OP_SETOPT, DKIM_OPTS_QUERYMETHOD,
63
 
                            &qtype, sizeof qtype);
64
 
        (void) dkim_options(lib, DKIM_OP_SETOPT, DKIM_OPTS_QUERYINFO,
65
 
                            KEYFILE, strlen(KEYFILE));
66
 
 
67
 
        dkim = dkim_verify(lib, JOBID, NULL, &status);
68
 
        assert(dkim != NULL);
69
 
 
70
 
        snprintf(hdr, sizeof hdr, "%s: %s", DKIM_SIGNHEADER, SIG2);
71
 
        status = dkim_header(dkim, hdr, strlen(hdr));
72
 
        assert(status == DKIM_STAT_OK);
73
 
 
74
 
        status = dkim_header(dkim, HEADER01, strlen(HEADER01));
75
 
        assert(status == DKIM_STAT_OK);
76
 
 
77
 
        status = dkim_header(dkim, HEADER02, strlen(HEADER02));
78
 
        assert(status == DKIM_STAT_OK);
79
 
 
80
 
        status = dkim_header(dkim, HEADER03, strlen(HEADER03));
81
 
        assert(status == DKIM_STAT_OK);
82
 
 
83
 
        status = dkim_header(dkim, HEADER04, strlen(HEADER04));
84
 
        assert(status == DKIM_STAT_OK);
85
 
 
86
 
        status = dkim_header(dkim, HEADER05, strlen(HEADER05));
87
 
        assert(status == DKIM_STAT_OK);
88
 
 
89
 
        status = dkim_header(dkim, HEADER06, strlen(HEADER06));
90
 
        assert(status == DKIM_STAT_OK);
91
 
 
92
 
        status = dkim_header(dkim, HEADER07, strlen(HEADER07));
93
 
        assert(status == DKIM_STAT_OK);
94
 
 
95
 
        status = dkim_header(dkim, HEADER08, strlen(HEADER08));
96
 
        assert(status == DKIM_STAT_OK);
97
 
 
98
 
        status = dkim_header(dkim, HEADER09, strlen(HEADER09));
99
 
        assert(status == DKIM_STAT_OK);
100
 
 
101
 
        status = dkim_eoh(dkim);
102
 
        assert(status == DKIM_STAT_OK);
103
 
 
104
 
        status = dkim_body(dkim, BODY00, strlen(BODY00));
105
 
        assert(status == DKIM_STAT_OK);
106
 
 
107
 
        status = dkim_body(dkim, BODY01, strlen(BODY01));
108
 
        assert(status == DKIM_STAT_OK);
109
 
 
110
 
        status = dkim_body(dkim, BODY01A, strlen(BODY01A));
111
 
        assert(status == DKIM_STAT_OK);
112
 
        status = dkim_body(dkim, BODY01B, strlen(BODY01B));
113
 
        assert(status == DKIM_STAT_OK);
114
 
        status = dkim_body(dkim, BODY01C, strlen(BODY01C));
115
 
        assert(status == DKIM_STAT_OK);
116
 
        status = dkim_body(dkim, BODY01D, strlen(BODY01D));
117
 
        assert(status == DKIM_STAT_OK);
118
 
        status = dkim_body(dkim, BODY01E, strlen(BODY01E));
119
 
        assert(status == DKIM_STAT_OK);
120
 
 
121
 
        status = dkim_body(dkim, BODY02, strlen(BODY02));
122
 
        assert(status == DKIM_STAT_OK);
123
 
 
124
 
        status = dkim_body(dkim, BODY03, strlen(BODY03));
125
 
        assert(status == DKIM_STAT_OK);
126
 
 
127
 
        status = dkim_body(dkim, BODY04, strlen(BODY04));
128
 
        assert(status == DKIM_STAT_OK);
129
 
 
130
 
        status = dkim_body(dkim, BODY03, strlen(BODY03));
131
 
        assert(status == DKIM_STAT_OK);
132
 
 
133
 
        status = dkim_body(dkim, BODY03, strlen(BODY03));
134
 
        assert(status == DKIM_STAT_OK);
135
 
 
136
 
        status = dkim_body(dkim, BODY05, strlen(BODY05));
137
 
        assert(status == DKIM_STAT_OK);
138
 
 
139
 
        status = dkim_body(dkim, BODY03, strlen(BODY03));
140
 
        assert(status == DKIM_STAT_OK);
141
 
 
142
 
        status = dkim_body(dkim, BODY03, strlen(BODY03));
143
 
        assert(status == DKIM_STAT_OK);
144
 
 
145
 
        status = dkim_eom(dkim, NULL);
146
 
        assert(status == DKIM_STAT_CANTVRFY);
147
 
 
148
 
        status = dkim_free(dkim);
149
 
        assert(status == DKIM_STAT_OK);
150
 
 
151
 
        dkim_close(lib);
152
 
 
153
 
        return 0;
154
 
}