1 1.1.1.2 elric dnl Id 2 1.1 elric dnl 3 1.1 elric dnl test for crypto libraries: 4 1.1 elric dnl - libcrypto (from openssl) 5 1.1 elric dnl - own-built libhcrypto 6 1.1 elric 7 1.1 elric m4_define([test_headers], [ 8 1.1 elric #undef KRB5 /* makes md4.h et al unhappy */ 9 1.1.1.3 christos #ifdef HAVE_HCRYPTO_W_OPENSSL 10 1.1 elric #ifdef HAVE_SYS_TYPES_H 11 1.1 elric #include <sys/types.h> 12 1.1 elric #endif 13 1.1 elric #include <openssl/evp.h> 14 1.1.1.3 christos #include <openssl/bn.h> 15 1.1 elric #include <openssl/md4.h> 16 1.1 elric #include <openssl/md5.h> 17 1.1 elric #include <openssl/sha.h> 18 1.1 elric #include <openssl/des.h> 19 1.1 elric #include <openssl/rc4.h> 20 1.1 elric #include <openssl/aes.h> 21 1.1.1.3 christos #include <openssl/rsa.h> 22 1.1.1.3 christos #include <openssl/dsa.h> 23 1.1.1.3 christos #include <openssl/dh.h> 24 1.1 elric #include <openssl/ec.h> 25 1.1 elric #include <openssl/engine.h> 26 1.1 elric #include <openssl/ui.h> 27 1.1 elric #include <openssl/rand.h> 28 1.1 elric #include <openssl/hmac.h> 29 1.1 elric #include <openssl/pkcs12.h> 30 1.1 elric #else 31 1.1 elric #include <hcrypto/evp.h> 32 1.1 elric #include <hcrypto/md4.h> 33 1.1 elric #include <hcrypto/md5.h> 34 1.1 elric #include <hcrypto/sha.h> 35 1.1 elric #include <hcrypto/des.h> 36 1.1 elric #include <hcrypto/rc4.h> 37 1.1 elric #include <hcrypto/aes.h> 38 1.1 elric #include <hcrypto/engine.h> 39 1.1 elric #include <hcrypto/hmac.h> 40 1.1 elric #include <hcrypto/pkcs12.h> 41 1.1 elric #endif 42 1.1 elric ]) 43 1.1 elric m4_define([test_body], [ 44 1.1 elric void *schedule = 0; 45 1.1 elric EVP_MD_CTX mdctx; 46 1.1 elric 47 1.1 elric EVP_md4(); 48 1.1 elric EVP_md5(); 49 1.1 elric EVP_sha1(); 50 1.1 elric EVP_sha256(); 51 1.1 elric 52 1.1 elric EVP_MD_CTX_init(&mdctx); 53 1.1 elric EVP_DigestInit_ex(&mdctx, EVP_sha1(), (ENGINE *)0); 54 1.1 elric EVP_CIPHER_iv_length(((EVP_CIPHER*)0)); 55 1.1 elric UI_UTIL_read_pw_string(0,0,0,0); 56 1.1 elric RAND_status(); 57 1.1.1.3 christos #ifdef HAVE_HCRYPTO_W_OPENSSL 58 1.1 elric EC_KEY_new(); 59 1.1 elric #endif 60 1.1 elric 61 1.1 elric OpenSSL_add_all_algorithms(); 62 1.1 elric AES_encrypt(0,0,0); 63 1.1 elric DES_cbc_encrypt(0, 0, 0, schedule, 0, 0); 64 1.1 elric RC4(0, 0, 0, 0);]) 65 1.1 elric 66 1.1 elric AC_DEFUN([KRB_CRYPTO],[ 67 1.1.1.3 christos AC_ARG_WITH([hcrypto-default-backend], 68 1.1.1.3 christos AS_HELP_STRING([--with-hcrypto-default-backend=cc|pkcs11_hcrypto|ossl|w32crypto|hcrypto], 69 1.1.1.3 christos [specify the default hcrypto backend]), 70 1.1.1.3 christos [ 71 1.1.1.3 christos CFLAGS="${CFLAGS} -DHCRYPTO_DEF_PROVIDER=${withval}" 72 1.1.1.3 christos case "$withval" in 73 1.1.1.3 christos cc) AC_DEFINE(HCRYPTO_DEF_PROVIDER, [cc], [Define to one of cc, pkcs11, ossl, w32crypto, or hcrypto to set a default hcrypto provider]);; 74 1.1.1.3 christos 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 1.1.1.3 christos ossl) AC_DEFINE(HCRYPTO_DEF_PROVIDER, [ossl], [Define to one of cc, pkcs11, ossl, w32crypto, or hcrypto to set a default hcrypto provider]);; 76 1.1.1.3 christos w32crypto) AC_DEFINE(HCRYPTO_DEF_PROVIDER, [w32crypto], [Define to one of cc, pkcs11, ossl, w32crypto, or hcrypto to set a default hcrypto provider]);; 77 1.1.1.3 christos hcrypto) AC_DEFINE(HCRYPTO_DEF_PROVIDER, [hcrypto], [Define to one of cc, pkcs11, ossl, w32crypto, or hcrypto to set a default hcrypto provider]);; 78 1.1.1.3 christos *) echo "Invalid hcrypto provider name ($withval)"; exit 5;; 79 1.1.1.3 christos esac 80 1.1.1.3 christos ], 81 1.1.1.3 christos []) 82 1.1.1.3 christos AC_ARG_WITH([hcrypto-fallback], 83 1.1.1.3 christos AS_HELP_STRING([--without-hcrypto-fallback], 84 1.1.1.3 christos [disable fallback on hcrypto for unavailable algorithms]), 85 1.1.1.3 christos [AC_DEFINE([HCRYPTO_FALLBACK],0,[Set to 1 to allow fallback to hcrypto for unavailable algorithms])], 86 1.1.1.3 christos [AC_DEFINE([HCRYPTO_FALLBACK],1,[Set to 1 to allow fallback to hcrypto for unavailable algorithms])]) 87 1.1 elric AC_WITH_ALL([openssl]) 88 1.1 elric 89 1.1 elric AC_MSG_CHECKING([for crypto library]) 90 1.1 elric 91 1.1 elric openssl=no 92 1.1 elric 93 1.1.1.3 christos if test "$with_openssl" = "yes"; then 94 1.1.1.3 christos with_openssl=/usr 95 1.1 elric fi 96 1.1.1.3 christos if test "$with_openssl" != "no"; then 97 1.1.1.3 christos saved_CFLAGS="${CFLAGS}" 98 1.1.1.3 christos saved_LDFLAGS="${LDFLAGS}" 99 1.1.1.3 christos INCLUDE_openssl_crypto= 100 1.1.1.3 christos LIB_openssl_crypto= 101 1.1 elric if test "$with_openssl_include" != ""; then 102 1.1.1.3 christos INCLUDE_openssl_crypto="-I${with_openssl_include}" 103 1.1.1.3 christos else 104 1.1.1.3 christos INCLUDE_openssl_crypto="-I${with_openssl}/include" 105 1.1 elric fi 106 1.1 elric if test "$with_openssl_lib" != ""; then 107 1.1.1.3 christos LIB_openssl_crypto="-L${with_openssl_lib}" 108 1.1.1.3 christos elif test "${with_openssl}" != "/usr" -a -d "${with_openssl}/lib"; then 109 1.1.1.3 christos LIB_openssl_crypto="-L${with_openssl}/lib" 110 1.1 elric fi 111 1.1.1.3 christos CFLAGS="-DHAVE_HCRYPTO_W_OPENSSL ${INCLUDE_openssl_crypto} ${CFLAGS}" 112 1.1.1.3 christos LDFLAGS="${LIB_openssl_crypto} ${LDFLAGS}" 113 1.1.1.3 christos AC_CHECK_LIB([crypto], [OPENSSL_init], 114 1.1.1.3 christos [LIB_openssl_crypto="${LIB_openssl_crypto} -lcrypto"; openssl=yes], [openssl=no], []) 115 1.1.1.3 christos # These cases are just for static linking on older OSes, 116 1.1.1.3 christos # presumably. 117 1.1.1.3 christos if test "$openssl" = "no"; then 118 1.1.1.3 christos AC_CHECK_LIB([crypto], [OPENSSL_init], 119 1.1.1.3 christos [LIB_openssl_crypto="${LIB_openssl_crypto} -lcrypto -ldl"; openssl=yes], [openssl=no], [-ldl]) 120 1.1.1.3 christos fi 121 1.1.1.3 christos if test "$openssl" = "no"; then 122 1.1.1.3 christos AC_CHECK_LIB([crypto], [OPENSSL_init], 123 1.1.1.3 christos [LIB_openssl_crypto="${LIB_openssl_crypto} -lcrypto -ldl -lnsl"; openssl=yes], [openssl=no], [-ldl -lnsl]) 124 1.1.1.3 christos fi 125 1.1.1.3 christos if test "$openssl" = "no"; then 126 1.1.1.3 christos AC_CHECK_LIB([crypto], [OPENSSL_init], 127 1.1.1.3 christos [LIB_openssl_crypto="${LIB_openssl_crypto} -lcrypto -ldl -lnsl -lsocket"; openssl=yes], [openssl=no], [-ldl -lnsl -lsocket]) 128 1.1.1.3 christos fi 129 1.1.1.3 christos if test "$openssl" = "no"; then 130 1.1.1.3 christos INCLUDE_openssl_crypto= 131 1.1.1.3 christos LIB_openssl_crypto= 132 1.1.1.3 christos fi 133 1.1.1.3 christos CFLAGS="${saved_CFLAGS}" 134 1.1.1.3 christos LDFLAGS="${saved_LDFLAGS}" 135 1.1 elric fi 136 1.1 elric 137 1.1.1.3 christos LIB_hcrypto='$(top_builddir)/lib/hcrypto/libhcrypto.la' 138 1.1.1.3 christos LIB_hcrypto_a='$(top_builddir)/lib/hcrypto/.libs/libhcrypto.a' 139 1.1.1.3 christos LIB_hcrypto_so='$(top_builddir)/lib/hcrypto/.libs/libhcrypto.so' 140 1.1.1.3 christos LIB_hcrypto_appl="-lhcrypto" 141 1.1.1.3 christos 142 1.1.1.3 christos AC_MSG_RESULT([included libhcrypto]) 143 1.1.1.3 christos 144 1.1.1.3 christos AC_ARG_WITH(pkcs11-module, 145 1.1.1.3 christos AS_HELP_STRING([--with-pkcs11-module=path], 146 1.1.1.3 christos [use PKCS11 module in path]), 147 1.1.1.3 christos [pkcs11_module="$withval"], 148 1.1.1.3 christos []) 149 1.1.1.3 christos 150 1.1.1.3 christos if test "$pkcs11_module" != ""; then 151 1.1.1.3 christos AC_DEFINE_UNQUOTED(PKCS11_MODULE_PATH, "$pkcs11_module", [path to PKCS11 module]) 152 1.1.1.3 christos openssl=no 153 1.1 elric fi 154 1.1 elric 155 1.1 elric if test "$openssl" = "yes"; then 156 1.1.1.3 christos AC_DEFINE([HAVE_HCRYPTO_W_OPENSSL], 1, [define to use openssl's libcrypto as the default backend for libhcrypto]) 157 1.1 elric fi 158 1.1.1.3 christos AM_CONDITIONAL(HAVE_HCRYPTO_W_OPENSSL, test "$openssl" = yes)dnl 159 1.1 elric 160 1.1.1.3 christos AC_SUBST(INCLUDE_openssl_crypto) 161 1.1.1.3 christos AC_SUBST(LIB_openssl_crypto) 162 1.1 elric AC_SUBST(LIB_hcrypto) 163 1.1 elric AC_SUBST(LIB_hcrypto_a) 164 1.1 elric AC_SUBST(LIB_hcrypto_so) 165 1.1 elric AC_SUBST(LIB_hcrypto_appl) 166 1.1 elric ]) 167