You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by yl...@apache.org on 2023/03/18 16:33:08 UTC

svn commit: r1908503 - in /apr/apr/trunk: build/crypto.m4 crypto/apr_crypto_openssl.c

Author: ylavic
Date: Sat Mar 18 16:33:08 2023
New Revision: 1908503

URL: http://svn.apache.org/viewvc?rev=1908503&view=rev
Log:
crypto_openssl: Fix configure/detection of OPENSSL_init_crypto()

Modified:
    apr/apr/trunk/build/crypto.m4
    apr/apr/trunk/crypto/apr_crypto_openssl.c

Modified: apr/apr/trunk/build/crypto.m4
URL: http://svn.apache.org/viewvc/apr/apr/trunk/build/crypto.m4?rev=1908503&r1=1908502&r2=1908503&view=diff
==============================================================================
--- apr/apr/trunk/build/crypto.m4 (original)
+++ apr/apr/trunk/build/crypto.m4 Sat Mar 18 16:33:08 2023
@@ -54,11 +54,11 @@ AC_DEFUN([APU_CHECK_CRYPTO], [
             crypto_library_enabled=1
           fi
         done
-	if test "$crypto_library_enabled" = "1"; then
+        if test "$crypto_library_enabled" = "1"; then
           AC_MSG_NOTICE([Crypto was requested but no crypto library was found; autodetecting possible libraries])
         else
           AC_ERROR([Crypto was requested but all possible crypto libraries were disabled.])
-	fi
+        fi
       fi
 
       APU_CHECK_CRYPTO_OPENSSL
@@ -97,15 +97,14 @@ AC_DEFUN([APU_CHECK_CRYPTO_OPENSSL], [
     if test "$withval" = "yes"; then
       AC_CHECK_HEADERS(openssl/x509.h, [openssl_have_headers=1])
       AC_CHECK_LIB(crypto, EVP_CIPHER_CTX_new, openssl_have_libs=1)
-      if test "$openssl_have_headers" != "0" && test "$openssl_have_libs" != "0"; then
+      if test "$openssl_have_headers" = "1" && test "$openssl_have_libs" = "1"; then
         apu_have_openssl=1
       fi
     elif test "$withval" = "no"; then
       apu_have_openssl=0
     else
-
       openssl_CPPFLAGS="-I$withval/include"
-      openssl_LDFLAGS="-L$withval/lib "
+      openssl_LDFLAGS="-L$withval/lib -L$withval/lib64"
 
       APR_ADDTO(CPPFLAGS, [$openssl_CPPFLAGS])
       APR_ADDTO(LDFLAGS, [$openssl_LDFLAGS])
@@ -113,15 +112,13 @@ AC_DEFUN([APU_CHECK_CRYPTO_OPENSSL], [
       AC_MSG_NOTICE(checking for openssl in $withval)
       AC_CHECK_HEADERS(openssl/x509.h, [openssl_have_headers=1])
       AC_CHECK_LIB(crypto, EVP_CIPHER_CTX_new, openssl_have_libs=1)
-      if test "$openssl_have_headers" != "0" && test "$openssl_have_libs" != "0"; then
+      if test "$openssl_have_headers" = "1" && test "$openssl_have_libs" = "1"; then
         apu_have_openssl=1
-        APR_ADDTO(LDFLAGS, [-L$withval/lib])
-        APR_ADDTO(INCLUDES, [-I$withval/include])
       fi
-
-      AC_CHECK_DECLS([EVP_PKEY_CTX_new, OPENSSL_init_crypto], [], [],
-                     [#include <openssl/evp.h>])
-
+    fi
+    if test "$apu_have_openssl" = "1"; then
+        AC_CHECK_LIB(crypto, OPENSSL_init_crypto)
+        AC_CHECK_FUNCS([OPENSSL_init_crypto])
     fi
   ], [
     apu_have_openssl=0
@@ -136,18 +133,12 @@ AC_DEFUN([APU_CHECK_CRYPTO_OPENSSL], [
     apu_have_crypto=1
 
     AC_MSG_CHECKING([for const input buffers in OpenSSL])
-    AC_TRY_COMPILE([#include <openssl/rsa.h>],
-        [ const unsigned char * buf;
-          unsigned char * outbuf;
-          RSA rsa;
-
-                RSA_private_decrypt(1,
-                                                        buf,
-                                                        outbuf,
-                                                        &rsa,
-                                                        RSA_PKCS1_PADDING);
-
-        ],
+    AC_TRY_COMPILE(
+        [#include <openssl/evp.h>],
+        [ EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
+          const unsigned char key[128] = {0}, iv[128] = {0};
+          EVP_EncryptInit_ex(ctx, EVP_aes_128_cbc(), NULL, key, iv);
+          EVP_CIPHER_CTX_free(ctx); ],
         [AC_MSG_RESULT([yes])]
         [AC_DEFINE([CRYPTO_OPENSSL_CONST_BUFFERS], 1, [Define that OpenSSL uses const buffers])],
         [AC_MSG_RESULT([no])])

Modified: apr/apr/trunk/crypto/apr_crypto_openssl.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/crypto/apr_crypto_openssl.c?rev=1908503&r1=1908502&r2=1908503&view=diff
==============================================================================
--- apr/apr/trunk/crypto/apr_crypto_openssl.c (original)
+++ apr/apr/trunk/crypto/apr_crypto_openssl.c Sat Mar 18 16:33:08 2023
@@ -203,7 +203,7 @@ static apr_status_t crypto_error(const a
  */
 static apr_status_t crypto_shutdown(void)
 {
-#if HAVE_DECL_OPENSSL_INIT_CRYPTO
+#if HAVE_OPENSSL_INIT_CRYPTO
     /* Openssl v1.1+ handles all termination automatically. Do
      * nothing in this case.
      */
@@ -232,7 +232,7 @@ static apr_status_t crypto_shutdown_help
 static apr_status_t crypto_init(apr_pool_t *pool, const char *params,
         const apu_err_t **result)
 {
-#if HAVE_DECL_OPENSSL_INIT_CRYPTO
+#if HAVE_OPENSSL_INIT_CRYPTO
     /* Openssl v1.1+ handles all initialisation automatically, apart
      * from hints as to how we want to use the library.
      *



Re: svn commit: r1908503 - in /apr/apr/trunk: build/crypto.m4 crypto/apr_crypto_openssl.c

Posted by Rainer Jung <ra...@kippdata.de>.
Thanks Yann, looks good here.

Am 27.03.23 um 15:43 schrieb Yann Ylavic:
> Hi Rainer;
> 
> On Mon, Mar 27, 2023 at 2:02 PM Rainer Jung <ra...@kippdata.de> wrote:
>>
>> Am 18.03.23 um 17:33 schrieb ylavic@apache.org:
>>>
>>> @@ -113,15 +112,13 @@ AC_DEFUN([APU_CHECK_CRYPTO_OPENSSL], [
>>>          AC_MSG_NOTICE(checking for openssl in $withval)
>>>          AC_CHECK_HEADERS(openssl/x509.h, [openssl_have_headers=1])
>>>          AC_CHECK_LIB(crypto, EVP_CIPHER_CTX_new, openssl_have_libs=1)
>>> -      if test "$openssl_have_headers" != "0" && test "$openssl_have_libs" != "0"; then
>>> +      if test "$openssl_have_headers" = "1" && test "$openssl_have_libs" = "1"; then
>>>            apu_have_openssl=1
>>> -        APR_ADDTO(LDFLAGS, [-L$withval/lib])
>>> -        APR_ADDTO(INCLUDES, [-I$withval/include])
>>   >         fi
>>   > -
>>   > -      AC_CHECK_DECLS([EVP_PKEY_CTX_new, OPENSSL_init_crypto], [], [],
>>   > -                     [#include <openssl/evp.h>])
>>   > -
>>   > +    fi
>>   > +    if test "$apu_have_openssl" = "1"; then
>>   > +        AC_CHECK_LIB(crypto, OPENSSL_init_crypto)
>>   > +        AC_CHECK_FUNCS([OPENSSL_init_crypto])
>>   >       fi
>>
>> Hmmm, for me this dropped "APR_ADDTO(INCLUDES,..." breaks the apr trunk
>> build. The path to the OpenSSL header files gets no longer added to any
>> INCLUDES variable for the build.
> 
> Ah yes, I thought both LDFLAGS and INCLUDES were already set above but
> it is LDFLAGS and CPPFLAGS actually.
> Restored in r1908749.
> 
> Thanks!
> Yann.

Re: svn commit: r1908503 - in /apr/apr/trunk: build/crypto.m4 crypto/apr_crypto_openssl.c

Posted by Yann Ylavic <yl...@gmail.com>.
Hi Rainer;

On Mon, Mar 27, 2023 at 2:02 PM Rainer Jung <ra...@kippdata.de> wrote:
>
> Am 18.03.23 um 17:33 schrieb ylavic@apache.org:
> >
> > @@ -113,15 +112,13 @@ AC_DEFUN([APU_CHECK_CRYPTO_OPENSSL], [
> >         AC_MSG_NOTICE(checking for openssl in $withval)
> >         AC_CHECK_HEADERS(openssl/x509.h, [openssl_have_headers=1])
> >         AC_CHECK_LIB(crypto, EVP_CIPHER_CTX_new, openssl_have_libs=1)
> > -      if test "$openssl_have_headers" != "0" && test "$openssl_have_libs" != "0"; then
> > +      if test "$openssl_have_headers" = "1" && test "$openssl_have_libs" = "1"; then
> >           apu_have_openssl=1
> > -        APR_ADDTO(LDFLAGS, [-L$withval/lib])
> > -        APR_ADDTO(INCLUDES, [-I$withval/include])
>  >         fi
>  > -
>  > -      AC_CHECK_DECLS([EVP_PKEY_CTX_new, OPENSSL_init_crypto], [], [],
>  > -                     [#include <openssl/evp.h>])
>  > -
>  > +    fi
>  > +    if test "$apu_have_openssl" = "1"; then
>  > +        AC_CHECK_LIB(crypto, OPENSSL_init_crypto)
>  > +        AC_CHECK_FUNCS([OPENSSL_init_crypto])
>  >       fi
>
> Hmmm, for me this dropped "APR_ADDTO(INCLUDES,..." breaks the apr trunk
> build. The path to the OpenSSL header files gets no longer added to any
> INCLUDES variable for the build.

Ah yes, I thought both LDFLAGS and INCLUDES were already set above but
it is LDFLAGS and CPPFLAGS actually.
Restored in r1908749.

Thanks!
Yann.

Re: svn commit: r1908503 - in /apr/apr/trunk: build/crypto.m4 crypto/apr_crypto_openssl.c

Posted by Rainer Jung <ra...@kippdata.de>.
Hi Yann,

Am 18.03.23 um 17:33 schrieb ylavic@apache.org:
> Author: ylavic
> Date: Sat Mar 18 16:33:08 2023
> New Revision: 1908503
> 
> URL: http://svn.apache.org/viewvc?rev=1908503&view=rev
> Log:
> crypto_openssl: Fix configure/detection of OPENSSL_init_crypto()
> 
> Modified:
>      apr/apr/trunk/build/crypto.m4
>      apr/apr/trunk/crypto/apr_crypto_openssl.c
> 
> Modified: apr/apr/trunk/build/crypto.m4
> URL: http://svn.apache.org/viewvc/apr/apr/trunk/build/crypto.m4?rev=1908503&r1=1908502&r2=1908503&view=diff
> ==============================================================================
> --- apr/apr/trunk/build/crypto.m4 (original)
> +++ apr/apr/trunk/build/crypto.m4 Sat Mar 18 16:33:08 2023
...

> @@ -113,15 +112,13 @@ AC_DEFUN([APU_CHECK_CRYPTO_OPENSSL], [
>         AC_MSG_NOTICE(checking for openssl in $withval)
>         AC_CHECK_HEADERS(openssl/x509.h, [openssl_have_headers=1])
>         AC_CHECK_LIB(crypto, EVP_CIPHER_CTX_new, openssl_have_libs=1)
> -      if test "$openssl_have_headers" != "0" && test "$openssl_have_libs" != "0"; then
> +      if test "$openssl_have_headers" = "1" && test "$openssl_have_libs" = "1"; then
>           apu_have_openssl=1
> -        APR_ADDTO(LDFLAGS, [-L$withval/lib])
> -        APR_ADDTO(INCLUDES, [-I$withval/include])
 >         fi
 > -
 > -      AC_CHECK_DECLS([EVP_PKEY_CTX_new, OPENSSL_init_crypto], [], [],
 > -                     [#include <openssl/evp.h>])
 > -
 > +    fi
 > +    if test "$apu_have_openssl" = "1"; then
 > +        AC_CHECK_LIB(crypto, OPENSSL_init_crypto)
 > +        AC_CHECK_FUNCS([OPENSSL_init_crypto])
 >       fi

Hmmm, for me this dropped "APR_ADDTO(INCLUDES,..." breaks the apr trunk 
build. The path to the OpenSSL header files gets no longer added to any 
INCLUDES variable for the build.

For 1.7.x and 1.6.x you committed it differently:

-        APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
-        APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include])
+        APR_ADDTO(APRUTIL_INCLUDES, [$openssl_CPPFLAGS])
+        APR_ADDTO(APRUTIL_LDFLAGS, [$openssl_LDFLAGS])

So maybe adding back APR_ADDTO for INCLUDES (and LDFLAGS?) but with the 
new values would be the right thing? Before the change, the addition to 
INCLUDES get copied over to EXTRA_INCLUDES and ends up in 
build/apr_rules.mk.

Best regards,

Rainer