Promote the pdkim variant-implementation sha routines to toplevel
authorJeremy Harris <jgh146exb@wizmail.org>
Thu, 2 Jun 2016 15:18:54 +0000 (16:18 +0100)
committerJeremy Harris <jgh146exb@wizmail.org>
Thu, 2 Jun 2016 22:02:31 +0000 (23:02 +0100)
src/OS/Makefile-Base
src/scripts/MakeLinks
src/src/blob.h [moved from src/src/pdkim/blob.h with 66% similarity]
src/src/hash.c [moved from src/src/pdkim/hash.c with 93% similarity]
src/src/hash.h [moved from src/src/pdkim/hash.h with 62% similarity]
src/src/pdkim/Makefile
src/src/pdkim/crypt_ver.h
src/src/pdkim/pdkim.h
src/src/pdkim/pdkim_hash.h [new file with mode: 0644]
src/src/pdkim/rsa.h
src/src/sha_ver.h [new file with mode: 0644]

index 3965ba36fbca147bfde6d13ce294f89bc3dbc64c..37126869daebb8ec0e9262c26ff205141eb53756 100644 (file)
@@ -331,7 +331,7 @@ OBJ_LOOKUPS = lookups/lf_quote.o lookups/lf_check_file.o lookups/lf_sqlperform.o
 
 OBJ_EXIM = acl.o base64.o child.o crypt16.o daemon.o dbfn.o debug.o deliver.o \
         directory.o dns.o drtables.o enq.o exim.o expand.o filter.o \
-        filtertest.o globals.o dkim.o \
+        filtertest.o globals.o dkim.o hash.o \
         header.o host.o ip.o log.o lss.o match.o moan.o \
         os.o parse.o queue.o \
         rda.o readconf.o receive.o retry.o rewrite.o rfc2047.o \
@@ -599,6 +599,7 @@ environment.o:   $(HDRS) environment.c
 filter.o:        $(HDRS) filter.c
 filtertest.o:    $(HDRS) filtertest.c
 globals.o:       $(HDRS) globals.c
+hash.o:          $(HDRS) sha_ver.h hash.h blob.h hash.c
 header.o:        $(HDRS) header.c
 host.o:          $(HDRS) host.c
 ip.o:            $(HDRS) ip.c
index 68cecf0a963745a355609d00da78e07a3041ce55..7a5649ef8af17e8771d0425170a3100f3f6ea6ac 100755 (executable)
@@ -95,13 +95,14 @@ cd ..
 # but local_scan.c does not, because its location is taken from the build-time
 # configuration. Likewise for the os.c file, which gets build dynamically.
 
-for f in dbfunctions.h dbstuff.h exim.h functions.h globals.h local_scan.h \
-  macros.h mytypes.h osfunctions.h store.h structs.h lookupapi.h \
+for f in blob.h dbfunctions.h dbstuff.h exim.h functions.h globals.h \
+  hash.h local_scan.h \
+  macros.h mytypes.h osfunctions.h store.h structs.h lookupapi.h sha_ver.h \
   \
   acl.c buildconfig.c base64.c child.c crypt16.c daemon.c dbfn.c debug.c deliver.c \
   directory.c dns.c drtables.c dummies.c enq.c exim.c exim_dbmbuild.c \
   exim_dbutil.c exim_lock.c expand.c filter.c filtertest.c globals.c \
-  header.c host.c ip.c log.c lss.c match.c moan.c parse.c perl.c queue.c \
+  hash.c header.c host.c ip.c log.c lss.c match.c moan.c parse.c perl.c queue.c \
   rda.c readconf.c receive.c retry.c rewrite.c rfc2047.c route.c search.c \
   setenv.c environment.c \
   sieve.c smtp_in.c smtp_out.c spool_in.c spool_out.c std-crypto.c store.c \
@@ -118,12 +119,6 @@ do
   ln -s ../src/$f $f
 done
 
-# WITH_OLD_DEMIME
-for f in  demime.c demime.h
-do
-  ln -s ../src/$f $f
-done
-
 # EXPERIMENTAL_*
 for f in  bmi_spam.c bmi_spam.h dcc.c dcc.h dane.c dane-gnu.c dane-openssl.c \
   danessl.h imap_utf7.c spf.c spf.h srs.c srs.h utf8.c
similarity index 66%
rename from src/src/pdkim/blob.h
rename to src/src/blob.h
index e1481c9f48579228227ed6812b8942b0e9eeb11c..a3f1e24d423e78e94377129e3ae1b0048ae40bed 100644 (file)
@@ -1,9 +1,7 @@
 /*
- *  PDKIM - a RFC4871 (DKIM) implementation
+ *  Blob - a general pointer/size item for a memory chunk
  *
  *  Copyright (C) 2016  Exim maintainers
- *
- *  RSA signing/verification interface
  */
 
 #ifndef BLOB_H /* entire file */
