Back to index

opendkim  2.6.2
t-test139.c
Go to the documentation of this file.
00001 /*
00002 **  Copyright (c) 2005-2008 Sendmail, Inc. and its suppliers.
00003 **    All rights reserved.
00004 **
00005 **  Copyright (c) 2009-2011, The OpenDKIM Project.  All rights reserved.
00006 */
00007 
00008 #ifndef lint
00009 static char t_test139_c_id[] = "@(#)$Id: t-test139.c,v 1.1.2.1 2010/10/09 04:55:27 cm-msk Exp $";
00010 #endif /* !lint */
00011 
00012 #include "build-config.h"
00013 
00014 /* system includes */
00015 #include <sys/types.h>
00016 #include <assert.h>
00017 #include <string.h>
00018 #include <stdio.h>
00019 
00020 /* libopendkim includes */
00021 #include "../dkim.h"
00022 #include "t-testdata.h"
00023 
00024 #define       MAXHEADER     4096
00025 
00026 #define SIG2 "v=1; a=rsa-sha1; c=relaxed/relaxed; d=example.com; s=test;\r\n\tt=1172620939; bh=Z9ONHHsBrKN0pbfrOu025VfbdR4=;\r\n\th=Received:Received:Received:From:To:Date:Subject:Message-ID:From;\r\n\tb=RvWqtJbgK3zK97zc8zGtuu90bZh0ytXhgfGzYzY+aOPK1Uq0jIvBvNLzDUBucQoII\r\n\t hjhzo0hMd0p2IcVkuWAG46vVxwrs7lfDjLnh6KbrpWyKCrcfve9I2SsFAHf68odc5y\r\n\t hapNm/weWJHWqdSUoxMqiFVuFChRsEXzsKDh5ffo="
00027 
00028 /*
00029 **  MAIN -- program mainline
00030 **
00031 **  Parameters:
00032 **     The usual.
00033 **
00034 **  Return value:
00035 **     Exit status.
00036 */
00037 
00038 int
00039 main(int argc, char **argv)
00040 {
00041 #ifdef TEST_KEEP_FILES
00042        u_int flags;
00043 #endif /* TEST_KEEP_FILES */
00044        DKIM_STAT status;
00045        DKIM *dkim;
00046        DKIM_LIB *lib;
00047        dkim_query_t qtype = DKIM_QUERY_FILE;
00048        unsigned char hdr[MAXHEADER + 1];
00049 
00050        printf("*** relaxed/relaxed rsa-sha1 verifying with oversigning\n");
00051 
00052 #ifdef USE_GNUTLS
00053        (void) gnutls_global_init();
00054 #endif /* USE_GNUTLS */
00055 
00056        /* instantiate the library */
00057        lib = dkim_init(NULL, NULL);
00058        assert(lib != NULL);
00059 
00060 #ifdef TEST_KEEP_FILES
00061        /* set flags */
00062        flags = (DKIM_LIBFLAGS_TMPFILES|DKIM_LIBFLAGS_KEEPFILES);
00063        (void) dkim_options(lib, DKIM_OP_SETOPT, DKIM_OPTS_FLAGS, &flags,
00064                            sizeof flags);
00065 #endif /* TEST_KEEP_FILES */
00066 
00067        (void) dkim_options(lib, DKIM_OP_SETOPT, DKIM_OPTS_QUERYMETHOD,
00068                            &qtype, sizeof qtype);
00069        (void) dkim_options(lib, DKIM_OP_SETOPT, DKIM_OPTS_QUERYINFO,
00070                            KEYFILE, strlen(KEYFILE));
00071 
00072        dkim = dkim_verify(lib, JOBID, NULL, &status);
00073        assert(dkim != NULL);
00074 
00075        snprintf(hdr, sizeof hdr, "%s: %s", DKIM_SIGNHEADER, SIG2);
00076        status = dkim_header(dkim, hdr, strlen(hdr));
00077        assert(status == DKIM_STAT_OK);
00078 
00079        status = dkim_header(dkim, HEADER01, strlen(HEADER01));
00080        assert(status == DKIM_STAT_OK);
00081 
00082        status = dkim_header(dkim, HEADER02, strlen(HEADER02));
00083        assert(status == DKIM_STAT_OK);
00084 
00085        status = dkim_header(dkim, HEADER03, strlen(HEADER03));
00086        assert(status == DKIM_STAT_OK);
00087 
00088        status = dkim_header(dkim, HEADER04, strlen(HEADER04));
00089        assert(status == DKIM_STAT_OK);
00090 
00091        status = dkim_header(dkim, HEADER05, strlen(HEADER05));
00092        assert(status == DKIM_STAT_OK);
00093 
00094        status = dkim_header(dkim, HEADER06, strlen(HEADER06));
00095        assert(status == DKIM_STAT_OK);
00096 
00097        status = dkim_header(dkim, HEADER07, strlen(HEADER07));
00098        assert(status == DKIM_STAT_OK);
00099 
00100        status = dkim_header(dkim, HEADER08, strlen(HEADER08));
00101        assert(status == DKIM_STAT_OK);
00102 
00103        status = dkim_header(dkim, HEADER09, strlen(HEADER09));
00104        assert(status == DKIM_STAT_OK);
00105 
00106        status = dkim_eoh(dkim);
00107        assert(status == DKIM_STAT_OK);
00108 
00109        status = dkim_body(dkim, BODY00, strlen(BODY00));
00110        assert(status == DKIM_STAT_OK);
00111 
00112        status = dkim_body(dkim, BODY01, strlen(BODY01));
00113        assert(status == DKIM_STAT_OK);
00114 
00115        status = dkim_body(dkim, BODY01A, strlen(BODY01A));
00116        assert(status == DKIM_STAT_OK);
00117        status = dkim_body(dkim, BODY01B, strlen(BODY01B));
00118        assert(status == DKIM_STAT_OK);
00119        status = dkim_body(dkim, BODY01C, strlen(BODY01C));
00120        assert(status == DKIM_STAT_OK);
00121        status = dkim_body(dkim, BODY01D, strlen(BODY01D));
00122        assert(status == DKIM_STAT_OK);
00123        status = dkim_body(dkim, BODY01E, strlen(BODY01E));
00124        assert(status == DKIM_STAT_OK);
00125 
00126        status = dkim_body(dkim, BODY02, strlen(BODY02));
00127        assert(status == DKIM_STAT_OK);
00128 
00129        status = dkim_body(dkim, BODY03, strlen(BODY03));
00130        assert(status == DKIM_STAT_OK);
00131 
00132        status = dkim_body(dkim, BODY04, strlen(BODY04));
00133        assert(status == DKIM_STAT_OK);
00134 
00135        status = dkim_body(dkim, BODY03, strlen(BODY03));
00136        assert(status == DKIM_STAT_OK);
00137 
00138        status = dkim_body(dkim, BODY03, strlen(BODY03));
00139        assert(status == DKIM_STAT_OK);
00140 
00141        status = dkim_body(dkim, BODY05, strlen(BODY05));
00142        assert(status == DKIM_STAT_OK);
00143 
00144        status = dkim_body(dkim, BODY03, strlen(BODY03));
00145        assert(status == DKIM_STAT_OK);
00146 
00147        status = dkim_body(dkim, BODY03, strlen(BODY03));
00148        assert(status == DKIM_STAT_OK);
00149 
00150        status = dkim_eom(dkim, NULL);
00151        assert(status == DKIM_STAT_OK);
00152 
00153        status = dkim_free(dkim);
00154        assert(status == DKIM_STAT_OK);
00155 
00156        dkim_close(lib);
00157 
00158        return 0;
00159 }