]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-dcrypt: Replace #if OPENSSL_VERSION_NUMBER with more explicit checks
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Sat, 25 Feb 2017 19:47:01 +0000 (21:47 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Sat, 25 Feb 2017 20:07:43 +0000 (22:07 +0200)
m4/ssl.m4
src/lib-dcrypt/dcrypt-openssl.c

index bf22f66fd0ab818473f395442e269020ddef715a..35b77ec44e50d581197d5f18f15506cc4977ae54 100644 (file)
--- a/m4/ssl.m4
+++ b/m4/ssl.m4
@@ -126,6 +126,18 @@ AC_DEFUN([DOVECOT_SSL], [
       AC_CHECK_LIB(ssl, ASN1_STRING_get0_data, [
         AC_DEFINE(HAVE_ASN1_STRING_GET0_DATA,, [Build with ASN1_STRING_get0_data() support])
       ],, $SSL_LIBS)
+      AC_CHECK_LIB(ssl, HMAC_CTX_new, [
+        AC_DEFINE(HAVE_HMAC_CTX_NEW,, [Build with HMAC_CTX_new() support])
+      ],, $SSL_LIBS)
+      AC_CHECK_LIB(ssl, EVP_MD_CTX_new, [
+        AC_DEFINE(HAVE_EVP_MD_CTX_NEW,, [Build with EVP_MD_CTX_new() support])
+      ],, $SSL_LIBS)
+      AC_CHECK_LIB(ssl, OBJ_length, [
+        AC_DEFINE(HAVE_OBJ_LENGTH,, [Build with OBJ_length() support])
+      ],, $SSL_LIBS)
+      AC_CHECK_LIB(ssl, EVP_PKEY_get0_RSA, [
+        AC_DEFINE(HAVE_EVP_PKEY_get0,, [Build with EVP_PKEY_get0_*() support])
+      ],, $SSL_LIBS)
       AC_CHECK_LIB(ssl, [EVP_PKEY_CTX_new_id], [have_evp_pkey_ctx_new_id="yes"],, $SSL_LIBS)
       AC_CHECK_LIB(ssl, [EC_KEY_new], [have_ec_key_new="yes"],, $SSL_LIBS)
       if test "$have_evp_pkey_ctx_new_id" = "yes" && test "$have_ec_key_new" = "yes"; then
index fa30d8b5821e3cab62b7b0f0e20e7fc23c72cf6c..893c1b29019124c09250c5ba3f219f042d5771f8 100644 (file)
   2<tab>key algo oid<tab>1<tab>symmetric algo name<tab>salt<tab>hash algo<tab>rounds<tab>E(RSA = i2d_PrivateKey, EC=Private Point)<tab>key id
 **/
 
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#ifndef HAVE_EVP_PKEY_get0
 #define EVP_PKEY_get0_EC_KEY(x) x->pkey.ec
 #define EVP_PKEY_get0_RSA(x) x->pkey.rsa
+#endif
+
+#ifndef HAVE_OBJ_LENGTH
 #define OBJ_length(o) ((o)->length)
 #endif
 
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#ifndef HAVE_EVP_MD_CTX_NEW
 #  define EVP_MD_CTX_new() EVP_MD_CTX_create()
 #  define EVP_MD_CTX_free(ctx) EVP_MD_CTX_destroy(ctx)
 #endif
 
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#ifndef HAVE_HMAC_CTX_NEW
 #  define HMAC_Init_ex(ctx, key, key_len, md, impl) \
        HMAC_Init_ex(&(ctx), key, key_len, md, impl)
 #  define HMAC_Update(ctx, data, len) HMAC_Update(&(ctx), data, len)
@@ -108,7 +111,7 @@ struct dcrypt_context_symmetric {
 struct dcrypt_context_hmac {
        pool_t pool;
        const EVP_MD *md;
-#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+#ifdef HAVE_HMAC_CTX_NEW
        HMAC_CTX *ctx;
 #else
        HMAC_CTX ctx;
@@ -484,7 +487,7 @@ bool dcrypt_openssl_ctx_hmac_init(struct dcrypt_context_hmac *ctx, const char **
 {
        int ec;
        i_assert(ctx->md != NULL);
-#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+#ifdef HAVE_HMAC_CTX_NEW
        ctx->ctx = HMAC_CTX_new();
        if (ctx->ctx == NULL) return dcrypt_openssl_error(error_r);
 #endif