1 dnl $Id: crypto.m4,v 1.13 2002/09/10 19:55:48 joda Exp $
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 #include <openssl/des.h>
15 #include <openssl/rc4.h>
24 typedef struct md4 MD4_CTX;
25 #define MD4_Init(C) md4_init((C))
26 #define MD4_Update(C, D, L) md4_update((C), (D), (L))
27 #define MD4_Final(D, C) md4_finito((C), (D))
28 typedef struct md5 MD5_CTX;
29 #define MD5_Init(C) md5_init((C))
30 #define MD5_Update(C, D, L) md5_update((C), (D), (L))
31 #define MD5_Final(D, C) md5_finito((C), (D))
32 typedef struct sha SHA_CTX;
33 #define SHA1_Init(C) sha_init((C))
34 #define SHA1_Update(C, D, L) sha_update((C), (D), (L))
35 #define SHA1_Final(D, C) sha_finito((C), (D))
38 m4_define([test_body], [
48 des_cbc_encrypt(0, 0, 0, schedule, 0, 0);
52 AC_DEFUN([KRB_CRYPTO],[
54 AC_WITH_ALL([openssl])
58 AC_MSG_CHECKING([for crypto library])
63 if test "$crypto_lib" = "unknown" -a "$with_krb4" != "no"; then
64 save_CPPFLAGS="$CPPFLAGS"
68 for i in $LIB_krb4; do
70 -L*) cdirs="$cdirs $i";;
71 -l*) clibs="$clibs $i";;
76 for i in $INCLUDE_krb4; do
77 CFLAGS="-DHAVE_OPENSSL $i $save_CFLAGS"
78 AC_TRY_COMPILE(test_headers, test_body,
79 openssl=yes ires="$i"; break)
80 CFLAGS="$i $save_CFLAGS"
81 AC_TRY_COMPILE(test_headers, test_body,
82 openssl=no ires="$i"; break)
83 CFLAGS="-DOLD_HASH_NAMES $i $save_CFLAGS"
84 AC_TRY_COMPILE(test_headers, test_body,
85 openssl=no ires="$i" old_hash=yes; break)
90 LIBS="$i $j $save_LIBS"
91 AC_TRY_LINK(test_headers, test_body,
92 lres="$i $j"; break 2)
97 if test "$ires" -a "$lres"; then
101 AC_MSG_RESULT([same as krb4])
102 LIB_des_a='$(LIB_des)'
103 LIB_des_so='$(LIB_des)'
104 LIB_des_appl='$(LIB_des)'
108 if test "$crypto_lib" = "unknown" -a "$with_openssl" != "no"; then
109 save_CFLAGS="$CFLAGS"
113 if test "$with_openssl_include" != ""; then
114 INCLUDE_des="-I${with_openssl}/include"
116 if test "$with_openssl_lib" != ""; then
117 LIB_des="-L${with_openssl}/lib"
119 CFLAGS="-DHAVE_OPENSSL ${INCLUDE_des} ${CFLAGS}"
120 LIB_des="${LIB_des} -lcrypto"
122 LIB_des_so="$LIB_des"
123 LIB_des_appl="$LIB_des"
124 LIBS="${LIBS} ${LIB_des}"
125 AC_TRY_LINK(test_headers, test_body, [
126 crypto_lib=libcrypto openssl=yes
127 AC_MSG_RESULT([libcrypto])
129 CFLAGS="$save_CFLAGS"
133 if test "$crypto_lib" = "unknown"; then
136 LIB_des='$(top_builddir)/lib/des/libdes.la'
137 LIB_des_a='$(top_builddir)/lib/des/.libs/libdes.a'
138 LIB_des_so='$(top_builddir)/lib/des/.libs/libdes.so'
141 AC_MSG_RESULT([included libdes])
145 if test "$with_krb4" != no -a "$crypto_lib" != krb4; then
146 AC_MSG_ERROR([the crypto library used by krb4 lacks features
147 required by Kerberos 5; to continue, you need to install a newer
148 Kerberos 4 or configure --without-krb4])
151 if test "$openssl" = "yes"; then
152 AC_DEFINE([HAVE_OPENSSL], 1, [define to use openssl's libcrypto])
154 if test "$old_hash" = yes; then
155 AC_DEFINE([HAVE_OLD_HASH_NAMES], 1,
156 [define if you have hash functions like md4_finito()])
158 AM_CONDITIONAL(HAVE_OPENSSL, test "$openssl" = yes)dnl
161 AC_SUBST(INCLUDE_des)
165 AC_SUBST(LIB_des_appl)