1*ebfedea0SLionel Sambucdnl Id 2*ebfedea0SLionel Sambucdnl 3*ebfedea0SLionel Sambucdnl test for crypto libraries: 4*ebfedea0SLionel Sambucdnl - libcrypto (from openssl) 5*ebfedea0SLionel Sambucdnl - own-built libhcrypto 6*ebfedea0SLionel Sambuc 7*ebfedea0SLionel Sambucm4_define([test_headers], [ 8*ebfedea0SLionel Sambuc #undef KRB5 /* makes md4.h et al unhappy */ 9*ebfedea0SLionel Sambuc #ifdef HAVE_OPENSSL 10*ebfedea0SLionel Sambuc #ifdef HAVE_SYS_TYPES_H 11*ebfedea0SLionel Sambuc #include <sys/types.h> 12*ebfedea0SLionel Sambuc #endif 13*ebfedea0SLionel Sambuc #include <openssl/evp.h> 14*ebfedea0SLionel Sambuc #include <openssl/md4.h> 15*ebfedea0SLionel Sambuc #include <openssl/md5.h> 16*ebfedea0SLionel Sambuc #include <openssl/sha.h> 17*ebfedea0SLionel Sambuc #include <openssl/des.h> 18*ebfedea0SLionel Sambuc #include <openssl/rc4.h> 19*ebfedea0SLionel Sambuc #include <openssl/aes.h> 20*ebfedea0SLionel Sambuc #include <openssl/ec.h> 21*ebfedea0SLionel Sambuc #include <openssl/engine.h> 22*ebfedea0SLionel Sambuc #include <openssl/ui.h> 23*ebfedea0SLionel Sambuc #include <openssl/rand.h> 24*ebfedea0SLionel Sambuc #include <openssl/hmac.h> 25*ebfedea0SLionel Sambuc #include <openssl/pkcs12.h> 26*ebfedea0SLionel Sambuc #else 27*ebfedea0SLionel Sambuc #include <hcrypto/evp.h> 28*ebfedea0SLionel Sambuc #include <hcrypto/md4.h> 29*ebfedea0SLionel Sambuc #include <hcrypto/md5.h> 30*ebfedea0SLionel Sambuc #include <hcrypto/sha.h> 31*ebfedea0SLionel Sambuc #include <hcrypto/des.h> 32*ebfedea0SLionel Sambuc #include <hcrypto/rc4.h> 33*ebfedea0SLionel Sambuc #include <hcrypto/aes.h> 34*ebfedea0SLionel Sambuc #include <hcrypto/engine.h> 35*ebfedea0SLionel Sambuc #include <hcrypto/hmac.h> 36*ebfedea0SLionel Sambuc #include <hcrypto/pkcs12.h> 37*ebfedea0SLionel Sambuc #endif 38*ebfedea0SLionel Sambuc ]) 39*ebfedea0SLionel Sambucm4_define([test_body], [ 40*ebfedea0SLionel Sambuc void *schedule = 0; 41*ebfedea0SLionel Sambuc EVP_MD_CTX mdctx; 42*ebfedea0SLionel Sambuc 43*ebfedea0SLionel Sambuc EVP_md4(); 44*ebfedea0SLionel Sambuc EVP_md5(); 45*ebfedea0SLionel Sambuc EVP_sha1(); 46*ebfedea0SLionel Sambuc EVP_sha256(); 47*ebfedea0SLionel Sambuc 48*ebfedea0SLionel Sambuc EVP_MD_CTX_init(&mdctx); 49*ebfedea0SLionel Sambuc EVP_DigestInit_ex(&mdctx, EVP_sha1(), (ENGINE *)0); 50*ebfedea0SLionel Sambuc EVP_CIPHER_iv_length(((EVP_CIPHER*)0)); 51*ebfedea0SLionel Sambuc UI_UTIL_read_pw_string(0,0,0,0); 52*ebfedea0SLionel Sambuc RAND_status(); 53*ebfedea0SLionel Sambuc #ifdef HAVE_OPENSSL 54*ebfedea0SLionel Sambuc EC_KEY_new(); 55*ebfedea0SLionel Sambuc #endif 56*ebfedea0SLionel Sambuc 57*ebfedea0SLionel Sambuc OpenSSL_add_all_algorithms(); 58*ebfedea0SLionel Sambuc AES_encrypt(0,0,0); 59*ebfedea0SLionel Sambuc DES_cbc_encrypt(0, 0, 0, schedule, 0, 0); 60*ebfedea0SLionel Sambuc RC4(0, 0, 0, 0);]) 61*ebfedea0SLionel Sambuc 62*ebfedea0SLionel Sambuc 63*ebfedea0SLionel SambucAC_DEFUN([KRB_CRYPTO],[ 64*ebfedea0SLionel Sambuccrypto_lib=unknown 65*ebfedea0SLionel SambucAC_WITH_ALL([openssl]) 66*ebfedea0SLionel Sambuc 67*ebfedea0SLionel SambucDIR_hcrypto= 68*ebfedea0SLionel Sambuc 69*ebfedea0SLionel SambucAC_MSG_CHECKING([for crypto library]) 70*ebfedea0SLionel Sambuc 71*ebfedea0SLionel Sambucopenssl=no 72*ebfedea0SLionel Sambuc 73*ebfedea0SLionel Sambucif test "$crypto_lib" = "unknown" -a "$with_krb4" != "no"; then 74*ebfedea0SLionel Sambuc save_CPPFLAGS="$CPPFLAGS" 75*ebfedea0SLionel Sambuc save_LIBS="$LIBS" 76*ebfedea0SLionel Sambuc 77*ebfedea0SLionel Sambuc cdirs= clibs= 78*ebfedea0SLionel Sambuc for i in $LIB_krb4; do 79*ebfedea0SLionel Sambuc case "$i" in 80*ebfedea0SLionel Sambuc -L*) cdirs="$cdirs $i";; 81*ebfedea0SLionel Sambuc -l*) clibs="$clibs $i";; 82*ebfedea0SLionel Sambuc esac 83*ebfedea0SLionel Sambuc done 84*ebfedea0SLionel Sambuc 85*ebfedea0SLionel Sambuc ires= 86*ebfedea0SLionel Sambuc for i in $INCLUDE_krb4; do 87*ebfedea0SLionel Sambuc CFLAGS="-DHAVE_OPENSSL $i $save_CFLAGS" 88*ebfedea0SLionel Sambuc for j in $cdirs; do 89*ebfedea0SLionel Sambuc for k in $clibs; do 90*ebfedea0SLionel Sambuc LIBS="$j $k $save_LIBS" 91*ebfedea0SLionel Sambuc AC_LINK_IFELSE([AC_LANG_PROGRAM([test_headers], 92*ebfedea0SLionel Sambuc [test_body])], 93*ebfedea0SLionel Sambuc [openssl=yes ires="$i" lres="$j $k"; break 3]) 94*ebfedea0SLionel Sambuc done 95*ebfedea0SLionel Sambuc done 96*ebfedea0SLionel Sambuc CFLAGS="$i $save_CFLAGS" 97*ebfedea0SLionel Sambuc for j in $cdirs; do 98*ebfedea0SLionel Sambuc for k in $clibs; do 99*ebfedea0SLionel Sambuc LIBS="$j $k $save_LIBS" 100*ebfedea0SLionel Sambuc AC_LINK_IFELSE([AC_LANG_PROGRAM([test_headers],[test_body])], 101*ebfedea0SLionel Sambuc [openssl=no ires="$i" lres="$j $k"; break 3]) 102*ebfedea0SLionel Sambuc done 103*ebfedea0SLionel Sambuc done 104*ebfedea0SLionel Sambuc done 105*ebfedea0SLionel Sambuc 106*ebfedea0SLionel Sambuc CFLAGS="$save_CFLAGS" 107*ebfedea0SLionel Sambuc LIBS="$save_LIBS" 108*ebfedea0SLionel Sambuc if test "$ires" -a "$lres"; then 109*ebfedea0SLionel Sambuc INCLUDE_hcrypto="$ires" 110*ebfedea0SLionel Sambuc LIB_hcrypto="$lres" 111*ebfedea0SLionel Sambuc crypto_lib=krb4 112*ebfedea0SLionel Sambuc AC_MSG_RESULT([same as krb4]) 113*ebfedea0SLionel Sambuc LIB_hcrypto_a='$(LIB_hcrypto)' 114*ebfedea0SLionel Sambuc LIB_hcrypto_so='$(LIB_hcrypto)' 115*ebfedea0SLionel Sambuc LIB_hcrypto_appl='$(LIB_hcrypto)' 116*ebfedea0SLionel Sambuc fi 117*ebfedea0SLionel Sambucfi 118*ebfedea0SLionel Sambuc 119*ebfedea0SLionel Sambucif test "$crypto_lib" = "unknown" -a "$with_openssl" != "no"; then 120*ebfedea0SLionel Sambuc save_CFLAGS="$CFLAGS" 121*ebfedea0SLionel Sambuc save_LIBS="$LIBS" 122*ebfedea0SLionel Sambuc INCLUDE_hcrypto= 123*ebfedea0SLionel Sambuc LIB_hcrypto= 124*ebfedea0SLionel Sambuc if test "$with_openssl_include" != ""; then 125*ebfedea0SLionel Sambuc INCLUDE_hcrypto="-I${with_openssl_include}" 126*ebfedea0SLionel Sambuc fi 127*ebfedea0SLionel Sambuc if test "$with_openssl_lib" != ""; then 128*ebfedea0SLionel Sambuc LIB_hcrypto="-L${with_openssl_lib}" 129*ebfedea0SLionel Sambuc fi 130*ebfedea0SLionel Sambuc CFLAGS="-DHAVE_OPENSSL ${INCLUDE_hcrypto} ${CFLAGS}" 131*ebfedea0SLionel Sambuc saved_LIB_hcrypto="$LIB_hcrypto" 132*ebfedea0SLionel Sambuc for lres in "" "-ldl" "-lnsl -lsocket" "-lnsl -lsocket -ldl"; do 133*ebfedea0SLionel Sambuc LIB_hcrypto="${saved_LIB_hcrypto} -lcrypto $lres" 134*ebfedea0SLionel Sambuc LIB_hcrypto_a="$LIB_hcrypto" 135*ebfedea0SLionel Sambuc LIB_hcrypto_so="$LIB_hcrypto" 136*ebfedea0SLionel Sambuc LIB_hcrypto_appl="$LIB_hcrypto" 137*ebfedea0SLionel Sambuc LIBS="${LIBS} ${LIB_hcrypto}" 138*ebfedea0SLionel Sambuc AC_LINK_IFELSE([AC_LANG_PROGRAM([test_headers],[test_body])], [ 139*ebfedea0SLionel Sambuc crypto_lib=libcrypto openssl=yes 140*ebfedea0SLionel Sambuc AC_MSG_RESULT([libcrypto]) 141*ebfedea0SLionel Sambuc ]) 142*ebfedea0SLionel Sambuc if test "$crypto_lib" = libcrypto ; then 143*ebfedea0SLionel Sambuc break; 144*ebfedea0SLionel Sambuc fi 145*ebfedea0SLionel Sambuc done 146*ebfedea0SLionel Sambuc CFLAGS="$save_CFLAGS" 147*ebfedea0SLionel Sambuc LIBS="$save_LIBS" 148*ebfedea0SLionel Sambucfi 149*ebfedea0SLionel Sambuc 150*ebfedea0SLionel Sambucif test "$crypto_lib" = "unknown"; then 151*ebfedea0SLionel Sambuc 152*ebfedea0SLionel Sambuc DIR_hcrypto='hcrypto' 153*ebfedea0SLionel Sambuc LIB_hcrypto='$(top_builddir)/lib/hcrypto/libhcrypto.la' 154*ebfedea0SLionel Sambuc LIB_hcrypto_a='$(top_builddir)/lib/hcrypto/.libs/libhcrypto.a' 155*ebfedea0SLionel Sambuc LIB_hcrypto_so='$(top_builddir)/lib/hcrypto/.libs/libhcrypto.so' 156*ebfedea0SLionel Sambuc LIB_hcrypto_appl="-lhcrypto" 157*ebfedea0SLionel Sambuc 158*ebfedea0SLionel Sambuc AC_MSG_RESULT([included libhcrypto]) 159*ebfedea0SLionel Sambuc 160*ebfedea0SLionel Sambucfi 161*ebfedea0SLionel Sambuc 162*ebfedea0SLionel Sambucif test "$with_krb4" != no -a "$crypto_lib" != krb4; then 163*ebfedea0SLionel Sambuc AC_MSG_ERROR([the crypto library used by krb4 lacks features 164*ebfedea0SLionel Sambucrequired by Kerberos 5; to continue, you need to install a newer 165*ebfedea0SLionel SambucKerberos 4 or configure --without-krb4]) 166*ebfedea0SLionel Sambucfi 167*ebfedea0SLionel Sambuc 168*ebfedea0SLionel Sambucif test "$openssl" = "yes"; then 169*ebfedea0SLionel Sambuc AC_DEFINE([HAVE_OPENSSL], 1, [define to use openssl's libcrypto]) 170*ebfedea0SLionel Sambucfi 171*ebfedea0SLionel SambucAM_CONDITIONAL(HAVE_OPENSSL, test "$openssl" = yes)dnl 172*ebfedea0SLionel Sambuc 173*ebfedea0SLionel SambucAC_SUBST(DIR_hcrypto) 174*ebfedea0SLionel SambucAC_SUBST(INCLUDE_hcrypto) 175*ebfedea0SLionel SambucAC_SUBST(LIB_hcrypto) 176*ebfedea0SLionel SambucAC_SUBST(LIB_hcrypto_a) 177*ebfedea0SLionel SambucAC_SUBST(LIB_hcrypto_so) 178*ebfedea0SLionel SambucAC_SUBST(LIB_hcrypto_appl) 179*ebfedea0SLionel Sambuc]) 180