[exim-cvs] cvs commit: exim/exim-src/src/pdkim Makefile READ…

Etusivu
Poista viesti
Vastaa
Lähettäjä: Tom Kistner
Päiväys:  
Vastaanottaja: exim-cvs
Aihe: [exim-cvs] cvs commit: exim/exim-src/src/pdkim Makefile README base64.c base64.h bignum.c bignum.h bn_mul.h pdkim.c pdkim.h rsa.c rsa.h sha1.c sha1.h sha2.c sha2.h
tom 2009/04/09 08:49:11 BST

  Modified files:        (Branch: DEVEL_PDKIM)
    exim-src/src/pdkim   Makefile README base64.c base64.h 
                         bignum.c bignum.h bn_mul.h pdkim.c 
                         pdkim.h rsa.c rsa.h sha1.c sha1.h sha2.c 
                         sha2.h 
  Log:
  Update to latest pdkim


  Revision  Changes    Path
  1.1.2.2   +5 -5      exim/exim-src/src/pdkim/Makefile
  1.1.2.2   +12 -2     exim/exim-src/src/pdkim/README
  1.1.2.2   +2 -1      exim/exim-src/src/pdkim/base64.c
  1.1.2.2   +3 -1      exim/exim-src/src/pdkim/base64.h
  1.1.2.2   +2 -1      exim/exim-src/src/pdkim/bignum.c
  1.1.2.2   +3 -1      exim/exim-src/src/pdkim/bignum.h
  1.1.2.2   +3 -1      exim/exim-src/src/pdkim/bn_mul.h
  1.1.2.9   +55 -24    exim/exim-src/src/pdkim/pdkim.c
  1.1.2.9   +68 -16    exim/exim-src/src/pdkim/pdkim.h
  1.1.2.4   +2 -1      exim/exim-src/src/pdkim/rsa.c
  1.1.2.4   +3 -1      exim/exim-src/src/pdkim/rsa.h
  1.1.2.3   +2 -1      exim/exim-src/src/pdkim/sha1.c
  1.1.2.4   +3 -1      exim/exim-src/src/pdkim/sha1.h
  1.1.2.2   +2 -1      exim/exim-src/src/pdkim/sha2.c
  1.1.2.3   +3 -1      exim/exim-src/src/pdkim/sha2.h


  Index: Makefile
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/pdkim/Attic/Makefile,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- Makefile    24 Feb 2009 13:13:47 -0000    1.1.2.1
  +++ Makefile    9 Apr 2009 07:49:10 -0000    1.1.2.2
  @@ -1,4 +1,4 @@
  -# $Cambridge: exim/exim-src/src/pdkim/Makefile,v 1.1.2.1 2009/02/24 13:13:47 tom Exp $
  +# $Cambridge: exim/exim-src/src/pdkim/Makefile,v 1.1.2.2 2009/04/09 07:49:10 tom Exp $


OBJ = base64.o bignum.o pdkim.o rsa.o sha1.o sha2.o

  @@ -13,10 +13,10 @@
            $(FE)$(CC) -c $(CFLAGS) $(INCLUDE) $*.c


   base64.o:           $(HDRS) base64.c
  -bignum.o:           $(HDRS) base64.c
  -pdkim.o:            $(HDRS) base64.c
  -rsa.o:              $(HDRS) base64.c
  -sha1.o:             $(HDRS) base64.c
  -sha2.o:             $(HDRS) base64.c
  +bignum.o:           $(HDRS) bignum.c
  +pdkim.o:            $(HDRS) pdkim.c
  +rsa.o:              $(HDRS) rsa.c
  +sha1.o:             $(HDRS) sha1.c
  +sha2.o:             $(HDRS) sha2.c


