Back to index

opendkim  2.6.6
t-test135.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_test135_c_id[] = "@(#)$Id: t-test135.c,v 1.2 2010/04/12 15:08:46 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 #ifdef USE_GNUTLS
00021 # include <gnutls/gnutls.h>
00022 #endif /* USE_GNUTLS */
00023 
00024 /* libopendkim includes */
00025 #include "../dkim.h"
00026 #include "t-testdata.h"
00027 
00028 #define       MAXHEADER     4096
00029 
00030 /*
00031 **  MAIN -- program mainline
00032 **
00033 **  Parameters:
00034 **     The usual.
00035 **
00036 **  Return value:
00037 **     Exit status.
00038 */
00039 
00040 int
00041 main(int argc, char **argv)
00042 {
00043 #ifdef TEST_KEEP_FILES
00044        u_int flags;
00045 #endif /* TEST_KEEP_FILES */
00046        DKIM_STAT status;
00047        DKIM *dkim;
00048        DKIM_LIB *lib;
00049        dkim_query_t qtype = DKIM_QUERY_FILE;
00050        unsigned char hdr[MAXHEADER + 1];
00051 
00052        printf("*** relaxed/simple rsa-sha1 verifying using chunking API (leading CRLF)\n");
00053 
00054 #ifdef USE_GNUTLS
00055        (void) gnutls_global_init();
00056 #endif /* USE_GNUTLS */
00057 
00058        /* instantiate the library */
00059        lib = dkim_init(NULL, NULL);
00060        assert(lib != NULL);
00061 
00062 #ifdef TEST_KEEP_FILES
00063        /* set flags */
00064        flags = (DKIM_LIBFLAGS_TMPFILES|DKIM_LIBFLAGS_KEEPFILES);
00065        (void) dkim_options(lib, DKIM_OP_SETOPT, DKIM_OPTS_FLAGS, &flags,
00066                            sizeof flags);
00067 #endif /* TEST_KEEP_FILES */
00068 
00069        (void) dkim_options(lib, DKIM_OP_SETOPT, DKIM_OPTS_QUERYMETHOD,
00070                            &qtype, sizeof qtype);
00071        (void) dkim_options(lib, DKIM_OP_SETOPT, DKIM_OPTS_QUERYINFO,
00072                            KEYFILE, strlen(KEYFILE));
00073 
00074        dkim = dkim_verify(lib, JOBID, NULL, &status);
00075        assert(dkim != NULL);
00076 
00077        status = dkim_chunk(dkim, CRLF, strlen(CRLF));
00078        assert(status == DKIM_STAT_SYNTAX);
00079 
00080        status = dkim_free(dkim);
00081        assert(status == DKIM_STAT_OK);
00082 
00083        dkim_close(lib);
00084 
00085        return 0;
00086 }