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 */
9 #ifdef HAVE_HCRYPTO_W_OPENSSL
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);
57 #ifdef HAVE_HCRYPTO_W_OPENSSL
61 OpenSSL_add_all_algorithms();
63 DES_cbc_encrypt(0, 0, 0, schedule, 0, 0);
66 AC_DEFUN([KRB_CRYPTO],[
67 AC_ARG_WITH([hcrypto-default-backend],
68 AS_HELP_STRING([--with-hcrypto-default-backend=cc|pkcs11_hcrypto|ossl|w32crypto|hcrypto],
69 [specify the default hcrypto backend]),
71 CFLAGS="${CFLAGS} -DHCRYPTO_DEF_PROVIDER=${withval}"
73 cc) AC_DEFINE(HCRYPTO_DEF_PROVIDER, [cc], [Define to one of cc, pkcs11, ossl, w32crypto, or hcrypto to set a default hcrypto provider]);;
74 pkcs11_hcrypto) AC_DEFINE(HCRYPTO_DEF_PROVIDER, [pkcs11_hcrypto], [Define to one of cc, pkcs11, ossl, w32crypto, or hcrypto to set a default hcrypto provider]);;
75 ossl) AC_DEFINE(HCRYPTO_DEF_PROVIDER, [ossl], [Define to one of cc, pkcs11, ossl, w32crypto, or hcrypto to set a default hcrypto provider]);;
76 w32crypto) AC_DEFINE(HCRYPTO_DEF_PROVIDER, [w32crypto], [Define to one of cc, pkcs11, ossl, w32crypto, or hcrypto to set a default hcrypto provider]);;
77 hcrypto) AC_DEFINE(HCRYPTO_DEF_PROVIDER, [hcrypto], [Define to one of cc, pkcs11, ossl, w32crypto, or hcrypto to set a default hcrypto provider]);;
78 *) echo "Invalid hcrypto provider name ($withval)"; exit 5;;
82 AC_WITH_ALL([openssl])
84 AC_MSG_CHECKING([for crypto library])
88 if test "$with_openssl" = "yes"; then
91 if test "$with_openssl" != "no"; then
92 INCLUDE_openssl_crypto=
94 if test "$with_openssl_include" != ""; then
95 INCLUDE_openssl_crypto="${with_openssl_include}"
97 INCLUDE_openssl_crypto="${with_openssl}/include"
99 if test "$with_openssl_lib" != ""; then
100 LIB_openssl_crypto="-L${with_openssl_lib}"
102 CFLAGS="-DHAVE_HCRYPTO_W_OPENSSL -I${INCLUDE_openssl_crypto} ${CFLAGS}"
103 # XXX What about rpath? Yeah...
104 AC_CHECK_LIB([crypto], [OPENSSL_init],
105 [LIB_openssl_crypto="${LIB_openssl_crypto} -lcrypto"; openssl=yes], [openssl=no], [])
106 # These cases are just for static linking on older OSes,
108 if test "$openssl" = "no"; then
109 AC_CHECK_LIB([crypto], [OPENSSL_init],
110 [LIB_openssl_crypto="${LIB_openssl_crypto} -lcrypto -ldl"; openssl=yes], [openssl=no], [-ldl])
112 if test "$openssl" = "no"; then
113 AC_CHECK_LIB([crypto], [OPENSSL_init],
114 [LIB_openssl_crypto="${LIB_openssl_crypto} -lcrypto -ldl -lnsl"; openssl=yes], [openssl=no], [-ldl -lnsl])
116 if test "$openssl" = "no"; then
117 AC_CHECK_LIB([crypto], [OPENSSL_init],
118 [LIB_openssl_crypto="${LIB_openssl_crypto} -lcrypto -ldl -lnsl -lsocket"; openssl=yes], [openssl=no], [-ldl -lnsl -lsocket])
122 LIB_hcrypto='$(top_builddir)/lib/hcrypto/libhcrypto.la'
123 LIB_hcrypto_a='$(top_builddir)/lib/hcrypto/.libs/libhcrypto.a'
124 LIB_hcrypto_so='$(top_builddir)/lib/hcrypto/.libs/libhcrypto.so'
125 LIB_hcrypto_appl="-lhcrypto"
127 AC_MSG_RESULT([included libhcrypto])
129 AC_ARG_WITH(pkcs11-module,
130 AS_HELP_STRING([--with-pkcs11-module=path],
131 [use PKCS11 module in path]),
132 [pkcs11_module="$withval"],
135 if test "$pkcs11_module" != ""; then
136 AC_DEFINE_UNQUOTED(PKCS11_MODULE_PATH, "$pkcs11_module", [path to PKCS11 module])
140 if test "$openssl" = "yes"; then
141 AC_DEFINE([HAVE_HCRYPTO_W_OPENSSL], 1, [define to use openssl's libcrypto as the default backend for libhcrypto])
143 AM_CONDITIONAL(HAVE_HCRYPTO_W_OPENSSL, test "$openssl" = yes)dnl
145 AC_SUBST(INCLUDE_openssl_crypto)
146 AC_SUBST(LIB_openssl_crypto)
147 AC_SUBST(LIB_hcrypto)
148 AC_SUBST(LIB_hcrypto_a)
149 AC_SUBST(LIB_hcrypto_so)
150 AC_SUBST(LIB_hcrypto_appl)