# End

  Index: README
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/pdkim/Attic/README,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- README    24 Feb 2009 13:13:47 -0000    1.1.2.1
  +++ README    9 Apr 2009 07:49:11 -0000    1.1.2.2
  @@ -1,3 +1,13 @@
  -# $Cambridge: exim/exim-src/src/pdkim/README,v 1.1.2.1 2009/02/24 13:13:47 tom Exp $
  +$Cambridge: exim/exim-src/src/pdkim/README,v 1.1.2.2 2009/04/09 07:49:11 tom Exp $


  -Preliminary REAME. Please ignore FTTB.
  +PDKIM - a RFC4871 (DKIM) implementation
  +http://duncanthrax.net/pdkim/
  +Copyright (C) 2009      Tom Kistner <tom@???>
  +
  +Includes code from the PolarSSL project.
  +http://polarssl.org
  +Copyright (C) 2009      Paul Bakker <polarssl_maintainer@???>
  +Copyright (C) 2006-2008 Christophe Devine
  +
  +This copy of PDKIM is included with Exim. For a standalone distribution,
  +visit http://duncanthrax.net/pdkim/.


  Index: base64.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/pdkim/Attic/base64.c,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- base64.c    24 Feb 2009 13:13:47 -0000    1.1.2.1
  +++ base64.c    9 Apr 2009 07:49:11 -0000    1.1.2.2
  @@ -1,4 +1,3 @@
  -/* $Cambridge: exim/exim-src/src/pdkim/base64.c,v 1.1.2.1 2009/02/24 13:13:47 tom Exp $ */
   /*
    *  RFC 1521 base64 encoding/decoding
    *
  @@ -21,6 +20,8 @@
    *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
    */


+/* $Cambridge: exim/exim-src/src/pdkim/base64.c,v 1.1.2.2 2009/04/09 07:49:11 tom Exp $ */
+
#include "base64.h"

static const unsigned char base64_enc_map[64] =

  Index: base64.h
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/pdkim/Attic/base64.h,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- base64.h    24 Feb 2009 13:13:47 -0000    1.1.2.1
  +++ base64.h    9 Apr 2009 07:49:11 -0000    1.1.2.2
  @@ -1,4 +1,3 @@
  -/* $Cambridge: exim/exim-src/src/pdkim/base64.h,v 1.1.2.1 2009/02/24 13:13:47 tom Exp $ */
   /**
    * \file base64.h
    *
  @@ -20,6 +19,9 @@
    *  with this program; if not, write to the Free Software Foundation, Inc.,
    *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
    */
  +
  +/* $Cambridge: exim/exim-src/src/pdkim/base64.h,v 1.1.2.2 2009/04/09 07:49:11 tom Exp $ */
  +
   #ifndef POLARSSL_BASE64_H
   #define POLARSSL_BASE64_H



  Index: bignum.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/pdkim/Attic/bignum.c,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- bignum.c    24 Feb 2009 13:13:47 -0000    1.1.2.1
  +++ bignum.c    9 Apr 2009 07:49:11 -0000    1.1.2.2
  @@ -1,4 +1,3 @@
  -/* $Cambridge: exim/exim-src/src/pdkim/bignum.c,v 1.1.2.1 2009/02/24 13:13:47 tom Exp $ */
   /*
    *  Multi-precision integer library
    *
  @@ -28,6 +27,8 @@
    *  http://math.libtomcrypt.com/files/tommath.pdf
    */


