DKIM: Remove embedded copy of PolarSSL and use OpenSSL/GnuTLS library.
[exim.git] / src / src / pdkim / pdkim.h
index 4a7498db917a88aeb95546dc1c61d02e20ef851f..c7c7b58377e14c5debf13ac6bf24b0b2625f1a38 100644 (file)
  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#ifdef USE_GNUTLS
+# include <gnutls/gnutls.h>
+# include <gnutls/crypto.h>
+#else
+# include <openssl/sha.h>
+#endif
+
 /* -------------------------------------------------------------------------- */
 /* Length of the preallocated buffer for the "answer" from the dns/txt
    callback function. This should match the maximum RDLENGTH from DNS. */
 /* Some required forward declarations, please ignore */
 typedef struct pdkim_stringlist pdkim_stringlist;
 typedef struct pdkim_str pdkim_str;
-typedef struct sha1_context sha1_context;
-typedef struct sha2_context sha2_context;
-#define HAVE_SHA1_CONTEXT
-#define HAVE_SHA2_CONTEXT
 
 /* -------------------------------------------------------------------------- */
 /* Some concessions towards Redmond */
@@ -225,10 +228,14 @@ typedef struct pdkim_signature {
   /* Properties below this point are used internally only ------------- */
 
   /* Per-signature helper variables ----------------------------------- */
-  sha1_context *sha1_body; /* SHA1 block                                */
-  sha2_context *sha2_body; /* SHA256 block                              */
+#ifdef USE_GNUTLS
+  gnutls_hash_hd_t sha_body; /* Either SHA1 or SHA256 block             */
+#else
+  SHA_CTX      sha1_body;    /* SHA1 block                              */
+  SHA256_CTX   sha2_body;    /* SHA256 block                            */
+#endif
   unsigned long signed_body_bytes; /* How many body bytes we hashed     */
-  pdkim_stringlist *headers; /* Raw headers included in the sig         */
+  pdkim_stringlist *headers;       /* Raw headers included in the sig   */
   /* Signing specific ------------------------------------------------- */
   char *rsa_privkey;     /* Private RSA key                             */
   char *sign_headers;    /* To-be-signed header names                   */
@@ -274,14 +281,14 @@ extern "C" {
 #endif
 
 DLLEXPORT
-pdkim_ctx *pdkim_init_sign    (char *, char *, char *);
+pdkim_ctx *pdkim_init_sign    (char *, char *, char *, int);
 
 DLLEXPORT
 pdkim_ctx *pdkim_init_verify  (int(*)(char *, char *));
 
 DLLEXPORT
 int        pdkim_set_optional (pdkim_ctx *, char *, char *,int, int,
-                               long, int,
+                               long,
                                unsigned long,
                                unsigned long);