3 dnl test for crypto libraries:
4 dnl - libcrypto (from openssl)
5 dnl - own-built libhcrypto
7 m4_define([test_headers], [
8 #undef KRB5 /* makes md4.h et al unhappy */
10 #ifdef HAVE_SYS_TYPES_H
11 #include <sys/types.h>
13 #include <openssl/evp.h>
14 #include <openssl/bn.h>
15 #include <openssl/md4.h>
16 #include <openssl/md5.h>
17 #include <openssl/sha.h>
18 #include <openssl/des.h>
19 #include <openssl/rc4.h>
20 #include <openssl/aes.h>
21 #include <openssl/rsa.h>
22 #include <openssl/dsa.h>
23 #include <openssl/dh.h>
24 #include <openssl/ec.h>
25 #include <openssl/engine.h>
26 #include <openssl/ui.h>
27 #include <openssl/rand.h>
28 #include <openssl/hmac.h>
29 #include <openssl/pkcs12.h>
31 #include <hcrypto/evp.h>
32 #include <hcrypto/md4.h>
33 #include <hcrypto/md5.h>
34 #include <hcrypto/sha.h>
35 #include <hcrypto/des.h>
36 #include <hcrypto/rc4.h>
37 #include <hcrypto/aes.h>
38 #include <hcrypto/engine.h>
39 #include <hcrypto/hmac.h>
40 #include <hcrypto/pkcs12.h>
43 m4_define([test_body], [
52 EVP_MD_CTX_init(&mdctx);
53 EVP_DigestInit_ex(&mdctx, EVP_sha1(), (ENGINE *)0);
54 EVP_CIPHER_iv_length(((EVP_CIPHER*)0));
55 UI_UTIL_read_pw_string(0,0,0,0);
61 OpenSSL_add_all_algorithms();
63 DES_cbc_encrypt(0, 0, 0, schedule, 0, 0);
66 m4_define([bn_headers], [
68 #include <openssl/bn.h>
70 m4_define([bn_body], [
71 BIGNUM *bn = BN_new();
73 if (BN_is_negative(bn))
75 BN_set_negative(bn, 1);
76 if (!BN_is_negative(bn))
81 AC_DEFUN([KRB_CRYPTO],[
83 AC_WITH_ALL([openssl])
87 AC_MSG_CHECKING([for crypto library])
91 if test "$crypto_lib" = "unknown" -a "$with_openssl" != "no"; then
96 if test "$with_openssl_include" != ""; then
97 INCLUDE_hcrypto="-I${with_openssl_include}"
99 if test "$with_openssl_lib" != ""; then
100 LIB_hcrypto="-L${with_openssl_lib}"
102 CFLAGS="-DHAVE_OPENSSL ${INCLUDE_hcrypto} ${CFLAGS}"
103 saved_LIB_hcrypto="$LIB_hcrypto"
104 for lres in "" "-ldl" "-lnsl -lsocket" "-lnsl -lsocket -ldl"; do
105 LIB_hcrypto="${saved_LIB_hcrypto} -lcrypto $lres"
106 LIB_hcrypto_a="$LIB_hcrypto"
107 LIB_hcrypto_so="$LIB_hcrypto"
108 LIB_hcrypto_appl="$LIB_hcrypto"
109 LIBS="${LIBS} ${LIB_hcrypto}"
110 AC_LINK_IFELSE([AC_LANG_PROGRAM([test_headers],[test_body])], [
111 crypto_lib=libcrypto openssl=yes
112 AC_MSG_RESULT([libcrypto])
113 AC_RUN_IFELSE([AC_LANG_PROGRAM([bn_headers],[bn_body])], [
114 AC_DEFINE([HAVE_BN_IS_NEGATIVE], 1, [define if OpenSSL provides BN_is_negative])
117 if test "$crypto_lib" = libcrypto ; then
121 AC_CHECK_LIB(crypto, RAND_egd, AC_DEFINE(HAVE_RAND_EGD, 1, [Define if the libcrypto has RAND_egd]))
122 CFLAGS="$save_CFLAGS"
126 if test "$crypto_lib" = "unknown"; then
128 DIR_hcrypto='hcrypto'
129 LIB_hcrypto='$(top_builddir)/lib/hcrypto/libhcrypto.la'
130 LIB_hcrypto_a='$(top_builddir)/lib/hcrypto/.libs/libhcrypto.a'
131 LIB_hcrypto_so='$(top_builddir)/lib/hcrypto/.libs/libhcrypto.so'
132 LIB_hcrypto_appl="-lhcrypto"
134 AC_MSG_RESULT([included libhcrypto])
138 if test "$openssl" = "yes"; then
139 AC_DEFINE([HAVE_OPENSSL], 1, [define to use openssl's libcrypto])
141 AM_CONDITIONAL(HAVE_OPENSSL, test "$openssl" = yes)dnl
143 AC_SUBST(DIR_hcrypto)
144 AC_SUBST(INCLUDE_hcrypto)
145 AC_SUBST(LIB_hcrypto)
146 AC_SUBST(LIB_hcrypto_a)
147 AC_SUBST(LIB_hcrypto_so)
148 AC_SUBST(LIB_hcrypto_appl)