+/* $Cambridge: exim/exim-src/src/pdkim/bignum.c,v 1.1.2.2 2009/04/09 07:49:11 tom Exp $ */
+
#include "bignum.h"
#include "bn_mul.h"


  Index: bignum.h
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/pdkim/Attic/bignum.h,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- bignum.h    24 Feb 2009 13:13:47 -0000    1.1.2.1
  +++ bignum.h    9 Apr 2009 07:49:11 -0000    1.1.2.2
  @@ -1,4 +1,3 @@
  -/* $Cambridge: exim/exim-src/src/pdkim/bignum.h,v 1.1.2.1 2009/02/24 13:13:47 tom Exp $ */
   /**
    * \file bignum.h
    *
  @@ -20,6 +19,9 @@
    *  with this program; if not, write to the Free Software Foundation, Inc.,
    *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
    */
  +
  +/* $Cambridge: exim/exim-src/src/pdkim/bignum.h,v 1.1.2.2 2009/04/09 07:49:11 tom Exp $ */
  +
   #ifndef POLARSSL_BIGNUM_H
   #define POLARSSL_BIGNUM_H



  Index: bn_mul.h
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/pdkim/Attic/bn_mul.h,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- bn_mul.h    24 Feb 2009 13:13:47 -0000    1.1.2.1
  +++ bn_mul.h    9 Apr 2009 07:49:11 -0000    1.1.2.2
  @@ -1,4 +1,3 @@
  -/* $Cambridge: exim/exim-src/src/pdkim/bn_mul.h,v 1.1.2.1 2009/02/24 13:13:47 tom Exp $ */
   /**
    * \file bn_mul.h
    *
  @@ -34,6 +33,9 @@
    *         . Alpha                . MIPS32
    *         . C, longlong          . C, generic
    */
  +
  +/* $Cambridge: exim/exim-src/src/pdkim/bn_mul.h,v 1.1.2.2 2009/04/09 07:49:11 tom Exp $ */
  +
   #ifndef POLARSSL_BN_MUL_H
   #define POLARSSL_BN_MUL_H



  Index: pdkim.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/pdkim/Attic/pdkim.c,v
  retrieving revision 1.1.2.8
  retrieving revision 1.1.2.9
  diff -u -r1.1.2.8 -r1.1.2.9
  --- pdkim.c    17 Mar 2009 16:20:13 -0000    1.1.2.8
  +++ pdkim.c    9 Apr 2009 07:49:11 -0000    1.1.2.9
  @@ -1,12 +1,31 @@
  -/* $Cambridge: exim/exim-src/src/pdkim/pdkim.c,v 1.1.2.8 2009/03/17 16:20:13 tom Exp $ */
  -/* pdkim.c */
  +/*
  + *  PDKIM - a RFC4871 (DKIM) implementation
  + *
  + *  Copyright (C) 2009  Tom Kistner <tom@???>
  + *
  + *  http://duncanthrax.net/pdkim/
  + *
  + *  This program is free software; you can redistribute it and/or modify
  + *  it under the terms of the GNU General Public License as published by
  + *  the Free Software Foundation; either version 2 of the License, or
  + *  (at your option) any later version.
  + *
  + *  This program is distributed in the hope that it will be useful,
  + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  + *  GNU General Public License for more details.
  + *
  + *  You should have received a copy of the GNU General Public License along
  + *  with this program; if not, write to the Free Software Foundation, Inc.,
  + *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  + */
  +
  +/* $Cambridge: exim/exim-src/src/pdkim/pdkim.c,v 1.1.2.9 2009/04/09 07:49:11 tom Exp $ */


#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include <strings.h>
#include <ctype.h>
-#include <unistd.h>

#include "pdkim.h"

  @@ -22,7 +41,6 @@
   #define PDKIM_MAX_HEADERS           512
   #define PDKIM_MAX_BODY_LINE_LEN     1024
   #define PDKIM_DNS_TXT_MAX_NAMELEN   1024
  -#define PDKIM_DNS_TXT_MAX_RECLEN    4096
   #define PDKIM_DEFAULT_SIGN_HEADERS "From:Sender:Reply-To:Subject:Date:"\
                                "Message-ID:To:Cc:MIME-Version:Content-Type:"\
                                "Content-Transfer-Encoding:Content-ID:"\
  @@ -32,7 +50,7 @@
                                "List-Id:List-Help:List-Unsubscribe:"\
                                "List-Subscribe:List-Post:List-Owner:List-Archive"


  -
  +/* -------------------------------------------------------------------------- */
   struct pdkim_stringlist {
     char *value;
     void *next;
  @@ -45,8 +63,6 @@
     unsigned int  allocated;
   };


