Debian Codegraph @

build/m4/aircrack_ng_crypto.m4

raw
1 dnl Aircrack-ng
2 dnl
3 dnl Copyright (C) 2017,2022 Joseph Benden <[email protected]>
4 dnl
5 dnl Autotool support was written by: Joseph Benden <[email protected]>
6 dnl
7 dnl This program is free software; you can redistribute it and/or modify
8 dnl it under the terms of the GNU General Public License as published by
9 dnl the Free Software Foundation; either version 2 of the License, or
10 dnl (at your option) any later version.
11 dnl
12 dnl This program is distributed in the hope that it will be useful,
13 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
14 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 dnl GNU General Public License for more details.
16 dnl
17 dnl You should have received a copy of the GNU General Public License
18 dnl along with this program; if not, write to the Free Software
19 dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 dnl
21 dnl In addition, as a special exception, the copyright holders give
22 dnl permission to link the code of portions of this program with the
23 dnl OpenSSL library under certain conditions as described in each
24 dnl individual source file, and distribute linked combinations
25 dnl including the two.
26 dnl
27 dnl You must obey the GNU General Public License in all respects
28 dnl for all of the code used other than OpenSSL.
29 dnl
30 dnl If you modify file(s) with this exception, you may extend this
31 dnl exception to your dnl version of the file(s), but you are not obligated
32 dnl to do so.
33 dnl
34 dnl If you dnl do not wish to do so, delete this exception statement from your
35 dnl version.
36 dnl
37 dnl If you delete this exception statement from all source files in the
38 dnl program, then also delete it here.
39
40 AC_DEFUN([AIRCRACK_NG_CRYPTO],[
41
42 AC_ARG_WITH(expensive-tests,
43 [AS_HELP_STRING([--without-expensive-tests],
44 [disable all the CPU-intensive unit-tests.])])
45
46 case "$with_expensive_tests" in
47 yes | y | "")
48 AX_APPEND_FLAG(-DEXPENSIVE_TESTS, [opt_[]_AC_LANG_ABBREV[]flags])
49 ;;
50 esac
51
52 AC_ARG_ENABLE(static-crypto,
53 AS_HELP_STRING([--enable-static-crypto],
54 [Enable statically linked OpenSSL libcrypto.]),
55 [static_crypto=$enableval], [static_crypto=no])
56
57 if test "x$static_crypto" != "xno"; then
58 AC_REQUIRE([AX_EXT_HAVE_STATIC_LIB_DETECT])
59 AX_EXT_HAVE_STATIC_LIB(ZLIB, ${DEFAULT_STATIC_LIB_SEARCH_PATHS}, z libz, compress)
60 AX_EXT_HAVE_STATIC_LIB(OPENSSL, ${DEFAULT_STATIC_LIB_SEARCH_PATHS}, crypto libcrypto, HMAC, -lz -ldl)
61 else
62 AX_CHECK_OPENSSL([OPENSSL_FOUND=yes],[OPENSSL_FOUND=no])
63
64 AX_LIB_GCRYPT
65 fi
66
67 CRYPTO_CFLAGS=
68 CRYPTO_INCLUDES=
69 CRYPTO_LIBS=
70 CRYPTO_LDFLAGS=
71 CRYPTO_TYPE=
72
73 AC_MSG_CHECKING([for OpenSSL or libgcrypt])
74 if test x"$GCRYPT_LIBS" != x; then
75 AC_MSG_RESULT([libgcrypt])
76 CRYPTO_CFLAGS="$GCRYPT_CFLAGS -DUSE_GCRYPT"
77 CRYPTO_INCLUDES=""
78 CRYPTO_LIBS="$GCRYPT_LIBS"
79 CRYPTO_LDFLAGS=""
80 CRYPTO_TYPE=libgcrypt
81 elif test "$OPENSSL_FOUND" = yes; then
82 AC_MSG_RESULT([OpenSSL])
83 CRYPTO_INCLUDES="$OPENSSL_INCLUDES"
84 CRYPTO_LIBS="$OPENSSL_LIBS"
85 CRYPTO_LDFLAGS="$OPENSSL_LDFLAGS"
86 CRYPTO_TYPE=openssl
87
88 AC_CHECK_HEADERS([openssl/cmac.h], [
89 AC_DEFINE([HAVE_OPENSSL_CMAC_H], [1], [Define if you have openssl/cmac.h header present.])
90 HAVE_CMAC=yes
91 ], [HAVE_CMAC=no])
92
93 OPENSSL_WITH_AES=
94 OPENSSL_WITH_ARCFOUR=
95 OPENSSL_WITH_CMAC=
96 OPENSSL_WITH_MD5=
97 OPENSSL_WITH_SHA1=
98 OPENSSL_WITH_SHA256=
99 save_LIBS="$LIBS"
100 save_LDFLAGS="$LDFLAGS"
101 save_CPPFLAGS="$CPPFLAGS"
102 LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS"
103 LIBS="$OPENSSL_LIBS $LIBS"
104 CPPFLAGS="$OPENSSL_INCLUDES $CPPFLAGS -Werror"
105 AC_MSG_CHECKING([whether OpenSSL supports MD5])
106 AC_LINK_IFELSE(
107 [AC_LANG_PROGRAM([#include <openssl/evp.h>], [
108 EVP_md5();
109 ])],
110 [
111 OPENSSL_WITH_MD5=1
112 AC_DEFINE([OPENSSL_WITH_MD5], [1], [Define if your OpenSSL has an MD5 implementation.])
113 AC_MSG_RESULT([yes])
114 ], [
115 AC_MSG_RESULT([no])
116 ])
117 AC_MSG_CHECKING([whether OpenSSL supports AES])
118 AC_LINK_IFELSE(
119 [AC_LANG_PROGRAM([#include <openssl/evp.h>], [EVP_aes_128_cbc()])],
120 [
121 OPENSSL_WITH_AES=1
122 AC_DEFINE([OPENSSL_WITH_AES], [1], [Define if your OpenSSL has an AES_128_cbc implementation.])
123 AC_MSG_RESULT([yes])
124 ], [
125 AC_MSG_RESULT([no])
126 ])
127 AC_MSG_CHECKING([whether OpenSSL supports ARCFOUR])
128 AC_LINK_IFELSE(
129 [AC_LANG_PROGRAM([
130 #include <openssl/rc4.h>
131 #include <string.h>
132 ], [
133 #if OPENSSL_VERSION_NUMBER < 0x30000000L
134 RC4_KEY ctx;
135 memset(&ctx, 0, sizeof(ctx));
136 #else
137 # error "no ARCFOUR here!!!"
138 #endif
139 ])],
140 [
141 OPENSSL_WITH_ARCFOUR=1
142 AC_DEFINE([OPENSSL_WITH_ARCFOUR], [1], [Define if your OpenSSL has an ARC4 implementation.])
143 AC_MSG_RESULT([yes])
144 ], [
145 AC_MSG_RESULT([no])
146 ])
147 if test x"$HAVE_CMAC" = xyes; then
148 AC_MSG_CHECKING([whether OpenSSL supports CMAC])
149 AC_LINK_IFELSE(
150 [AC_LANG_PROGRAM([#include <openssl/cmac.h>], [
151 #if OPENSSL_VERSION_NUMBER >= 0x30000000L
152 # error "No CMAC here!!!"
153 #else
154 CMAC_CTX_new()
155 #endif
156 ])],
157 [
158 OPENSSL_WITH_CMAC=1
159 AC_DEFINE([OPENSSL_WITH_CMAC], [1], [Define if your OpenSSL has a CMAC implementation.])
160 AC_MSG_RESULT([yes])
161 ], [
162 AC_MSG_RESULT([no])
163 ])
164 fi
165 AC_MSG_CHECKING([whether OpenSSL supports SHA-1])
166 AC_LINK_IFELSE(
167 [AC_LANG_PROGRAM([#include <openssl/evp.h>], [
168 EVP_sha1();
169 ])],
170 [
171 OPENSSL_WITH_SHA1=1
172 AC_DEFINE([OPENSSL_WITH_SHA1], [1], [Define if your OpenSSL has an SHA-1 implementation.])
173 AC_MSG_RESULT([yes])
174 ], [
175 AC_MSG_RESULT([no])
176 ])
177 AC_MSG_CHECKING([whether OpenSSL supports SHA-256])
178 AC_LINK_IFELSE(
179 [AC_LANG_PROGRAM([#include <openssl/evp.h>], [
180 EVP_sha256();
181 ])],
182 [
183 OPENSSL_WITH_SHA256=1
184 AC_DEFINE([OPENSSL_WITH_SHA256], [1], [Define if your OpenSSL has an SHA-256 implementation.])
185 AC_MSG_RESULT([yes])
186 ], [
187 AC_MSG_RESULT([no])
188 ])
189 LDFLAGS="$save_LDFLAGS"
190 LIBS="$save_LIBS"
191 CPPFLAGS="$save_CPPFLAGS"
192 else
193 AC_MSG_ERROR([one of OpenSSL or Gcrypt was not found])
194 fi
195
196 AC_SUBST(CRYPTO_CFLAGS)
197 AC_SUBST(CRYPTO_INCLUDES)
198 AC_SUBST(CRYPTO_LIBS)
199 AC_SUBST(CRYPTO_LDFLAGS)
200
201 AM_CONDITIONAL([LIBGCRYPT], [test "$CRYPTO_TYPE" = libgcrypt])
202 AM_CONDITIONAL([GCRYPT_WITH_AES], [test x"${GCRYPT_WITH_AES}" != x])
203 AM_CONDITIONAL([GCRYPT_WITH_ARCFOUR], [test x"${GCRYPT_WITH_ARCFOUR}" != x])
204 AM_CONDITIONAL([GCRYPT_WITH_CMAC], [test x"${GCRYPT_WITH_CMAC_AES}" != x])
205 AM_CONDITIONAL([GCRYPT_WITH_MD5], [test x"${GCRYPT_WITH_MD5}" != x])
206 AM_CONDITIONAL([GCRYPT_WITH_SHA1], [test x"${GCRYPT_WITH_SHA1}" != x])
207 AM_CONDITIONAL([GCRYPT_WITH_SHA256], [test x"${GCRYPT_WITH_SHA256}" != x])
208 AM_CONDITIONAL([OPENSSL_WITH_AES], [test x"${OPENSSL_WITH_AES}" != x])
209 AM_CONDITIONAL([OPENSSL_WITH_ARCFOUR], [test x"${OPENSSL_WITH_ARCFOUR}" != x])
210 AM_CONDITIONAL([OPENSSL_WITH_CMAC], [test x"${OPENSSL_WITH_CMAC}" != x])
211 AM_CONDITIONAL([OPENSSL_WITH_MD5], [test x"${OPENSSL_WITH_MD5}" != x])
212 AM_CONDITIONAL([OPENSSL_WITH_SHA1], [test x"${OPENSSL_WITH_SHA1}" != x])
213 AM_CONDITIONAL([OPENSSL_WITH_SHA256], [test x"${OPENSSL_WITH_SHA256}" != x])
214 AM_CONDITIONAL([STATIC_CRYPTO], [test "$static_crypto" != no])
215 ])