1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
54
  
55
  
56
  
57
  
58
  
59
  
60
  
61
  
62
  
63
  
64
  
65
  
66
  
67
  
68
  
69
  
70
  
71
  
72
  
73
  
74
  
75
  
76
  
77
  
78
  
79
  
80
  
81
  
82
  
83
  
84
  
85
  
86
  
87
  
88
  
89
  
90
  
91
  
92
  
93
  
94
  
95
  
96
  
97
  
98
  
99
  
100
  
101
  
102
  
103
  
104
  
105
  
106
  
107
  
108
  
109
  
110
  
111
  
112
  
113
  
114
  
115
  
116
  
117
  
118
  
119
  
120
  
121
  
122
  
123
  
AC_INIT(nettle.cmod) 
AC_CONFIG_HEADER(nettle_config.h) 
 
AC_SET_MAKE 
 
AC_MODULE_INIT() 
 
if test "$with_nettle" = "no"; then 
  PIKE_FEATURE_WITHOUT(Nettle) 
else 
  AC_CHECK_LIB(gmp, mpz_init) 
  AC_CHECK_LIB(gmp, __mpz_init) 
  AC_CHECK_LIB(gmp, __gmpz_init) 
  AC_MSG_CHECKING(CryptAcquireContext in -ladvapi32) 
  AC_CACHE_VAL(pike_cv_nettle_advapi32_CryptAcquireContext, 
  [ 
    OLDLIBS="$LIBS" 
    LIBS="-ladvapi32 $LIBS" 
    AC_TRY_LINK([#ifndef _WIN32_WINNT 
#define _WIN32_WINNT 0x0400 
#endif 
#include <windows.h> 
#include <wincrypt.h> 
    ],[CryptAcquireContext(0,0,0,0,0);], 
      [pike_cv_nettle_advapi32_CryptAcquireContext=yes], 
      [pike_cv_nettle_advapi32_CryptAcquireContext=no]) 
    LIBS="$OLDLIBS" 
  ]) 
  AC_MSG_RESULT($pike_cv_nettle_advapi32_CryptAcquireContext) 
  if test x"$pike_cv_nettle_advapi32_CryptAcquireContext" = xyes; then 
    LIBS="-ladvapi32 $LIBS" 
  fi 
  AC_CHECK_LIB(nettle, nettle_md5_init) 
  AC_CHECK_LIB(nettle, md5_init) 
  AC_CHECK_LIB(hogweed, nettle_dsa_generate_keypair) 
 
  AC_SUBST(IDEA_OBJ) 
 
  if test "x$ac_cv_lib_nettle_nettle_md5_init" = "xyes" -o \ 
          "x$ac_cv_lib_nettle_md5_init" = "xyes"; then 
    PIKE_FEATURE_OK(Nettle) 
 
    # md4 is available in later versions of nettle 
    # camellia is available in Nettle 2.1 and later. 
    AC_CHECK_HEADERS(nettle/camellia.h nettle/md4.h nettle/sha3.h \ 
                     nettle/arctwo.h nettle/ripemd160.h nettle/gosthash94.h \ 
                     nettle/ctr.h nettle/gcm.h nettle/ecdsa.h) 
    AC_CHECK_FUNCS(nettle_md4_init) 
 
    AC_MSG_CHECKING([for idea.c]) 
    # Have the patent-encumbered idea files been purged? 
    if test -f "$srcdir/idea.c" ; then 
      AC_MSG_RESULT([found]) 
      AC_DEFINE([WITH_IDEA], 1, [idea.c available]) 
      IDEA_OBJ=idea.o 
    else 
      AC_MSG_RESULT([no]) 
      IDEA_OBJ="" 
    fi 
 
    # These might have been purged from the Nettle lib to avoid GPL 
    # contamination. 
    AC_CHECK_FUNCS(nettle_blowfish_decrypt nettle_serpent_decrypt) 
 
    # This is the recomended interface in Nettle 2.0. 
    AC_CHECK_FUNCS(nettle_yarrow256_slow_reseed) 
 
    # This wasn't present in old Nettles. 
    AC_CHECK_FUNCS(nettle_salsa20_crypt nettle_sha224_init) 
 
    AC_MSG_CHECKING([for struct yarrow256_ctx.seed_file]) 
    AC_CACHE_VAL(pike_cv_nettle_struct_yarrow256_ctx_seed_file, [ 
      pike_cv_nettle_struct_yarrow256_ctx_seed_file=no 
      AC_TRY_COMPILE([ 
#include <nettle/yarrow.h> 
      ], [ 
  struct yarrow256_ctx ctx; 
  return !sizeof(ctx.seed_file); 
      ], [ 
        pike_cv_nettle_struct_yarrow256_ctx_seed_file=yes 
      ]) 
    ]) 
    AC_MSG_RESULT($pike_cv_nettle_struct_yarrow256_ctx_seed_file); 
    if test "x$pike_cv_nettle_struct_yarrow256_ctx_seed_file" = "xyes"; then 
      AC_DEFINE(HAVE_STRUCT_YARROW256_CTX_SEED_FILE) 
    fi 
 
    AC_MSG_CHECKING([whether nettle_crypt_func is a pointer type]) 
    AC_CACHE_VAL(pike_cv_nettle_crypt_func_is_pointer, [ 
      pike_cv_nettle_crypt_func_is_pointer=no 
      AC_TRY_COMPILE([ 
/* Note: Old Nettles had the nettle_crypt_func typedef directly 
 *       in <nettle/nettle-meta.h> while more modern have it in 
 *       <nettle/nettle-types.h>. Since <nettle/nettle-meta.h> 
 *       pulls in <nettle/nettle-types.h> it should be sufficient. 
 */ 
#include <nettle/nettle-meta.h> 
      ], [ 
  nettle_crypt_func foo = (nettle_crypt_func)(void *)0; 
  return (int)foo; 
      ], [ 
        pike_cv_nettle_crypt_func_is_pointer=yes 
      ]) 
    ]) 
    AC_MSG_RESULT($pike_cv_nettle_crypt_func_is_pointer); 
    if test "x$pike_cv_nettle_crypt_func_is_pointer" = "xyes"; then 
      AC_DEFINE(HAVE_NETTLE_CRYPT_FUNC_IS_POINTER) 
    fi 
  else 
    AC_ERROR([Cannot compile --with-nettle without the Nettle library. 
It is highly recommended that you install a working Nettle library on 
your system as that will add features to Pike required by many 
applications. These features include ciphers, hash algorithms and 
random generators. If you know that you do not need cryptographic 
functions, you can re-run configure with the option --without-nettle 
instead. Nettle is available at http://www.lysator.liu.se/~nisse/nettle/. 
    ]) 
    PIKE_FEATURE_NODEP(Nettle) 
  fi 
fi 
 
AC_OUTPUT(Makefile,echo FOO >stamp-h )