-
-
/* -------------------------------------------------------------------------- */
/* A bunch of list constants */
char *pdkim_querymethods[] = {
@@ -122,7 +138,7 @@

     for (i=0;i<len;i++) {
       int c = p[i];
  -    fprintf(stream,"%02x ",c);
  +    fprintf(stream,"%02x",c);
     }
     if (lf)
       fputc('\n',stream);
  @@ -264,7 +280,7 @@



   /* -------------------------------------------------------------------------- */
  -void pdkim_free_ctx(pdkim_ctx *ctx) {
  +DLLEXPORT void pdkim_free_ctx(pdkim_ctx *ctx) {
     if (ctx) {
       pdkim_free_sig(ctx->sig);
       pdkim_strfree(ctx->cur_header);
  @@ -471,6 +487,7 @@
     sig = malloc(sizeof(pdkim_signature));
     if (sig == NULL) return NULL;
     memset(sig,0,sizeof(pdkim_signature));
  +  sig->bodylength = -1;


     sig->rawsig_no_b_val = malloc(strlen(raw_hdr)+1);
     if (sig->rawsig_no_b_val == NULL) {
  @@ -597,7 +614,7 @@
                 sig->expires = strtoul(cur_val->str,NULL,10);
               break;
               case 'l':
  -              sig->bodylength = strtoul(cur_val->str,NULL,10);
  +              sig->bodylength = strtol(cur_val->str,NULL,10);
               break;
               case 'h':
                 sig->headernames = strdup(cur_val->str);
  @@ -643,6 +660,12 @@
     }


     *q = '\0';
  +  /* Chomp raw header. The final newline must not be added to the signature. */
  +  q--;
  +  while( (q > sig->rawsig_no_b_val) && ((*q == '\r') || (*q == '\n')) ) {
  +    *q = '\0'; q--;
  +  }
  +
     #ifdef PDKIM_DEBUG
     if (ctx->debug_stream) {
       fprintf(ctx->debug_stream,
  @@ -836,7 +859,7 @@
       }


       /* Make sure we don't exceed the to-be-signed body length */
  -    if (sig->bodylength &&
  +    if ((sig->bodylength >= 0) &&
           ((sig->signed_body_bytes+(unsigned long)canon_len) > sig->bodylength))
         canon_len = (sig->bodylength - sig->signed_body_bytes);


@@ -893,7 +916,7 @@

         /* If bodylength limit is set, and we have received less bytes
            than the requested amount, effectively remove the limit tag. */
  -      if (sig->signed_body_bytes < sig->bodylength) sig->bodylength = 0;
  +      if (sig->signed_body_bytes < sig->bodylength) sig->bodylength = -1;
       }
       /* VERIFICATION --------------------------------------------------------- */
       else {
  @@ -992,6 +1015,7 @@


     /* Traverse all signatures */
     while (sig != NULL) {
  +    pdkim_stringlist *list;


       /* SIGNING -------------------------------------------------------------- */
       if (ctx->mode == PDKIM_MODE_SIGN) {
  @@ -1011,8 +1035,8 @@
       }


       /* Add header to the signed headers list */
  -    pdkim_stringlist *list = pdkim_append_stringlist(sig->headers,
  -                                                     ctx->cur_header->str);
  +    list = pdkim_append_stringlist(sig->headers,
  +                                   ctx->cur_header->str);
       if (list == NULL) return PDKIM_ERR_OOM;
       sig->headers = list;


  @@ -1025,13 +1049,14 @@
          (strncasecmp(ctx->cur_header->str,
                       DKIM_SIGNATURE_HEADERNAME,
                       strlen(DKIM_SIGNATURE_HEADERNAME)) == 0) ) {
  +     pdkim_signature *new_sig;
       /* Create and chain new signature block */
       #ifdef PDKIM_DEBUG
       if (ctx->debug_stream)
         fprintf(ctx->debug_stream,
           "PDKIM >> Found sig, trying to parse >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
       #endif
  -    pdkim_signature *new_sig = pdkim_parse_sig_header(ctx, ctx->cur_header->str);
  +    new_sig = pdkim_parse_sig_header(ctx, ctx->cur_header->str);
       if (new_sig != NULL) {
         pdkim_signature *last_sig = ctx->sig;
         if (last_sig == NULL) {
  @@ -1062,7 +1087,7 @@


   /* -------------------------------------------------------------------------- */
   #define HEADER_BUFFER_FRAG_SIZE 256
  -int pdkim_feed (pdkim_ctx *ctx,
  +DLLEXPORT int pdkim_feed (pdkim_ctx *ctx,
                   char *data,
                   int   len) {
     int p;
  @@ -1170,7 +1195,7 @@
           goto BAIL;
         }
       }
  -    if (sig->bodylength > 0) {
  +    if (sig->bodylength >= 0) {
         if (!( pdkim_strcat(hdr,"l=")                             &&
                pdkim_numcat(hdr,sig->bodylength)                  &&
                pdkim_strcat(hdr,";") ) ) {
  @@ -1210,7 +1235,7 @@



   /* -------------------------------------------------------------------------- */
  -int pdkim_feed_finish(pdkim_ctx *ctx, pdkim_signature **return_signatures) {
  +DLLEXPORT int pdkim_feed_finish(pdkim_ctx *ctx, pdkim_signature **return_signatures) {
     pdkim_signature *sig = ctx->sig;
     pdkim_str *headernames = NULL;             /* Collected signed header names */


  @@ -1344,10 +1369,14 @@
       if (sig->algo == PDKIM_ALGO_RSA_SHA1) {
         sha1_update(&(sha1_headers),(unsigned char *)sig_hdr,strlen(sig_hdr));
         sha1_finish(&(sha1_headers),(unsigned char *)headerhash);
  +      fprintf(ctx->debug_stream, "PDKIM [%s] hh computed: ", sig->domain);
  +      pdkim_hexprint(ctx->debug_stream, headerhash, 20, 1);
       }
       else {
         sha2_update(&(sha2_headers),(unsigned char *)sig_hdr,strlen(sig_hdr));
         sha2_finish(&(sha2_headers),(unsigned char *)headerhash);
  +      fprintf(ctx->debug_stream, "PDKIM [%s] hh computed: ", sig->domain);
  +      pdkim_hexprint(ctx->debug_stream, headerhash, 32, 1);
       }


       free(sig_hdr);
  @@ -1508,7 +1537,7 @@



   /* -------------------------------------------------------------------------- */
  -pdkim_ctx *pdkim_init_verify(int input_mode,
  +DLLEXPORT pdkim_ctx *pdkim_init_verify(int input_mode,
                                int(*dns_txt_callback)(char *, char *)
                                ) {
     pdkim_ctx *ctx = malloc(sizeof(pdkim_ctx));
  @@ -1530,11 +1559,12 @@



   /* -------------------------------------------------------------------------- */
  -pdkim_ctx *pdkim_init_sign(int input_mode,
  +DLLEXPORT pdkim_ctx *pdkim_init_sign(int input_mode,
                              char *domain,
                              char *selector,
                              char *rsa_privkey) {
     pdkim_ctx *ctx;
  +  pdkim_signature *sig;


     if (!domain || !selector || !rsa_privkey) return NULL;


  @@ -1548,13 +1578,14 @@
       return NULL;
     }


  -  pdkim_signature *sig = malloc(sizeof(pdkim_signature));
  +  sig = malloc(sizeof(pdkim_signature));
     if (sig == NULL) {
       free(ctx->linebuf);
       free(ctx);
       return NULL;
     }
     memset(sig,0,sizeof(pdkim_signature));
  +  sig->bodylength = -1;


     ctx->mode = PDKIM_MODE_SIGN;
     ctx->input_mode = input_mode;
  @@ -1588,19 +1619,19 @@


   #ifdef PDKIM_DEBUG
   /* -------------------------------------------------------------------------- */
  -void pdkim_set_debug_stream(pdkim_ctx *ctx,
  +DLLEXPORT void pdkim_set_debug_stream(pdkim_ctx *ctx,
                               FILE *debug_stream) {
     ctx->debug_stream = debug_stream;
   };
   #endif


   /* -------------------------------------------------------------------------- */
  -int pdkim_set_optional(pdkim_ctx *ctx,
  +DLLEXPORT int pdkim_set_optional(pdkim_ctx *ctx,
                          char *sign_headers,
                          char *identity,
                          int canon_headers,
                          int canon_body,
  -                       unsigned long bodylength,
  +                       long bodylength,
                          int algo,
                          unsigned long created,
                          unsigned long expires) {


  Index: pdkim.h
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/pdkim/Attic/pdkim.h,v
  retrieving revision 1.1.2.8
  retrieving revision 1.1.2.9
  diff -u -r1.1.2.8 -r1.1.2.9
  --- pdkim.h    17 Mar 2009 21:11:56 -0000    1.1.2.8
  +++ pdkim.h    9 Apr 2009 07:49:11 -0000    1.1.2.9
  @@ -1,5 +1,26 @@
  -/* $Cambridge: exim/exim-src/src/pdkim/pdkim.h,v 1.1.2.8 2009/03/17 21:11:56 tom Exp $ */
  -/* pdkim.h */
  +/*
  + *  PDKIM - a RFC4871 (DKIM) implementation
  + *
  + *  Copyright (C) 2009  Tom Kistner <tom@???>
  + *
  + *  http://duncanthrax.net/pdkim/
  + *
  + *  This program is free software; you can redistribute it and/or modify
  + *  it under the terms of the GNU General Public License as published by
  + *  the Free Software Foundation; either version 2 of the License, or
  + *  (at your option) any later version.
  + *
  + *  This program is distributed in the hope that it will be useful,
  + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  + *  GNU General Public License for more details.
  + *
  + *  You should have received a copy of the GNU General Public License along
  + *  with this program; if not, write to the Free Software Foundation, Inc.,
  + *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  + */
  +
  +/* $Cambridge: exim/exim-src/src/pdkim/pdkim.h,v 1.1.2.9 2009/04/09 07:49:11 tom Exp $ */


/* -------------------------------------------------------------------------- */
/* Debugging. This can also be enabled/disabled at run-time. I recommend to
@@ -7,6 +28,11 @@
#define PDKIM_DEBUG

   /* -------------------------------------------------------------------------- */
  +/* Length of the preallocated buffer for the "answer" from the dns/txt
  +   callback function. */
  +#define PDKIM_DNS_TXT_MAX_RECLEN    4096
  +
  +/* -------------------------------------------------------------------------- */
   /* Function success / error codes */
   #define PDKIM_OK                      0
   #define PDKIM_FAIL                   -1
  @@ -54,6 +80,18 @@
   #define HAVE_SHA2_CONTEXT


   /* -------------------------------------------------------------------------- */
  +/* Some concessions towards Redmond */
  +#ifdef WINDOWS
  +#define snprintf _snprintf
  +#define strcasecmp _stricmp
  +#define strncasecmp _strnicmp
  +#define DLLEXPORT __declspec(dllexport)
  +#else
  +#define DLLEXPORT
  +#endif
  +
  +
  +/* -------------------------------------------------------------------------- */
   /* Public key as (usually) fetched from DNS */
   typedef struct pdkim_pubkey {
     char *version;                  /* v=  */
  @@ -111,8 +149,9 @@
     /* (x=) Timestamp of expiry of signature */
     unsigned long expires;


  -  /* (l=) Amount of hashed body bytes (after canonicalization) */
  -  unsigned long bodylength;
  +  /* (l=) Amount of hashed body bytes (after canonicalization). Default
  +     is -1. Note: a value of 0 means that the body is unsigned! */
  +  long bodylength;


     /* (h=) Colon-separated list of header names that are included in the
        signature */
  @@ -246,26 +285,39 @@



/* -------------------------------------------------------------------------- */
-/* API functions. Please see pdkim-api.txt for documentation / example code. */
+/* API functions. Please see the sample code in sample/test_sign.c and
+ sample/test_verify.c for documentation.
+*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif

  -pdkim_ctx
  -     *pdkim_init_sign         (int, char *, char *, char *);
  +DLLEXPORT
  +pdkim_ctx *pdkim_init_sign    (int, char *, char *, char *);


  -pdkim_ctx
  -     *pdkim_init_verify       (int, int(*)(char *, char *));
  +DLLEXPORT
  +pdkim_ctx *pdkim_init_verify  (int, int(*)(char *, char *));


  -int   pdkim_set_optional      (pdkim_ctx *,
  -                               char *, char *,
  -                               int, int,
  -                               unsigned long, int,
  +DLLEXPORT
  +int        pdkim_set_optional (pdkim_ctx *, char *, char *,int, int,
  +                               long, int,
                                  unsigned long,
                                  unsigned long);


  -int   pdkim_feed              (pdkim_ctx *, char *, int);
  -int   pdkim_feed_finish       (pdkim_ctx *, pdkim_signature **);
  +DLLEXPORT
  +int        ppdkim_feed        (pdkim_ctx *, char *, int);
  +DLLEXPORT
  +int        pdkim_feed_finish  (pdkim_ctx *, pdkim_signature **);


  -void  pdkim_free_ctx          (pdkim_ctx *);
  +DLLEXPORT
  +void       pdkim_free_ctx     (pdkim_ctx *);


   #ifdef PDKIM_DEBUG
  -void  pdkim_set_debug_stream  (pdkim_ctx *, FILE *);
  +DLLEXPORT
  +void       pdkim_set_debug_stream(pdkim_ctx *, FILE *);
  +#endif
  +
  +#ifdef __cplusplus
  +}
   #endif


  Index: rsa.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/pdkim/Attic/rsa.c,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- rsa.c    17 Mar 2009 21:11:56 -0000    1.1.2.3
  +++ rsa.c    9 Apr 2009 07:49:11 -0000    1.1.2.4
  @@ -1,4 +1,3 @@
  -/* $Cambridge: exim/exim-src/src/pdkim/rsa.c,v 1.1.2.3 2009/03/17 21:11:56 tom Exp $ */
   /*
    *  The RSA public-key cryptosystem
    *
  @@ -27,6 +26,8 @@
    *  http://www.cacr.math.uwaterloo.ca/hac/about/chap8.pdf
    */


+/* $Cambridge: exim/exim-src/src/pdkim/rsa.c,v 1.1.2.4 2009/04/09 07:49:11 tom Exp $ */
+
#include "rsa.h"
#include "base64.h"


  Index: rsa.h
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/pdkim/Attic/rsa.h,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- rsa.h    17 Mar 2009 21:11:56 -0000    1.1.2.3
  +++ rsa.h    9 Apr 2009 07:49:11 -0000    1.1.2.4
  @@ -1,4 +1,3 @@
  -/* $Cambridge: exim/exim-src/src/pdkim/rsa.h,v 1.1.2.3 2009/03/17 21:11:56 tom Exp $ */
   /**
    * \file rsa.h
    *
  @@ -20,6 +19,9 @@
    *  with this program; if not, write to the Free Software Foundation, Inc.,
    *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
    */
  +
  +/* $Cambridge: exim/exim-src/src/pdkim/rsa.h,v 1.1.2.4 2009/04/09 07:49:11 tom Exp $ */
  +
   #ifndef POLARSSL_RSA_H
   #define POLARSSL_RSA_H



  Index: sha1.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/pdkim/Attic/sha1.c,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- sha1.c    24 Feb 2009 18:43:59 -0000    1.1.2.2
  +++ sha1.c    9 Apr 2009 07:49:11 -0000    1.1.2.3
  @@ -1,4 +1,3 @@
  -/* $Cambridge: exim/exim-src/src/pdkim/sha1.c,v 1.1.2.2 2009/02/24 18:43:59 tom Exp $ */
   /*
    *  FIPS-180-1 compliant SHA-1 implementation
    *
  @@ -26,6 +25,8 @@
    *  http://www.itl.nist.gov/fipspubs/fip180-1.htm
    */


+/* $Cambridge: exim/exim-src/src/pdkim/sha1.c,v 1.1.2.3 2009/04/09 07:49:11 tom Exp $ */
+
#include "sha1.h"

#include <string.h>

  Index: sha1.h
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/pdkim/Attic/sha1.h,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- sha1.h    17 Mar 2009 14:56:55 -0000    1.1.2.3
  +++ sha1.h    9 Apr 2009 07:49:11 -0000    1.1.2.4
  @@ -1,4 +1,3 @@
  -/* $Cambridge: exim/exim-src/src/pdkim/sha1.h,v 1.1.2.3 2009/03/17 14:56:55 tom Exp $ */
   /**
    * \file sha1.h
    *
  @@ -20,6 +19,9 @@
    *  with this program; if not, write to the Free Software Foundation, Inc.,
    *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
    */
  +
  +/* $Cambridge: exim/exim-src/src/pdkim/sha1.h,v 1.1.2.4 2009/04/09 07:49:11 tom Exp $ */
  +
   #ifndef POLARSSL_SHA1_H
   #define POLARSSL_SHA1_H



  Index: sha2.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/pdkim/Attic/sha2.c,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- sha2.c    24 Feb 2009 13:13:47 -0000    1.1.2.1
  +++ sha2.c    9 Apr 2009 07:49:11 -0000    1.1.2.2
  @@ -1,4 +1,3 @@
  -/* $Cambridge: exim/exim-src/src/pdkim/sha2.c,v 1.1.2.1 2009/02/24 13:13:47 tom Exp $ */
   /*
    *  FIPS-180-2 compliant SHA-256 implementation
    *
  @@ -26,6 +25,8 @@
    *  http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf
    */


+/* $Cambridge: exim/exim-src/src/pdkim/sha2.c,v 1.1.2.2 2009/04/09 07:49:11 tom Exp $ */
+
#include "sha2.h"

#include <string.h>

  Index: sha2.h
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/pdkim/Attic/sha2.h,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- sha2.h    17 Mar 2009 14:56:55 -0000    1.1.2.2
  +++ sha2.h    9 Apr 2009 07:49:11 -0000    1.1.2.3
  @@ -1,4 +1,3 @@
  -/* $Cambridge: exim/exim-src/src/pdkim/sha2.h,v 1.1.2.2 2009/03/17 14:56:55 tom Exp $ */
   /**
    * \file sha2.h
    *
  @@ -20,6 +19,9 @@
    *  with this program; if not, write to the Free Software Foundation, Inc.,
    *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
    */
  +
  +/* $Cambridge: exim/exim-src/src/pdkim/sha2.h,v 1.1.2.3 2009/04/09 07:49:11 tom Exp $ */
  +
   #ifndef POLARSSL_SHA2_H
   #define POLARSSL_SHA2_H