similarity index 93%
rename from src/src/pdkim/hash.c
rename to src/src/hash.c
index 0f7d0f6d4f9016ea54e57409aa55b0a7485ca2fe..628df5b4b6d8bb7bef7bd195bc6e2d776f6d0d9a 100644 (file)
@@ -1,21 +1,22 @@
 /*
- *  PDKIM - a RFC4871 (DKIM) implementation
+ *  Exim - an Internet mail transport agent
  *
  *  Copyright (C) 2016  Exim maintainers
  *
  *  Hash interface functions
  */
 
-#include "../exim.h"
-
-#ifndef DISABLE_DKIM   /* entire file */
+#include "exim.h"
 
 #ifndef SUPPORT_TLS
 # error Need SUPPORT_TLS for DKIM
 #endif
 
-#include "crypt_ver.h"
+#include "sha_ver.h"
+#include "hash.h"
+
 
+#ifdef notdef
 #ifdef RSA_OPENSSL
 # include <openssl/rsa.h>
 # include <openssl/ssl.h>
 #  include <gnutls/abstract.h>
 # endif
 #endif
-
-#ifdef SHA_GNUTLS
-# include <gnutls/crypto.h>
 #endif
 
-#include "hash.h"
-
 
 /******************************************************************************/
 #ifdef SHA_OPENSSL
@@ -177,5 +173,4 @@ return h->sha1 ? 20 : 32;
 }
 
 
-#endif /*DISABLE_DKIM*/
 /* End of File */
similarity index 62%
rename from src/src/pdkim/hash.h
rename to src/src/hash.h
index 52a5507c371d32dd4a6e7890c8ebc97ce9782f99..d3531ccd9251ea438eecda202bd244de3fa6f3a4 100644 (file)
@@ -1,43 +1,34 @@
 /*
- *  PDKIM - a RFC4871 (DKIM) implementation
+ *  Exim - an Internet mail transport agent
  *
  *  Copyright (C) 2016  Exim maintainers
  *
  *  Hash interface functions
  */
 
-#include "../exim.h"
+#include "exim.h"
 
-#if !defined(DISABLE_DKIM) && !defined(PDKIM_HASH_H)   /* entire file */
-#define PDKIM_HASH_H
+#if !defined(HASH_H)   /* entire file */
+#define HASH_H
 
-#ifndef SUPPORT_TLS
-# error Need SUPPORT_TLS for DKIM
-#endif
-
-#include "crypt_ver.h"
+#include "sha_ver.h"
 #include "blob.h"
 
-#ifdef RSA_OPENSSL
-# include <openssl/rsa.h>
-# include <openssl/ssl.h>
-# include <openssl/err.h>
-#elif defined(RSA_GNUTLS)
-# include <gnutls/gnutls.h>
-# include <gnutls/x509.h>
-#endif
-
-#ifdef SHA_GNUTLS
+#ifdef SHA_OPENSSL
+# include <openssl/sha.h>
+#elif defined SHA_GNUTLS
 # include <gnutls/crypto.h>
 #elif defined(SHA_GCRYPT)
 # include <gcrypt.h>
 #elif defined(SHA_POLARSSL)
-# include "pdkim.h"
-# include "polarssl/sha1.h"
-# include "polarssl/sha2.h"
+# include "pdkim/pdkim.h"              /*XXX ugly */
+# include "pdkim/polarssl/sha1.h"
+# include "pdkim/polarssl/sha2.h"
 #endif
 
