]> git.netwichtig.de Git - user/henk/code/exim.git/blobdiff - src/src/pdkim/signing.c
Fix ldap lookups for zero-length attribute value. Bug 2251
[user/henk/code/exim.git] / src / src / pdkim / signing.c
index f73fa9cc8f00631f0cd158abd6a854877afd7ffb..b182c9a209c0d730869cbb69ebc10fcc65864c9d 100644 (file)
@@ -1,22 +1,37 @@
 /*
  *  PDKIM - a RFC4871 (DKIM) implementation
  *
- *  Copyright (C) 2017  Exim maintainers
+ *  Copyright (C) 1995 - 2018  Exim maintainers
  *
  *  signing/verification interface
  */
 
 #include "../exim.h"
+#include "crypt_ver.h"
+#include "signing.h"
+
+
+#ifdef MACRO_PREDEF
+# include "../macro_predef.h"
 
-#ifndef DISABLE_DKIM   /* entire file */
+void
+features_crypto(void)
+{
+# ifdef SIGN_HAVE_ED25519
+  builtin_macro_create(US"_CRYPTO_SIGN_ED25519");
+# endif
+# ifdef EXIM_HAVE_SHA3
+  builtin_macro_create(US"_CRYPTO_HASH_SHA3");
+# endif
+}
+#else
+
+#ifndef DISABLE_DKIM   /* rest of file */
 
 #ifndef SUPPORT_TLS
 # error Need SUPPORT_TLS for DKIM
 #endif
 
-#include "crypt_ver.h"
-#include "signing.h"
-
 
 /******************************************************************************/
 #ifdef SIGN_GNUTLS
@@ -71,7 +86,7 @@ return string_cat(g, s);
 Return: NULL for success, or an error string */
 
 const uschar *
-exim_dkim_signing_init(uschar * privkey_pem, es_ctx * sign_ctx)
+exim_dkim_signing_init(const uschar * privkey_pem, es_ctx * sign_ctx)
 {
 gnutls_datum_t k = { .data = privkey_pem, .size = Ustrlen(privkey_pem) };
 gnutls_x509_privkey_t x509_key;
@@ -330,7 +345,7 @@ Only handles RSA keys.
 Return: NULL for success, or an error string */
 
 const uschar *
-exim_dkim_signing_init(uschar * privkey_pem, es_ctx * sign_ctx)
+exim_dkim_signing_init(const uschar * privkey_pem, es_ctx * sign_ctx)
 {
 uschar * s1, * s2;
 blob der;
@@ -386,7 +401,7 @@ Useful cmds:
 (not good for ed25519)
 
  */
+
 if (  !(s1 = Ustrstr(CS privkey_pem, "-----BEGIN RSA PRIVATE KEY-----"))
    || !(s2 = Ustrstr(CS (s1+=31),    "-----END RSA PRIVATE KEY-----" ))
    )
@@ -679,7 +694,7 @@ ERR_load_crypto_strings();
 }
 
 
-/* accumulate data (was gnutls-onl but now needed for OpenSSL non-EC too
+/* accumulate data (was gnutls-only but now needed for OpenSSL non-EC too
 because now using hash-and-sign interface) */
 gstring *
 exim_dkim_data_append(gstring * g, uschar * s)
@@ -692,7 +707,7 @@ return string_cat(g, s);
 Return: NULL for success, or an error string */
 
 const uschar *
-exim_dkim_signing_init(uschar * privkey_pem, es_ctx * sign_ctx)
+exim_dkim_signing_init(const uschar * privkey_pem, es_ctx * sign_ctx)
 {
 BIO * bp = BIO_new_mem_buf(privkey_pem, -1);
 
@@ -737,10 +752,10 @@ if(  (ctx = EVP_MD_CTX_create())
 
 /* Initialise the DigestSign operation */
   && EVP_DigestSignInit(ctx, NULL, md, NULL, sign_ctx->key) > 0
+
  /* Call update with the message */
    && EVP_DigestSignUpdate(ctx, data->data, data->len) > 0
+
  /* Finalise the DigestSign operation */
  /* First call EVP_DigestSignFinal with a NULL sig parameter to obtain the length of the
   * signature. Length is returned in slen */
@@ -884,4 +899,5 @@ switch (hash)
 /******************************************************************************/
 
 #endif /*DISABLE_DKIM*/
+#endif /*MACRO_PREDEF*/
 /* End of File */