Back to index

opendkim  2.6.6
t-test114.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_test114_c_id[] = "@(#)$Id: t-test114.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 <string.h>
00018 #include <stdio.h>
00019 #include <time.h>
00020 
00021 #ifdef USE_GNUTLS
00022 # include <gnutls/gnutls.h>
00023 #endif /* USE_GNUTLS */
00024 
00025 /* libopendkim includes */
00026 #include "../dkim.h"
00027 #include "t-testdata.h"
00028 
00029 #define       MAXHEADER     4096
00030 
00031 /* template */
00032 #define SIG "v=1; a=rsa-sha1; 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="
00033 
00034 #define SIG1 "v=1; a=rsa-sha1; c=relaxed/simple; d=example.com; s=test;\r\n\tt=1172620939; bh=ll/0h2aWgG+D3ewmE4Y3pY7Ukz8=; b=bj9kVUbnBYfe9sVzH9lT45\r\n\tTFKO3eQnDbXLfgmgu/b5QgxcnhT9ojnV2IAM4KUO8+hOo5sDEu5Co/0GASH0vHpSV4P\r\n\t377Iwew3FxvLpHsVbVKgXzoKD4QSbHRpWNxyL6LypaaqFa96YqjXuYXr0vpb88hticn\r\n\t6I16//WThMz8fMU="
00035 #define SIG2 "v=1; a=rsa-sha1; c=relaxed/simple; d=example.com; s=test;\r\n\tt=1172620939; l=-1; 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="
00036 #define SIG3 "v=1; a=rsa-sha1; c=relaxed/simple; d=example.com; s=test;\r\n\tt=1172620939; l=all; 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="
00037 #define SIG4 "v=1; a=rsa-sha1; c=relaxed/simple; d=example.com; s=test;\r\n\tt=1172620939; q=foo; 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="
00038 #define SIG5 "v=1; a=rsa-sha1; c=relaxed/simple; d=example.com; s=test;\r\n\tt=1172620939; q=dns/foo; 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="
00039 #define SIG6 "v=1; a=rsa-sha1; c=relaxed/simple; s=test;\r\n\tt=1172620939; q=dns/foo; 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="
00040 #define SIG7 "v=1; a=rsa-sha1; c=relaxed/simple; d=example.com; \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="
00041 #define SIG8 "v=1; a=rsa-sha1; c=relaxed/simple; d=; 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="
00042 #define SIG9 "v=1; a=rsa-sha1; c=relaxed/simple; d=example.com; s=;\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="
00043 #define SIG10 "v=1; a=rsa-sha1; c=relaxed/simple; d=example.com; s=test;\r\n\tt=1172620939; 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="
00044 #define SIG11 "v=1; a=rsa-sha1; c=relaxed/simple; d=example.com; s=test;\r\n\tt=1172620939; bh=; 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="
00045 #define SIG12 "v=1; 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="
00046 #define SIG13 "v=1; a=rsa-sha1; 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"
00047 #define SIG14 "v=1; a=rsa-sha1; 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="
00048 #define SIG15 "v=1; a=rsa-sha1; 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//WThMz8f="
00049 #define SIG16 "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="
00050 #define SIG17 "v=1; a=rsa-sha1; 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=; x"
00051 #define SIG18 "v=1; a=rsa-sha1; c=relaxed/simple; d=example.com; s=test;\r\n\tt=%ld; x=%ld; 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="
00052 #define SIG19 "v=1; a=rsa-sha1; c=relaxed/simple; d=example.com; s=test;\r\n\tt=1172620939; x=never; 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="
00053 #define SIG20 "v=1; =rsa-sha1; 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="
00054 #define SIG21 "v=1; 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="
00055 #define SIG22 "v=1; a=rsa-sha1; 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="
00056 #define SIG23 "a=rsa-sha1; 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="
00057 
00058 /*
00059 **  MAIN -- program mainline
00060 **
00061 **  Parameters:
00062 **     The usual.
00063 **
00064 **  Return value:
00065 **     Exit status.
00066 */
00067 
00068 int
00069 main(int argc, char **argv)
00070 {
00071 #ifdef TEST_KEEP_FILES
00072        u_int flags;
00073 #endif /* TEST_KEEP_FILES */
00074        int nsigs;
00075        int len;
00076        DKIM_STAT status;
00077        dkim_canon_t bcanon;
00078        dkim_canon_t hcanon;
00079        time_t now;
00080        DKIM *dkim;
00081        DKIM_LIB *lib;
00082        DKIM_SIGINFO **sigs;
00083        dkim_query_t qtype = DKIM_QUERY_FILE;
00084        unsigned char hdr[MAXHEADER + 1];
00085 
00086        printf("*** detection of various signature abnormalities\n");
00087 
00088 #ifdef USE_GNUTLS
00089        (void) gnutls_global_init();
00090 #endif /* USE_GNUTLS */
00091 
00092        /* instantiate the library */
00093        lib = dkim_init(NULL, NULL);
00094        assert(lib != NULL);
00095 
00096 #ifdef TEST_KEEP_FILES
00097        /* set flags */
00098        flags = (DKIM_LIBFLAGS_TMPFILES|DKIM_LIBFLAGS_KEEPFILES);
00099        (void) dkim_options(lib, DKIM_OP_SETOPT, DKIM_OPTS_FLAGS, &flags,
00100                            sizeof flags);
00101 #endif /* TEST_KEEP_FILES */
00102 
00103        (void) dkim_options(lib, DKIM_OP_SETOPT, DKIM_OPTS_QUERYMETHOD,
00104                            &qtype, sizeof qtype);
00105        (void) dkim_options(lib, DKIM_OP_SETOPT, DKIM_OPTS_QUERYINFO,
00106                            KEYFILE, strlen(KEYFILE));
00107 
00108        dkim = dkim_verify(lib, JOBID, NULL, &status);
00109        assert(dkim != NULL);
00110 
00111        /* missing h= */
00112        snprintf(hdr, sizeof hdr, "%s: %s", DKIM_SIGNHEADER, SIG1);
00113        status = dkim_header(dkim, hdr, strlen(hdr));
00114        assert(status == DKIM_STAT_SYNTAX);
00115 
00116        /* negative l= */
00117        snprintf(hdr, sizeof hdr, "%s: %s", DKIM_SIGNHEADER, SIG2);
00118        status = dkim_header(dkim, hdr, strlen(hdr));
00119        assert(status == DKIM_STAT_OK);
00120 
00121        /* bogus l= */
00122        snprintf(hdr, sizeof hdr, "%s: %s", DKIM_SIGNHEADER, SIG3);
00123        status = dkim_header(dkim, hdr, strlen(hdr));
00124        assert(status == DKIM_STAT_OK);
00125 
00126        /* bogus q= */
00127        snprintf(hdr, sizeof hdr, "%s: %s", DKIM_SIGNHEADER, SIG4);
00128        status = dkim_header(dkim, hdr, strlen(hdr));
00129        assert(status == DKIM_STAT_OK);
00130 
00131        /* bogus q= option */
00132        snprintf(hdr, sizeof hdr, "%s: %s", DKIM_SIGNHEADER, SIG5);
00133        status = dkim_header(dkim, hdr, strlen(hdr));
00134        assert(status == DKIM_STAT_OK);
00135 
00136        /* missing d= */
00137        snprintf(hdr, sizeof hdr, "%s: %s", DKIM_SIGNHEADER, SIG6);
00138        status = dkim_header(dkim, hdr, strlen(hdr));
00139        assert(status == DKIM_STAT_SYNTAX);
00140 
00141        /* missing s= */
00142        snprintf(hdr, sizeof hdr, "%s: %s", DKIM_SIGNHEADER, SIG7);
00143        status = dkim_header(dkim, hdr, strlen(hdr));
00144        assert(status == DKIM_STAT_SYNTAX);
00145 
00146        /* empty d= */
00147        snprintf(hdr, sizeof hdr, "%s: %s", DKIM_SIGNHEADER, SIG8);
00148        status = dkim_header(dkim, hdr, strlen(hdr));
00149        assert(status == DKIM_STAT_OK);
00150 
00151        /* empty s= */
00152        snprintf(hdr, sizeof hdr, "%s: %s", DKIM_SIGNHEADER, SIG9);
00153        status = dkim_header(dkim, hdr, strlen(hdr));
00154        assert(status == DKIM_STAT_OK);
00155 
00156        /* missing bh= */
00157        snprintf(hdr, sizeof hdr, "%s: %s", DKIM_SIGNHEADER, SIG10);
00158        status = dkim_header(dkim, hdr, strlen(hdr));
00159        assert(status == DKIM_STAT_OK);
00160 
00161        /* empty bh= */
00162        snprintf(hdr, sizeof hdr, "%s: %s", DKIM_SIGNHEADER, SIG11);
00163        status = dkim_header(dkim, hdr, strlen(hdr));
00164        assert(status == DKIM_STAT_OK);
00165 
00166        /* missing a= */
00167        snprintf(hdr, sizeof hdr, "%s: %s", DKIM_SIGNHEADER, SIG12);
00168        status = dkim_header(dkim, hdr, strlen(hdr));
00169        assert(status == DKIM_STAT_SYNTAX);
00170 
00171        /* missing b= */
00172        snprintf(hdr, sizeof hdr, "%s: %s", DKIM_SIGNHEADER, SIG13);
00173        status = dkim_header(dkim, hdr, strlen(hdr));
00174        assert(status == DKIM_STAT_SYNTAX);
00175 
00176        /* empty b= */
00177        snprintf(hdr, sizeof hdr, "%s: %s", DKIM_SIGNHEADER, SIG14);
00178        status = dkim_header(dkim, hdr, strlen(hdr));
00179        assert(status == DKIM_STAT_OK);
00180 
00181        /* corrupt b= */
00182        snprintf(hdr, sizeof hdr, "%s: %s", DKIM_SIGNHEADER, SIG15);
00183        status = dkim_header(dkim, hdr, strlen(hdr));
00184        assert(status == DKIM_STAT_OK);
00185 
00186        /* invalid a= */
00187        snprintf(hdr, sizeof hdr, "%s: %s", DKIM_SIGNHEADER, SIG16);
00188        status = dkim_header(dkim, hdr, strlen(hdr));
00189        assert(status == DKIM_STAT_OK);
00190 
00191        /* trailing tag with no value */
00192        snprintf(hdr, sizeof hdr, "%s: %s", DKIM_SIGNHEADER, SIG17);
00193        status = dkim_header(dkim, hdr, strlen(hdr));
00194        assert(status == DKIM_STAT_SYNTAX);
00195 
00196        /* x= < t= */
00197         (void) time(&now);
00198         len = snprintf(hdr, sizeof hdr, "%s: ", DKIM_SIGNHEADER);
00199         snprintf(hdr + len, sizeof hdr - len, SIG18, (long) (now + 25),
00200                 (long) (now + 10));
00201         status = dkim_header(dkim, hdr, strlen(hdr));
00202         assert(status == DKIM_STAT_OK);
00203 
00204        /* bogus x= */
00205        snprintf(hdr, sizeof hdr, "%s: %s", DKIM_SIGNHEADER, SIG19);
00206        status = dkim_header(dkim, hdr, strlen(hdr));
00207        assert(status == DKIM_STAT_SYNTAX);
00208 
00209        /* control characters */
00210        snprintf(hdr, sizeof hdr, "%s: %s", DKIM_SIGNHEADER, SIG20);
00211        status = dkim_header(dkim, hdr, strlen(hdr));
00212        assert(status == DKIM_STAT_SYNTAX);
00213 
00214        /* missing a= */
00215        snprintf(hdr, sizeof hdr, "%s: %s", DKIM_SIGNHEADER, SIG21);
00216        status = dkim_header(dkim, hdr, strlen(hdr));
00217        assert(status == DKIM_STAT_SYNTAX);
00218 
00219        /* missing c= */
00220        snprintf(hdr, sizeof hdr, "%s: %s", DKIM_SIGNHEADER, SIG22);
00221        status = dkim_header(dkim, hdr, strlen(hdr));
00222        assert(status == DKIM_STAT_OK);
00223 
00224        /* missing v= */
00225        snprintf(hdr, sizeof hdr, "%s: %s", DKIM_SIGNHEADER, SIG23);
00226        status = dkim_header(dkim, hdr, strlen(hdr));
00227        assert(status == DKIM_STAT_SYNTAX);
00228 
00229        status = dkim_header(dkim, HEADER01, strlen(HEADER01));
00230        assert(status == DKIM_STAT_OK);
00231 
00232        status = dkim_header(dkim, HEADER02, strlen(HEADER02));
00233        assert(status == DKIM_STAT_OK);
00234 
00235        status = dkim_header(dkim, HEADER03, strlen(HEADER03));
00236        assert(status == DKIM_STAT_OK);
00237 
00238        status = dkim_header(dkim, HEADER04, strlen(HEADER04));
00239        assert(status == DKIM_STAT_OK);
00240 
00241        status = dkim_header(dkim, HEADER05, strlen(HEADER05));
00242        assert(status == DKIM_STAT_OK);
00243 
00244        status = dkim_header(dkim, HEADER06, strlen(HEADER06));
00245        assert(status == DKIM_STAT_OK);
00246 
00247        status = dkim_header(dkim, HEADER07, strlen(HEADER07));
00248        assert(status == DKIM_STAT_OK);
00249 
00250        status = dkim_header(dkim, HEADER08, strlen(HEADER08));
00251        assert(status == DKIM_STAT_OK);
00252 
00253        status = dkim_header(dkim, HEADER09, strlen(HEADER09));
00254        assert(status == DKIM_STAT_OK);
00255 
00256        status = dkim_eoh(dkim);
00257        assert(status == DKIM_STAT_OK);
00258 
00259        status = dkim_getsiglist(dkim, &sigs, &nsigs);
00260        assert(status == DKIM_STAT_OK);
00261        assert(nsigs == 13);
00262 
00263        assert(dkim_sig_geterror(sigs[0]) == DKIM_SIGERROR_INVALID_L);
00264        assert(dkim_sig_geterror(sigs[1]) == DKIM_SIGERROR_INVALID_L);
00265        assert(dkim_sig_geterror(sigs[2]) == DKIM_SIGERROR_INVALID_Q);
00266        assert(dkim_sig_geterror(sigs[3]) == DKIM_SIGERROR_INVALID_QO);
00267        assert(dkim_sig_geterror(sigs[4]) == DKIM_SIGERROR_EMPTY_D);
00268        assert(dkim_sig_geterror(sigs[5]) == DKIM_SIGERROR_EMPTY_S);
00269        assert(dkim_sig_geterror(sigs[6]) == DKIM_SIGERROR_MISSING_BH);
00270        assert(dkim_sig_geterror(sigs[7]) == DKIM_SIGERROR_EMPTY_BH);
00271        assert(dkim_sig_geterror(sigs[8]) == DKIM_SIGERROR_EMPTY_B);
00272        assert(dkim_sig_geterror(sigs[9]) == DKIM_SIGERROR_CORRUPT_B);
00273        assert(dkim_sig_geterror(sigs[10]) == DKIM_SIGERROR_INVALID_A);
00274        assert(dkim_sig_geterror(sigs[11]) == DKIM_SIGERROR_TIMESTAMPS);
00275 
00276        assert(dkim_sig_geterror(sigs[12]) == DKIM_SIGERROR_BADSIG);
00277        status = dkim_sig_getcanons(sigs[12], &hcanon, &bcanon);
00278        assert(status == DKIM_STAT_OK);
00279        assert(hcanon == DKIM_CANON_SIMPLE);
00280        assert(bcanon == DKIM_CANON_SIMPLE);
00281 
00282        status = dkim_free(dkim);
00283        assert(status == DKIM_STAT_OK);
00284 
00285        dkim_close(lib);
00286 
00287        return 0;
00288 }