-/* Hash context */
+
+/* Hash context for the exim_sha_* routines */
+
 typedef struct {
   int sha1;
   int hashlen;
@@ -63,17 +54,10 @@ typedef struct {
 
 } hctx;
 
-#if defined(SHA_OPENSSL)
-# include "pdkim.h"
-#elif defined(SHA_GCRYPT)
-# include "pdkim.h"
-#endif
-
-
 extern void     exim_sha_init(hctx *, BOOL);
 extern void     exim_sha_update(hctx *, const uschar *a, int);
 extern void     exim_sha_finish(hctx *, blob *);
 extern int      exim_sha_hashlen(hctx *);
 
-#endif /*DISABLE_DKIM*/
+#endif
 /* End of File */
index c72a9426b975d8a275f1525443ab2dbf68139ea5..61625bd499ad3102704f122ba93da98f26e0b024 100644 (file)
@@ -1,6 +1,6 @@
 # Make file for building the pdkim library.
 
-OBJ = pdkim.o hash.o rsa.o
+OBJ = pdkim.o rsa.o
 
 pdkim.a:         $(OBJ)
                 @$(RM_COMMAND) -f pdkim.a
@@ -12,8 +12,7 @@ pdkim.a:         $(OBJ)
 .c.o:;           @echo "$(CC) $*.c"
                 $(FE)$(CC) -c $(CFLAGS) $(INCLUDE) -I. $*.c
 
-pdkim.o:            $(HDRS) crypt_ver.h hash.h blob.h pdkim.h pdkim.c
-hash.o:             $(HDRS) crypt_ver.h hash.h blob.h pdkim.h hash.c
-rsa.o:              $(HDRS) crypt_ver.h rsa.h blob.h rsa.c
+pdkim.o: $(HDRS) ../sha_ver.h crypt_ver.h ../hash.h ../blob.h pdkim.h pdkim.c
+rsa.o:   $(HDRS) ../sha_ver.h crypt_ver.h rsa.h ../blob.h rsa.c
 
 # End
index 0e1db894f59a89ad214501ea18287573856564f5..cd2171c8233fc71f3d32f94c24f5e203cfbcf67e 100644 (file)
@@ -8,6 +8,7 @@
 /* RSA and SHA routine selection for PDKIM */
 
 #include "../exim.h"
+#include "../sha_ver.h"
 
 
 #ifdef USE_GNUTLS
 #  define RSA_GCRYPT
 # endif
 
-# if GNUTLS_VERSION_NUMBER >= 0x020a00
-#  define SHA_GNUTLS
-# else
-#  define SHA_GCRYPT
-# endif
-
 #else
 # define RSA_OPENSSL
-# define SHA_OPENSSL
 #endif
 
index 58f9c13535d0c8c730bc7edae9b6cd5825caf149..ba984c1d9e51db8183af81c309a0d1e2d9ee1aba 100644 (file)
@@ -23,8 +23,8 @@
 #ifndef PDKIM_H
 #define PDKIM_H
 
-#include "blob.h"
-#include "hash.h"
+#include "../blob.h"
+#include "../hash.h"
 
 /* -------------------------------------------------------------------------- */
 /* Length of the preallocated buffer for the "answer" from the dns/txt
diff --git a/src/src/pdkim/pdkim_hash.h b/src/src/pdkim/pdkim_hash.h
new file mode 100644 (file)
index 0000000..143cd19
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ *  PDKIM - a RFC4871 (DKIM) implementation
+ *
+ *  Copyright (C) 2016  Exim maintainers
+ *
+ *  Hash interface functions
+ */
+
+#include "../exim.h"
+
+#if !defined(HASH_H)   /* entire file */
+#define HASH_H
+
+#ifndef SUPPORT_TLS
+# error Need SUPPORT_TLS for DKIM
+#endif
+
+#include "crypt_ver.h"
+#include "../blob.h"
+#include "../hash.h"
+
+#ifdef RSA_OPENSSL
+# include <openssl/rsa.h>
+# include <openssl/ssl.h>
+# include <openssl/err.h>
+#elif defined(RSA_GNUTLS)
+# include <gnutls/gnutls.h>
+# include <gnutls/x509.h>
+#endif
+
+#if defined(SHA_OPENSSL)
+# include "pdkim.h"
+#elif defined(SHA_GCRYPT)
+# include "pdkim.h"
+#endif
+
+#endif
+/* End of File */
index 32631fdaceea0bd532b21aa043305e8faa56c669..6018eba64950b932d97d220d2c34a20ab2bdb598 100644 (file)
@@ -25,7 +25,7 @@
 #  include <libtasn1.h>
 #endif
 
-#include "blob.h"
+#include "../blob.h"
 
 
 #ifdef RSA_OPENSSL
diff --git a/src/src/sha_ver.h b/src/src/sha_ver.h
new file mode 100644 (file)
index 0000000..630c78d
--- /dev/null
@@ -0,0 +1,32 @@
+/*************************************************
+*     Exim - an Internet mail transport agent    *
+*************************************************/
+
+/* Copyright (c) Jeremy Harris 2016 */
+/* See the file NOTICE for conditions of use and distribution. */
+
+/* SHA routine selection */
+
+#include "exim.h"
+
+#ifdef SUPPORT_TLS
+
+# define EXIM_HAVE_SHA2
+
+# ifdef USE_GNUTLS
+#  include <gnutls/gnutls.h>
+
+#  if GNUTLS_VERSION_NUMBER >= 0x020a00
+#   define SHA_GNUTLS
+#  else
+#   define SHA_GCRYPT
+#  endif
+
+# else
+#  define SHA_OPENSSL
+# endif
+
+#else
+# define SHA_NATIVE
+#endif
+