Back to index

opendkim  2.6.4
t-test145.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_test145_c_id[] = "@(#)$Id: t-test00.c,v 1.2 2009/12/08 19:14: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 <stdio.h>
00018 #include <string.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 #define BADKEY              "-----BEGIN RSA PRIVATE KEY-----" \
00031        "MIICXQIBAAKBgQC4GUGr*d/6SFNzVLYpphnRd0QPGKz2uWnV65RAxa1Pw352Bqiz" \
00032        "qiKOBjgYGzj8pJQSs8tOvv/2k6jpI809RnESqOFgF0gu3UJbNnu3+cd8k/kiQj+q" \
00033        "4cKKRpAT92ccxc7svhCNgN1sBGmROYZuysG3Vu3Dyc079gSLtnSrgXb+gQIDAQAB" \
00034        "AoGAemlI0opm1Kvs2T4VliH8/tvX5FXbBH8LEZQAUwVeFTB/UQlieXyCV39pIxZO" \
00035        "0Sa50qm8YNL9rb5HTSZiHQFOwyAKNqS4m/7JCsbuH4gQkPgPF561BHNL9oKfYgJq" \
00036        "9P4kEFfDTBoXKBMxwWtT7AKV8dYvCa3vYzPQ/1BnqQdw2zECQQDyscdgR9Ih59PQ" \
00037        "b72ddibdsxS65uXS2vzYLe7SKl+4R5JgJzw0M6DTAnoYFf6JAsKGZM15PCC0E16t" \
00038        "RRo47U9VAkEAwjEVrlQ0/8yPACbDggDJg/Zz/uRu1wK0zjqj4vKjleubaX4SEvj7" \
00039        "r6xxZm9hC1pMJAC9y3bbkbgCRBjXfyY6fQJBANe5aq2MaZ41wTOPf45NjbKXEiAo" \
00040        "SbUpboKCIbyyaa8V/2h0t7D3C0dE9l4efsguqdZoF7Rh2/f1F70QpYRgfJkCQQCH" \
00041        "oRrAeGXP50JVW72fNgeJGH/pnghgOa6of0JpxwhENJuGMZxUDfxTtUA6yD3iXP3j" \
00042        "A3WL/wbaHsfOYf9Y+g1NAkAGLhx67Ah+uBNK4Xvfz0YPGINX20m+CMsxAw7FOaNv" \
00043        "IW2oWFfZCB4APkIis79Ql45AHpavwx5XodBMzZwJUvlL\n" \
00044        "-----END RSA PRIVATE KEY-----\n"
00045 
00046 /*
00047 **  MAIN -- program mainline
00048 **
00049 **  Parameters:
00050 **     The usual.
00051 **
00052 **  Return value:
00053 **     Exit status.
00054 */
00055 
00056 int
00057 main(int argc, char **argv)
00058 {
00059 #ifdef TEST_KEEP_FILES
00060        u_int flags;
00061 #endif /* TEST_KEEP_FILES */
00062        DKIM_STAT status;
00063        uint64_t fixed_time;
00064        DKIM *dkim;
00065        DKIM_LIB *lib;
00066        dkim_sigkey_t key;
00067        unsigned char hdr[MAXHEADER + 1];
00068 
00069        printf("*** invalid key preload test\n");
00070 
00071 #ifdef USE_GNUTLS
00072        (void) gnutls_global_init();
00073 #endif /* USE_GNUTLS */
00074 
00075        /* instantiate the library */
00076        lib = dkim_init(NULL, NULL);
00077        assert(lib != NULL);
00078 
00079 #ifdef TEST_KEEP_FILES
00080        /* set flags */
00081        flags = (DKIM_LIBFLAGS_TMPFILES|DKIM_LIBFLAGS_KEEPFILES);
00082        (void) dkim_options(lib, DKIM_OP_SETOPT, DKIM_OPTS_FLAGS, &flags,
00083                            sizeof flags);
00084 #endif /* TEST_KEEP_FILES */
00085 
00086        key = BADKEY;
00087 
00088        dkim = dkim_sign(lib, JOBID, NULL, key, SELECTOR, DOMAIN,
00089                         DKIM_CANON_RELAXED, DKIM_CANON_RELAXED,
00090                         DKIM_SIGN_RSASHA1, -1L, &status);
00091        assert(dkim != NULL);
00092 
00093        status = dkim_privkey_load(dkim);
00094        assert(status == DKIM_STAT_NORESOURCE);
00095 
00096        status = dkim_free(dkim);
00097        assert(status == DKIM_STAT_OK);
00098 
00099        dkim_close(lib);
00100 
00101        return 0;
00102 }