3 dnl test for crypto libraries:
4 dnl - libcrypto (from openssl)
5 dnl - libdes (from krb4)
8 m4_define([test_headers], [
9 #undef KRB5 /* makes md4.h et al unhappy */
11 #include <openssl/md4.h>
12 #include <openssl/md5.h>
13 #include <openssl/sha.h>
14 #define OPENSSL_DES_LIBDES_COMPATIBILITY
15 #include <openssl/des.h>
16 #include <openssl/rc4.h>
17 #include <openssl/rand.h>
26 typedef struct md4 MD4_CTX;
27 #define MD4_Init(C) md4_init((C))
28 #define MD4_Update(C, D, L) md4_update((C), (D), (L))
29 #define MD4_Final(D, C) md4_finito((C), (D))
30 typedef struct md5 MD5_CTX;
31 #define MD5_Init(C) md5_init((C))
32 #define MD5_Update(C, D, L) md5_update((C), (D), (L))
33 #define MD5_Final(D, C) md5_finito((C), (D))
34 typedef struct sha SHA_CTX;
35 #define SHA1_Init(C) sha_init((C))
36 #define SHA1_Update(C, D, L) sha_update((C), (D), (L))
37 #define SHA1_Final(D, C) sha_finito((C), (D))
40 m4_define([test_body], [
53 des_cbc_encrypt(0, 0, 0, schedule, 0, 0);
57 AC_DEFUN([KRB_CRYPTO],[
59 AC_WITH_ALL([openssl])
63 AC_MSG_CHECKING([for crypto library])
68 if test "$crypto_lib" = "unknown" -a "$with_krb4" != "no"; then
69 save_CPPFLAGS="$CPPFLAGS"
73 for i in $LIB_krb4; do
75 -L*) cdirs="$cdirs $i";;
76 -l*) clibs="$clibs $i";;
81 for i in $INCLUDE_krb4; do
82 CFLAGS="-DHAVE_OPENSSL $i $save_CFLAGS"
85 LIBS="$j $k $save_LIBS"
86 AC_TRY_LINK(test_headers, test_body,
87 openssl=yes ires="$i" lres="$j $k"; break 3)
90 CFLAGS="$i $save_CFLAGS"
93 LIBS="$j $k $save_LIBS"
94 AC_TRY_LINK(test_headers, test_body,
95 openssl=no ires="$i" lres="$j $k"; break 3)
98 CFLAGS="-DHAVE_OLD_HASH_NAMES $i $save_CFLAGS"
101 LIBS="$j $k $save_LIBS"
102 AC_TRY_LINK(test_headers, test_body,
103 openssl=no ires="$i" lres="$j $k"; break 3)
108 CFLAGS="$save_CFLAGS"
110 if test "$ires" -a "$lres"; then
114 AC_MSG_RESULT([same as krb4])
115 LIB_des_a='$(LIB_des)'
116 LIB_des_so='$(LIB_des)'
117 LIB_des_appl='$(LIB_des)'
121 if test "$crypto_lib" = "unknown" -a "$with_openssl" != "no"; then
122 save_CFLAGS="$CFLAGS"
126 if test "$with_openssl_include" != ""; then
127 INCLUDE_des="-I${with_openssl_include}"
129 if test "$with_openssl_lib" != ""; then
130 LIB_des="-L${with_openssl_lib}"
132 CFLAGS="-DHAVE_OPENSSL ${INCLUDE_des} ${CFLAGS}"
133 saved_LIB_des="$LIB_des"
134 for lres in "" "-lnsl -lsocket"; do
135 LIB_des="${saved_LIB_des} -lcrypto $lres"
137 LIB_des_so="$LIB_des"
138 LIB_des_appl="$LIB_des"
139 LIBS="${LIBS} ${LIB_des}"
140 AC_TRY_LINK(test_headers, test_body, [
141 crypto_lib=libcrypto openssl=yes
142 AC_MSG_RESULT([libcrypto])
144 if test "$crypto_lib" = libcrypto ; then
148 CFLAGS="$save_CFLAGS"
152 if test "$crypto_lib" = "unknown"; then
155 LIB_des='$(top_builddir)/lib/des/libdes.la'
156 LIB_des_a='$(top_builddir)/lib/des/.libs/libdes.a'
157 LIB_des_so='$(top_builddir)/lib/des/.libs/libdes.so'
160 AC_MSG_RESULT([included libdes])
164 if test "$with_krb4" != no -a "$crypto_lib" != krb4; then
165 AC_MSG_ERROR([the crypto library used by krb4 lacks features
166 required by Kerberos 5; to continue, you need to install a newer
167 Kerberos 4 or configure --without-krb4])
170 if test "$openssl" = "yes"; then
171 AC_DEFINE([HAVE_OPENSSL], 1, [define to use openssl's libcrypto])
173 if test "$old_hash" = yes; then
174 AC_DEFINE([HAVE_OLD_HASH_NAMES], 1,
175 [define if you have hash functions like md4_finito()])
177 AM_CONDITIONAL(HAVE_OPENSSL, test "$openssl" = yes)dnl
180 AC_SUBST(INCLUDE_des)
184 AC_SUBST(LIB_des_appl)