language
stringlengths
0
24
filename
stringlengths
9
214
code
stringlengths
99
9.93M
M4 Macro
aircrack-ng/build/m4/aircrack_ng_pcap.m4
dnl Aircrack-ng dnl dnl Copyright (C) 2017 Joseph Benden <joe@benden.us> dnl dnl Autotool support was written by: Joseph Benden <joe@benden.us> dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_PCAP], [ AC_ARG_WITH(libpcap-include, [AS_HELP_STRING([--with-libpcap-include=DIR], [use PCAP includes in DIR, [default=auto]]) ],[ if test -d "$withval" ; then CPPFLAGS="$CPPFLAGS -I$withval" fi ]) AC_ARG_WITH(libpcap-lib, [AS_HELP_STRING([--with-libpcap-lib=DIR], [use PCAP libraries in DIR, [default=auto]]) ],[ if test -d "$withval" ; then LDFLAGS="$LDFLAGS -L$withval" fi ]) dnl dnl Search for headers dnl if test "${with_libpcap_include+set}" != set; then AC_MSG_CHECKING(pcap header directories) found_pcap_dir="" for pcap_dir in /usr/include/pcap /usr/local/include/pcap \ $prefix/include ; do if test -d "$pcap_dir" ; then found_pcap_dir="$pcap_dir" break fi done if test "$found_pcap_dir" != "" ; then PCAP_CFLAGS="-I$found_pcap_dir" AC_SUBST([PCAP_CFLAGS]) AC_MSG_RESULT([$found_pcap_dir]) else AC_MSG_RESULT([not found]) fi fi dnl dnl Verify that required headers are usable dnl saved_cflags="$CFLAGS" CFLAGS="$PCAP_INCLUDES $CFLAGS" AC_CHECK_HEADERS([pcap.h], [ PCAP_FOUND=yes ], [ PCAP_FOUND=no ]) CFLAGS="$saved_cflags" AC_ARG_ENABLE(static-pcap, AS_HELP_STRING([--enable-static-pcap], [Enable statically linked PCAP libpcap.]), [static_pcap=$enableval], [static_pcap=no]) dnl dnl Locate the library dnl AS_IF([test "$PCAP_FOUND" = yes], [ if test "x$static_pcap" != "xno"; then AC_REQUIRE([AX_EXT_HAVE_STATIC_LIB_DETECT]) AX_EXT_HAVE_STATIC_LIB(PCAP, ${DEFAULT_STATIC_LIB_SEARCH_PATHS}, pcap libpcap, pcap_open_live) if test "x$PCAP_FOUND" = xyes; then AC_DEFINE([HAVE_PCAP], [1], [Define this if you have libpcap on your system]) fi else AC_CHECK_LIB([pcap], [pcap_open_live], [ PCAP_LIBS=-lpcap AC_DEFINE([HAVE_PCAP], [1], [Define this if you have libpcap on your system]) AC_SUBST(PCAP_LIBS) PCAP_FOUND=yes ],[ PCAP_FOUND=no ]) fi ]) AM_CONDITIONAL([HAVE_PCAP], [test "$PCAP_FOUND" = yes]) ])
M4 Macro
aircrack-ng/build/m4/aircrack_ng_pcre.m4
dnl Aircrack-ng dnl dnl Copyright (C) 2017 Joseph Benden <joe@benden.us> dnl dnl Autotool support was written by: Joseph Benden <joe@benden.us> dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_PCRE], [ AC_ARG_ENABLE(static-pcre, AS_HELP_STRING([--enable-static-pcre], [Enable statically linked PCRE libpcre.]), [static_pcre=$enableval], [static_pcre=no]) if test "x$static_pcre" != "xno"; then AC_REQUIRE([AX_EXT_HAVE_STATIC_LIB_DETECT]) AX_EXT_HAVE_STATIC_LIB(PCRE, ${DEFAULT_STATIC_LIB_SEARCH_PATHS}, pcre libpcre, pcre_version) if test "x$PCRE_FOUND" = xyes; then HAVE_PCRE=yes else HAVE_PCRE=no fi else PKG_CHECK_MODULES(PCRE, libpcre, HAVE_PCRE=yes, HAVE_PCRE=no) fi AC_ARG_ENABLE(static-pcre2, AS_HELP_STRING([--enable-static-pcre2], [Enable statically linked PCRE2 libpcre2-8.]), [static_pcre2=$enableval], [static_pcre2=no]) if test "x$static_pcre2" != "xno"; then AC_REQUIRE([AX_EXT_HAVE_STATIC_LIB_DETECT]) AX_EXT_HAVE_STATIC_LIB(PCRE2, ${DEFAULT_STATIC_LIB_SEARCH_PATHS}, pcre2 libpcre2-8, pcre2_version) if test "x$PCRE2_FOUND" = xyes; then HAVE_PCRE2=yes else HAVE_PCRE2=no fi else PKG_CHECK_MODULES(PCRE2, libpcre2-8, HAVE_PCRE2=yes, HAVE_PCRE2=no) fi if test "x$HAVE_PCRE" = "xyes" && test "x$HAVE_PCRE2" = "xyes"; then AC_DEFINE([HAVE_PCRE2], [1], [Define this if you have libpcre2-8 on your system]) PCRE2_NOTE="(Pcre and Pcre2 found, using Pcre2)" elif test "x$HAVE_PCRE" = "xyes"; then AC_DEFINE([HAVE_PCRE], [1], [Define this if you have libpcre on your system]) elif test "x$HAVE_PCRE2" = "xyes"; then AC_DEFINE([HAVE_PCRE2], [1], [Define this if you have libpcre2-8 on your system]) fi ])
M4 Macro
aircrack-ng/build/m4/aircrack_ng_prog_cc.m4
dnl Aircrack-ng dnl dnl Copyright (C) 2017 Joseph Benden <joe@benden.us> dnl dnl Autotool support was written by: Joseph Benden <joe@benden.us> dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_PROG_CC],[ dnl dnl Require a C compiler, while working around a known problem of dnl Autoconf including the GCC flags '-g -O2'. dnl saved_cflags="$CFLAGS" AC_PROG_CC CFLAGS="$saved_cflags" ])
M4 Macro
aircrack-ng/build/m4/aircrack_ng_prog_cxx.m4
dnl Aircrack-ng dnl dnl Copyright (C) 2017 Joseph Benden <joe@benden.us> dnl dnl Autotool support was written by: Joseph Benden <joe@benden.us> dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_PROG_CXX],[ dnl dnl Require a C compiler, while working around a known problem of dnl Autoconf including the GCC flags '-g -O2'. dnl saved_cxxflags="$CXXFLAGS" AC_PROG_CXX CXXFLAGS="$saved_cxxflags" ])
M4 Macro
aircrack-ng/build/m4/aircrack_ng_pthread.m4
dnl Aircrack-ng dnl dnl Copyright (C) 2018 Joseph Benden <joe@benden.us> dnl dnl Autotool support was written by: Joseph Benden <joe@benden.us> dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_PTHREAD], [ AX_PTHREAD([ AC_CHECK_LIB([pthread], [pthread_create], [ PTHREAD_LIBS="-lpthread" ]) dnl AC_DEFINE([_REENTRANT], [], [Define this if your library functions are re-entrant]) ]) AC_MSG_CHECKING([for pthread_setaffinity_np]) AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl ac_save_[]FLAGS="$[]FLAGS" ac_save_LDFLAGS="$LDFLAGS" FLAGS="$ac_save_[]FLAGS -pthread" LDFLAGS="$LDFLAGS $PTHREAD_LIBS -pthread" # Check for pthread_{,attr_}[sg]etaffinity_np. AC_LINK_IFELSE([ AC_LANG_PROGRAM([ #define _GNU_SOURCE #include <pthread.h> ], [ cpu_set_t g_cpuset; pthread_attr_t attr; pthread_getaffinity_np (pthread_self (), sizeof (cpu_set_t), &g_cpuset); if (CPU_ISSET (0, &g_cpuset)) CPU_SET (1, &g_cpuset); else CPU_ZERO (&g_cpuset); pthread_setaffinity_np (pthread_self (), sizeof (cpu_set_t), &g_cpuset); pthread_attr_init (&attr); pthread_attr_getaffinity_np (&attr, sizeof (cpu_set_t), &g_cpuset); pthread_attr_setaffinity_np (&attr, sizeof (cpu_set_t), &g_cpuset); ]) ], [ AC_MSG_RESULT([yes]) AC_DEFINE(HAVE_PTHREAD_AFFINITY_NP, 1, [Define if pthread_{,attr_}{g,s}etaffinity_np is supported.]) ], [ AC_MSG_RESULT([no]) ]) LDFLAGS="$ac_save_LDFLAGS" FLAGS="$ac_save_[]FLAGS" AS_VAR_POPDEF([FLAGS])dnl ])
M4 Macro
aircrack-ng/build/m4/aircrack_ng_rfkill.m4
dnl Aircrack-ng dnl dnl Copyright (C) 2017 Joseph Benden <joe@benden.us> dnl dnl Autotool support was written by: Joseph Benden <joe@benden.us> dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_RFKILL],[ AC_ARG_VAR([RFKILL],[Use this rfkill tool.]) dnl Allow env override but do not be fooled by 'ETHTOOL=t'. test t = "$RFKILL" && unset RFKILL AC_CHECK_PROG([RFKILL], [rfkill], [$as_dir/$ac_word$ac_exec_ext], [], [$RFKILL_PATH$PATH_SEPARATOR$PATH$PATH_SEPARATOR/sbin$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/usr/local/sbin]) ])
M4 Macro
aircrack-ng/build/m4/aircrack_ng_simd.m4
dnl Aircrack-ng dnl dnl Copyright (C) 2017 Joseph Benden <joe@benden.us> dnl dnl Autotool support was written by: Joseph Benden <joe@benden.us> dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_SIMD], [ AX_REQUIRE_DEFINED([AX_COMPILER_VENDOR]) AX_REQUIRE_DEFINED([AX_COMPILER_VERSION]) AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG]) AX_REQUIRE_DEFINED([AX_APPEND_FLAG]) AX_COMPILER_VENDOR AX_COMPILER_VERSION OPENBSD=0 IS_X86=0 IS_ARM=0 IS_PPC=0 IS_CROSS=0 if test "$cross_compiling" != yes then IS_CROSS=0 else IS_CROSS=1 fi case "$host_cpu" in x86_64 | amd64 | i*86*) IS_X86=1 ;; *arm* | *aarch64*) IS_ARM=1 ;; *mips*) IS_MIPS=1 ;; powerpc*) IS_PPC=1 ;; esac case "$host_os" in *openbsd* | *OpenBSD*) OPENBSD=1 ;; esac if test $IS_ARM -eq 1 then AX_CHECK_COMPILE_FLAG([-Werror -mfpu=neon], [ AX_APPEND_FLAG(-mfpu=neon, [arm_neon_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(arm_neon_[]_AC_LANG_ABBREV[]flags) ]) AS_VAR_PUSHDEF([CACHEVAR], [ax_cv_neon_[]_AC_LANG_ABBREV[]flags]) AC_CACHE_CHECK([whether _AC_LANG compiler supports NEON instructions], CACHEVAR, [ ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS _AC_LANG_PREFIX[]FLAGS="$arm_neon_[]_AC_LANG_ABBREV[]flags $[]_AC_LANG_PREFIX[]FLAGS" AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ #if !defined(__ARM_NEON) && !defined(__ARM_NEON__) && !defined(__aarch64) && !defined(__aarch64__) #error macro not defined #endif ]])], [AS_VAR_SET(CACHEVAR,[yes])], [AS_VAR_SET(CACHEVAR,[no])]) _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags ]) AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes], [NEON_FOUND=1], [NEON_FOUND=0]) AS_VAR_POPDEF([CACHEVAR]) fi if test $IS_PPC -eq 1 then AX_CHECK_COMPILE_FLAG([-finline-functions], [ AX_APPEND_FLAG(-finline-functions, [ppc_altivec_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(ppc_altivec_[]_AC_LANG_ABBREV[]flags) ]) AX_CHECK_COMPILE_FLAG([-finline-limit=4000], [ AX_APPEND_FLAG(-finline-limit=4000, [ppc_altivec_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(ppc_altivec_[]_AC_LANG_ABBREV[]flags) ]) AX_CHECK_COMPILE_FLAG([-fno-strict-aliasing], [ AX_APPEND_FLAG(-fno-strict-aliasing, [ppc_altivec_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(ppc_altivec_[]_AC_LANG_ABBREV[]flags) ]) AX_CHECK_COMPILE_FLAG([-maltivec], [ AX_APPEND_FLAG(-maltivec, [ppc_altivec_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(ppc_altivec_[]_AC_LANG_ABBREV[]flags) ]) AX_CHECK_COMPILE_FLAG([-mabi=altivec], [ AX_APPEND_FLAG(-mabi=altivec, [ppc_altivec_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(ppc_altivec_[]_AC_LANG_ABBREV[]flags) ]) AS_VAR_PUSHDEF([CACHEVAR], [ax_cv_altivec_[]_AC_LANG_ABBREV[]flags]) AC_CACHE_CHECK([whether _AC_LANG compiler supports VSX instructions], CACHEVAR, [ ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS _AC_LANG_PREFIX[]FLAGS="$ppc_altivec_[]_AC_LANG_ABBREV[]flags -mvsx -mpower8-vector $[]_AC_LANG_PREFIX[]FLAGS" AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ #if !defined(__VSX__) && !defined(__POWER8_VECTOR__) #error macro not defined #endif ]])], [AS_VAR_SET(CACHEVAR,[yes])], [AS_VAR_SET(CACHEVAR,[no])]) _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags ]) AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes], [ ALTIVEC_FOUND=1 POWER8_FOUND=1 AX_APPEND_FLAG(-mvsx, [ppc_altivec_[]_AC_LANG_ABBREV[]flags]) AX_APPEND_FLAG(-mpower8-vector, [ppc_altivec_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(ppc_altivec_[]_AC_LANG_ABBREV[]flags) ], [ ALTIVEC_FOUND=0 POWER8_FOUND=0 ]) AS_VAR_POPDEF([CACHEVAR]) fi if test $IS_X86 -eq 0 then AC_CHECK_HEADERS([sys/auxv.h], [ AC_DEFINE([HAS_AUXV], [1], [Define if your system has sys/auxv.h header]) ]) fi AC_ARG_WITH(cacheline-size, [AS_HELP_STRING([--with-cacheline-size=[width]], [use specific CPU L1 cache-line size, in bytes. [default=64]])]) case $with_cacheline_size in no | "") CACHELINE_SIZE=64;; *) CACHELINE_SIZE=$with_cacheline_size;; esac AC_SUBST([CACHELINE_SIZE]) AC_DEFINE_UNQUOTED([CACHELINE_SIZE], [$CACHELINE_SIZE], [Define to set the specific CPU L1 cache-line size, in bytes.]) AC_ARG_WITH(static-simd, [AS_HELP_STRING([--with-static-simd[[=x86-sse2|x86-avx|x86-avx2|x86-avx512|ppc-altivec|ppc-power8|arm-neon|arm-asimd]], [use specific SIMD implementation at static link, [default=none]]])]) case $with_static_simd in no | "") ;; x86-sse2|x86-avx|x86-avx2|x86-avx512|ppc-altivec|ppc-power8|arm-neon|arm-asimd) SIMD_SUFFIX=_$(echo $with_static_simd | tr '[a-z]' '[A-Z]' | tr '-' '_') AC_SUBST([SIMD_SUFFIX]) case "$enable_static,$enable_shared" in "yes,yes" | "no,yes" | "no,no" ) AC_MSG_ERROR([The --with-static-simd option is only valid with static builds.]) ;; esac ;; *) AC_MSG_ERROR([Invalid SIMD given to --with-static-simd option.]) ;; esac AC_ARG_WITH(avx512, [AS_HELP_STRING([--with-avx512[[=yes|no]]], [use AVX-512F instruction set, [default=no]])]) if test $IS_X86 -eq 1 then case $with_avx512 in yes) case "$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor" in intel) AX_APPEND_FLAG(-march=skylake-avx512, [x86_avx512_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(x86_avx512_[]_AC_LANG_ABBREV[]flags) AVX512F_FOUND=1 AC_SUBST([AVX512F_FOUND], [1], [Define if your system supports AVX-512F]) ;; *) AX_CHECK_COMPILE_FLAG([-mavx512f], [ AX_APPEND_FLAG(-mavx512f, [x86_avx512_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(x86_avx512_[]_AC_LANG_ABBREV[]flags) AVX512F_FOUND=1 AC_SUBST([AVX512F_FOUND], [1], [Define if your system supports AVX-512F]) ]) ;; esac AC_DEFINE_UNQUOTED([AVX512F_FOUND], [$AVX512F_FOUND], [Define to enable AVX-512F buffers.]) ;; esac case "$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor" in intel) AX_APPEND_FLAG(-march=core-avx2, [x86_avx2_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(x86_avx2_[]_AC_LANG_ABBREV[]flags) AX_APPEND_FLAG(-march=corei7-avx, [x86_avx_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(x86_avx_[]_AC_LANG_ABBREV[]flags) AX_APPEND_FLAG(-march=corei7, [x86_sse2_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(x86_sse2_[]_AC_LANG_ABBREV[]flags) AX_APPEND_FLAG(-march=pentiumii, [x86_mmx_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(x86_mmx_[]_AC_LANG_ABBREV[]flags) ;; *) AX_CHECK_COMPILE_FLAG([-mavx2], [ AX_APPEND_FLAG(-mavx2, [x86_avx2_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(x86_avx2_[]_AC_LANG_ABBREV[]flags) ]) AX_CHECK_COMPILE_FLAG([-mavx], [ AX_APPEND_FLAG(-mavx, [x86_avx_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(x86_avx_[]_AC_LANG_ABBREV[]flags) ]) AX_CHECK_COMPILE_FLAG([-msse2], [ AX_APPEND_FLAG(-msse2, [x86_sse2_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(x86_sse2_[]_AC_LANG_ABBREV[]flags) ]) AX_CHECK_COMPILE_FLAG([-mmmx], [ AX_APPEND_FLAG(-mmmx, [x86_mmx_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(x86_mmx_[]_AC_LANG_ABBREV[]flags) ]) ;; esac fi AM_CONDITIONAL([X86], [test "$IS_X86" = 1]) AM_CONDITIONAL([ARM], [test "$IS_ARM" = 1]) AM_CONDITIONAL([PPC], [test "$IS_PPC" = 1]) AM_CONDITIONAL([NEON], [test "$NEON_FOUND" = 1]) AM_CONDITIONAL([AVX512F], [test "$AVX512F_FOUND" = 1]) AM_CONDITIONAL([ALTIVEC], [test "$ALTIVEC_FOUND" = 1]) AM_CONDITIONAL([POWER8], [test "$POWER8_FOUND" = 1]) ]) AC_DEFUN([AIRCRACK_NG_SIMD_C], [ AC_LANG_PUSH([C]) AIRCRACK_NG_SIMD AC_LANG_POP([C]) ]) AC_DEFUN([AIRCRACK_NG_SIMD_CXX], [ AC_LANG_PUSH([C++]) AIRCRACK_NG_SIMD AC_LANG_POP([C++]) ])
M4 Macro
aircrack-ng/build/m4/aircrack_ng_sqlite.m4
dnl Aircrack-ng dnl dnl Copyright (C) 2017 Joseph Benden <joe@benden.us> dnl dnl Autotool support was written by: Joseph Benden <joe@benden.us> dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_SQLITE],[ AC_ARG_ENABLE(static-sqlite3, AS_HELP_STRING([--enable-static-sqlite3], [Enable statically linked SQLite3 libsqlite3.]), [static_sqlite3=$enableval], [static_sqlite3=no]) if test "x$static_sqlite3" != "xno"; then AC_REQUIRE([AX_EXT_HAVE_STATIC_LIB_DETECT]) AX_EXT_HAVE_STATIC_LIB(SQLITE3, ${DEFAULT_STATIC_LIB_SEARCH_PATHS}, sqlite3 libsqlite3, sqlite3_open, -lpthread -ldl) if test "x$SQLITE3_FOUND" = xyes; then HAVE_SQLITE3=yes fi else AX_LIB_SQLITE3 fi if test x"$HAVE_SQLITE3" = xyes; then AC_DEFINE([HAVE_SQLITE], [1], [Define if you have sqlite3]) HAVE_SQLITE3=yes else HAVE_SQLITE3=no fi AM_CONDITIONAL([HAVE_SQLITE3], [test "$HAVE_SQLITE3" = yes]) ])
M4 Macro
aircrack-ng/build/m4/aircrack_ng_tcmalloc.m4
dnl Aircrack-ng dnl dnl Copyright (C) 2018 Joseph Benden <joe@benden.us> dnl dnl Autotool support was written by: Joseph Benden <joe@benden.us> dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_TCMALLOC], [ AX_REQUIRE_DEFINED([AX_COMPILER_VENDOR]) AX_REQUIRE_DEFINED([AC_CHECK_LIB]) AX_COMPILER_VENDOR AC_ARG_WITH(tcmalloc, [AS_HELP_STRING([--with-tcmalloc[[=yes|no]]], [use tcmalloc library, [default=no]])]) case $with_tcmalloc in yes) AC_CHECK_LIB([tcmalloc], [TCMallocGetenvSafe], [ LIBS="$LIBS -ltcmalloc" TCMALLOC=yes ],[ TCMALLOC=no ]) ;; *) TCMALLOC=no ;; esac case "$ax_cv_c_compiler_vendor" in clang|gnu) if test "$TCMALLOC" = yes; then CFLAGS="$CFLAGS -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free" CXXFLAGS="$CXXFLAGS -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free" fi ;; esac ])
M4 Macro
aircrack-ng/build/m4/aircrack_ng_tsan.m4
dnl Aircrack-ng dnl dnl Copyright (C) 2018 Joseph Benden <joe@benden.us> dnl dnl Autotool support was written by: Joseph Benden <joe@benden.us> dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_TSAN], [ AC_ARG_ENABLE(tsan, AS_HELP_STRING([--enable-tsan], [Enable ThreadSanitizer (TSAN)]), [tsan=$enableval], [tsan=no]) if test "x$tsan" != "xno"; then # Assume both C and C++ compiler either support TSAN or not. LDFLAGS_saved="$LDFLAGS" LDFLAGS="$LDFLAGS -fsanitize=thread" AX_CHECK_COMPILE_FLAG([-fsanitize=thread], [CFLAGS="$CFLAGS -fsanitize=thread"; CXXFLAGS="$CXXFLAGS -fsanitize=thread"], [LDFLAGS="$LDFLAGS_saved"]) fi ])
M4 Macro
aircrack-ng/build/m4/aircrack_ng_windows.m4
dnl Aircrack-ng dnl dnl Copyright (C) 2017 Joseph Benden <joe@benden.us> dnl dnl Autotool support was written by: Joseph Benden <joe@benden.us> dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_WINDOWS],[ AX_REQUIRE_DEFINED([AC_CHECK_HEADER])[]dnl AX_REQUIRE_DEFINED([AX_COMPILER_VENDOR])dnl AC_ARG_ENABLE(win32-portable, AS_HELP_STRING([--enable-win32-portable], [Enable portable WIN32 edition]), [ AC_DEFINE([WIN32_PORTABLE], [1], [Define if portable WIN32 is supported]) ], []) case "$host_os" in CYGWIN*|MSYS*|cygwin*|msys*) AC_CHECK_FILE(/usr/include/w32api/windows.h, [ CPPFLAGS="$CPPFLAGS -I/usr/include/w32api" ], []) AC_CHECK_LIB(w32api, WinMain, [ LIBS="$LIBS -lw32api" ]) AC_CHECK_HEADER(windows.h, [], [AC_MSG_ERROR([windows.h was not found])]) CPPFLAGS="$CPPFLAGS -DCYGWIN" CFLAGS="$CFLAGS -mconsole -mwindows" CXXFLAGS="$CXXFLAGS -mconsole -mwindows" LDFLAGS="$LDFLAGS -mconsole -mwindows" case "$host_os" in MSYS*|msys*) CPPFLAGS="$CPPFLAGS -DMSYS2" CFLAGS="$CFLAGS -DMSYS2" CXXFLAGS="$CXXFLAGS -DMSYS2" ;; esac case "$ax_cv_c_compiler_vendor" in clang) LIBS="$LIBS -liconv" ;; esac ;; esac ])
M4 Macro
aircrack-ng/build/m4/aircrack_ng_zlib.m4
dnl Aircrack-ng dnl dnl Copyright (C) 2017 Joseph Benden <joe@benden.us> dnl dnl Autotool support was written by: Joseph Benden <joe@benden.us> dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_ZLIB], [ PKG_CHECK_MODULES([ZLIB], [zlib], [ HAVE_ZLIB=yes AC_DEFINE([HAVE_ZLIB], [1], [Define if you have zlib]) ], [HAVE_ZLIB=no]) ])
M4 Macro
aircrack-ng/build/m4/ax_ac_append_to_file.m4
# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_ac_append_to_file.html # =========================================================================== # # SYNOPSIS # # AX_AC_APPEND_TO_FILE([FILE],[DATA]) # # DESCRIPTION # # Appends the specified data to the specified Autoconf is run. If you want # to append to a file when configure is run use AX_APPEND_TO_FILE instead. # # LICENSE # # Copyright (c) 2009 Allan Caffee <allan.caffee@gmail.com> # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 10 AC_DEFUN([AX_AC_APPEND_TO_FILE],[ AC_REQUIRE([AX_FILE_ESCAPES]) m4_esyscmd( AX_FILE_ESCAPES [ printf "%s" "$2" >> "$1" ]) ])
M4 Macro
aircrack-ng/build/m4/ax_ac_print_to_file.m4
# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_ac_print_to_file.html # =========================================================================== # # SYNOPSIS # # AX_AC_PRINT_TO_FILE([FILE],[DATA]) # # DESCRIPTION # # Writes the specified data to the specified file when Autoconf is run. If # you want to print to a file when configure is run use AX_PRINT_TO_FILE # instead. # # LICENSE # # Copyright (c) 2009 Allan Caffee <allan.caffee@gmail.com> # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 10 AC_DEFUN([AX_AC_PRINT_TO_FILE],[ m4_esyscmd( AC_REQUIRE([AX_FILE_ESCAPES]) [ printf "%s" "$2" > "$1" ]) ])
M4 Macro
aircrack-ng/build/m4/ax_add_am_macro_static.m4
# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_add_am_macro_static.html # =========================================================================== # # SYNOPSIS # # AX_ADD_AM_MACRO_STATIC([RULE]) # # DESCRIPTION # # Adds the specified rule to $AMINCLUDE. # # LICENSE # # Copyright (c) 2009 Tom Howard <tomhoward@users.sf.net> # Copyright (c) 2009 Allan Caffee <allan.caffee@gmail.com> # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 8 AC_DEFUN([AX_ADD_AM_MACRO_STATIC],[ AC_REQUIRE([AX_AM_MACROS_STATIC]) AX_AC_APPEND_TO_FILE(AMINCLUDE_STATIC,[$1]) ])
M4 Macro
aircrack-ng/build/m4/ax_am_macros_static.m4
# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_am_macros_static.html # =========================================================================== # # SYNOPSIS # # AX_AM_MACROS_STATIC # # DESCRIPTION # # Adds support for macros that create Automake rules. You must manually # add the following line # # include $(top_srcdir)/aminclude_static.am # # to your Makefile.am files. # # LICENSE # # Copyright (c) 2009 Tom Howard <tomhoward@users.sf.net> # Copyright (c) 2009 Allan Caffee <allan.caffee@gmail.com> # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 11 AC_DEFUN([AMINCLUDE_STATIC],[aminclude_static.am]) AC_DEFUN([AX_AM_MACROS_STATIC], [ AX_AC_PRINT_TO_FILE(AMINCLUDE_STATIC,[ # ]AMINCLUDE_STATIC[ generated automatically by Autoconf # from AX_AM_MACROS_STATIC on ]m4_esyscmd([LC_ALL=C date])[ ]) ])
M4 Macro
aircrack-ng/build/m4/ax_append_flag.m4
# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_append_flag.html # =========================================================================== # # SYNOPSIS # # AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE]) # # DESCRIPTION # # FLAG is appended to the FLAGS-VARIABLE shell variable, with a space # added in between. # # If FLAGS-VARIABLE is not specified, the current language's flags (e.g. # CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains # FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly # FLAG. # # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. # # LICENSE # # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de> # Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com> # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation, either version 3 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see <https://www.gnu.org/licenses/>. # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 7 AC_DEFUN([AX_APPEND_FLAG], [dnl AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])]) AS_VAR_SET_IF(FLAGS,[ AS_CASE([" AS_VAR_GET(FLAGS) "], [*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])], [ AS_VAR_APPEND(FLAGS,[" $1"]) AC_RUN_LOG([: FLAGS="$FLAGS"]) ]) ], [ AS_VAR_SET(FLAGS,[$1]) AC_RUN_LOG([: FLAGS="$FLAGS"]) ]) AS_VAR_POPDEF([FLAGS])dnl ])dnl AX_APPEND_FLAG
M4 Macro
aircrack-ng/build/m4/ax_cflags_warn_all.m4
# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_cflags_warn_all.html # =========================================================================== # # SYNOPSIS # # AX_CFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] # AX_CXXFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] # AX_FCFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] # # DESCRIPTION # # Try to find a compiler option that enables most reasonable warnings. # # For the GNU compiler it will be -Wall (and -ansi -pedantic) The result # is added to the shellvar being CFLAGS, CXXFLAGS, or FCFLAGS by default. # # Currently this macro knows about the GCC, Solaris, Digital Unix, AIX, # HP-UX, IRIX, NEC SX-5 (Super-UX 10), Cray J90 (Unicos 10.0.0.8), and # Intel compilers. For a given compiler, the Fortran flags are much more # experimental than their C equivalents. # # - $1 shell-variable-to-add-to : CFLAGS, CXXFLAGS, or FCFLAGS # - $2 add-value-if-not-found : nothing # - $3 action-if-found : add value to shellvariable # - $4 action-if-not-found : nothing # # NOTE: These macros depend on AX_APPEND_FLAG. # # LICENSE # # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de> # Copyright (c) 2010 Rhys Ulerich <rhys.ulerich@gmail.com> # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 3 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see <https://www.gnu.org/licenses/>. # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 16 AC_DEFUN([AX_FLAGS_WARN_ALL],[dnl AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl AS_VAR_PUSHDEF([VAR],[ac_cv_[]_AC_LANG_ABBREV[]flags_warn_all])dnl AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings], VAR,[VAR="no, unknown" ac_save_[]FLAGS="$[]FLAGS" for ac_arg dnl in "-warn all % -warn all" dnl Intel "-pedantic % -Wall" dnl GCC "-xstrconst % -v" dnl Solaris C "-std1 % -verbose -w0 -warnprotos" dnl Digital Unix "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX "-ansi -ansiE % -fullwarn" dnl IRIX "+ESlit % +w1" dnl HP-UX C "-Xc % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10) "-h conform % -h msglevel 2" dnl Cray C (Unicos) # do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` AC_COMPILE_IFELSE([AC_LANG_PROGRAM], [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) done FLAGS="$ac_save_[]FLAGS" ]) AS_VAR_POPDEF([FLAGS])dnl AX_REQUIRE_DEFINED([AX_APPEND_FLAG]) case ".$VAR" in .ok|.ok,*) m4_ifvaln($3,$3) ;; .|.no|.no,*) m4_default($4,[m4_ifval($2,[AX_APPEND_FLAG([$2], [$1])])]) ;; *) m4_default($3,[AX_APPEND_FLAG([$VAR], [$1])]) ;; esac AS_VAR_POPDEF([VAR])dnl ])dnl AX_FLAGS_WARN_ALL dnl implementation tactics: dnl the for-argument contains a list of options. The first part of dnl these does only exist to detect the compiler - usually it is dnl a global option to enable -ansi or -extrawarnings. All other dnl compilers will fail about it. That was needed since a lot of dnl compilers will give false positives for some option-syntax dnl like -Woption or -Xoption as they think of it is a pass-through dnl to later compile stages or something. The "%" is used as a dnl delimiter. A non-option comment can be given after "%%" marks dnl which will be shown but not added to the respective C/CXXFLAGS. AC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl AC_LANG_PUSH([C]) AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) AC_LANG_POP([C]) ]) AC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl AC_LANG_PUSH([C++]) AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) AC_LANG_POP([C++]) ]) AC_DEFUN([AX_FCFLAGS_WARN_ALL],[dnl AC_LANG_PUSH([Fortran]) AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) AC_LANG_POP([Fortran]) ])
M4 Macro
aircrack-ng/build/m4/ax_check_cflags.m4
AC_DEFUN([AX_CHECK_CFLAGS], [ AC_MSG_CHECKING([whether compiler accepts "$1"]) cat > conftest.c++ << EOF int main(){ return 0; } EOF if $CC $CPPFLAGS $CFLAGS -o conftest.o conftest.c++ [$1] > /dev/null 2>&1 then AC_MSG_RESULT([yes]) CFLAGS="${CFLAGS} [$1]" [$2] else AC_MSG_RESULT([no]) [$3] fi ])dnl AX_CHECK_CFLAGS
M4 Macro
aircrack-ng/build/m4/ax_check_compile_flag.m4
# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html # =========================================================================== # # SYNOPSIS # # AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) # # DESCRIPTION # # Check whether the given FLAG works with the current language's compiler # or gives an error. (Warnings, however, are ignored) # # ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on # success/failure. # # If EXTRA-FLAGS is defined, it is added to the current language's default # flags (e.g. CFLAGS) when the check is done. The check is thus made with # the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to # force the compiler to issue an error when a bad flag is given. # # INPUT gives an alternative input source to AC_COMPILE_IFELSE. # # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this # macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. # # LICENSE # # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de> # Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com> # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation, either version 3 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see <https://www.gnu.org/licenses/>. # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 5 AC_DEFUN([AX_CHECK_COMPILE_FLAG], [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], [AS_VAR_SET(CACHEVAR,[yes])], [AS_VAR_SET(CACHEVAR,[no])]) _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) AS_VAR_IF(CACHEVAR,yes, [m4_default([$2], :)], [m4_default([$3], :)]) AS_VAR_POPDEF([CACHEVAR])dnl ])dnl AX_CHECK_COMPILE_FLAGS
M4 Macro
aircrack-ng/build/m4/ax_check_gnu_make.m4
# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_check_gnu_make.html # =========================================================================== # # SYNOPSIS # # AX_CHECK_GNU_MAKE([run-if-true],[run-if-false]) # # DESCRIPTION # # This macro searches for a GNU version of make. If a match is found: # # * The makefile variable `ifGNUmake' is set to the empty string, otherwise # it is set to "#". This is useful for including a special features in a # Makefile, which cannot be handled by other versions of make. # * The makefile variable `ifnGNUmake' is set to #, otherwise # it is set to the empty string. This is useful for including a special # features in a Makefile, which can be handled # by other versions of make or to specify else like clause. # * The variable `_cv_gnu_make_command` is set to the command to invoke # GNU make if it exists, the empty string otherwise. # * The variable `ax_cv_gnu_make_command` is set to the command to invoke # GNU make by copying `_cv_gnu_make_command`, otherwise it is unset. # * If GNU Make is found, its version is extracted from the output of # `make --version` as the last field of a record of space-separated # columns and saved into the variable `ax_check_gnu_make_version`. # * Additionally if GNU Make is found, run shell code run-if-true # else run shell code run-if-false. # # Here is an example of its use: # # Makefile.in might contain: # # # A failsafe way of putting a dependency rule into a makefile # $(DEPEND): # $(CC) -MM $(srcdir)/*.c > $(DEPEND) # # @ifGNUmake@ ifeq ($(DEPEND),$(wildcard $(DEPEND))) # @ifGNUmake@ include $(DEPEND) # @ifGNUmake@ else # fallback code # @ifGNUmake@ endif # # Then configure.in would normally contain: # # AX_CHECK_GNU_MAKE() # AC_OUTPUT(Makefile) # # Then perhaps to cause gnu make to override any other make, we could do # something like this (note that GNU make always looks for GNUmakefile # first): # # if ! test x$_cv_gnu_make_command = x ; then # mv Makefile GNUmakefile # echo .DEFAULT: > Makefile ; # echo \ $_cv_gnu_make_command \$@ >> Makefile; # fi # # Then, if any (well almost any) other make is called, and GNU make also # exists, then the other make wraps the GNU make. # # LICENSE # # Copyright (c) 2008 John Darrington <j.darrington@elvis.murdoch.edu.au> # Copyright (c) 2015 Enrico M. Crisostomo <enrico.m.crisostomo@gmail.com> # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 12 AC_DEFUN([AX_CHECK_GNU_MAKE],dnl [AC_PROG_AWK AC_CACHE_CHECK([for GNU make],[_cv_gnu_make_command],[dnl _cv_gnu_make_command="" ; dnl Search all the common names for GNU make for a in "$MAKE" make gmake gnumake ; do if test -z "$a" ; then continue ; fi ; if "$a" --version 2> /dev/null | grep GNU 2>&1 > /dev/null ; then _cv_gnu_make_command=$a ; AX_CHECK_GNU_MAKE_HEADLINE=$("$a" --version 2> /dev/null | grep "GNU Make") ax_check_gnu_make_version=$(echo ${AX_CHECK_GNU_MAKE_HEADLINE} | ${AWK} -F " " '{ print $(NF); }') break ; fi done ;]) dnl If there was a GNU version, then set @ifGNUmake@ to the empty string, '#' otherwise AS_VAR_IF([_cv_gnu_make_command], [""], [AS_VAR_SET([ifGNUmake], ["#"])], [AS_VAR_SET([ifGNUmake], [""])]) AS_VAR_IF([_cv_gnu_make_command], [""], [AS_VAR_SET([ifnGNUmake], [""])], [AS_VAR_SET([ifnGNUmake], ["#"])]) AS_VAR_IF([_cv_gnu_make_command], [""], [AS_UNSET(ax_cv_gnu_make_command)], [AS_VAR_SET([ax_cv_gnu_make_command], [${_cv_gnu_make_command}])]) AS_VAR_IF([_cv_gnu_make_command], [""],[$2],[$1]) AC_SUBST([ifGNUmake]) AC_SUBST([ifnGNUmake]) ])
M4 Macro
aircrack-ng/build/m4/ax_check_openssl.m4
# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_check_openssl.html # =========================================================================== # # SYNOPSIS # # AX_CHECK_OPENSSL([action-if-found[, action-if-not-found]]) # # DESCRIPTION # # Look for OpenSSL in a number of default spots, or in a user-selected # spot (via --with-openssl). Sets # # OPENSSL_INCLUDES to the include directives required # OPENSSL_LIBS to the -l directives required # OPENSSL_LDFLAGS to the -L or -R flags required # # and calls ACTION-IF-FOUND or ACTION-IF-NOT-FOUND appropriately # # This macro sets OPENSSL_INCLUDES such that source files should use the # openssl/ directory in include directives: # # #include <openssl/hmac.h> # # LICENSE # # Copyright (c) 2009,2010 Zmanda Inc. <http://www.zmanda.com/> # Copyright (c) 2009,2010 Dustin J. Mitchell <dustin@zmanda.com> # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 10 AU_ALIAS([CHECK_SSL], [AX_CHECK_OPENSSL]) AC_DEFUN([AX_CHECK_OPENSSL], [ found=false AC_ARG_WITH([openssl], [AS_HELP_STRING([--with-openssl=DIR], [root of the OpenSSL directory])], [ case "$withval" in "" | y | ye | yes | n | no) AC_MSG_ERROR([Invalid --with-openssl value]) ;; *) ssldirs="$withval" ;; esac ], [ AC_CHECK_LIB([crypto], [OPENSSL_init], [ OPENSSL_LIBS="-lssl -lcrypto" OPENSSL_LDFLAGS="" AC_CHECK_HEADERS([openssl/crypto.h], [ OPENSSL_INCLUDES="" found=true ]) ]) if ! $found; then # if pkg-config is installed and openssl has installed a .pc file, # then use that information and don't search ssldirs AC_CHECK_TOOL([PKG_CONFIG], [pkg-config]) if test x"$PKG_CONFIG" != x""; then OPENSSL_LDFLAGS=`$PKG_CONFIG openssl --libs-only-L 2>/dev/null` if test $? = 0; then OPENSSL_LIBS=`$PKG_CONFIG openssl --libs-only-l 2>/dev/null` OPENSSL_INCLUDES=`$PKG_CONFIG openssl --cflags-only-I 2>/dev/null` found=true fi fi fi # no such luck; use some default ssldirs if ! $found; then ssldirs="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr" fi ] ) # note that we #include <openssl/foo.h>, so the OpenSSL headers have to be in # an 'openssl' subdirectory if ! $found; then OPENSSL_INCLUDES= for ssldir in $ssldirs; do AC_MSG_CHECKING([for openssl/ssl.h in $ssldir]) if test -f "$ssldir/include/openssl/ssl.h"; then OPENSSL_INCLUDES="-I$ssldir/include" OPENSSL_LDFLAGS="-L$ssldir/lib" OPENSSL_LIBS="-lssl -lcrypto" found=true AC_MSG_RESULT([yes]) break else AC_MSG_RESULT([no]) fi done # if the file wasn't found, well, go ahead and try the link anyway -- maybe # it will just work! fi # try the preprocessor and linker with our new flags, # being careful not to pollute the global LIBS, LDFLAGS, and CPPFLAGS AC_MSG_CHECKING([whether compiling and linking against OpenSSL works]) echo "Trying link with OPENSSL_LDFLAGS=$OPENSSL_LDFLAGS;" \ "OPENSSL_LIBS=$OPENSSL_LIBS; OPENSSL_INCLUDES=$OPENSSL_INCLUDES" >&AS_MESSAGE_LOG_FD save_LIBS="$LIBS" save_LDFLAGS="$LDFLAGS" save_CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS" LIBS="$OPENSSL_LIBS $LIBS" CPPFLAGS="$OPENSSL_INCLUDES $CPPFLAGS" AC_LINK_IFELSE( [AC_LANG_PROGRAM([#include <openssl/ssl.h>], [SSL_new(NULL)])], [ AC_MSG_RESULT([yes]) $1 ], [ AC_MSG_RESULT([no]) $2 ]) CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" AC_SUBST([OPENSSL_INCLUDES]) AC_SUBST([OPENSSL_LIBS]) AC_SUBST([OPENSSL_LDFLAGS]) ])
M4 Macro
aircrack-ng/build/m4/ax_code_coverage.m4
# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_code_coverage.html # =========================================================================== # # SYNOPSIS # # AX_CODE_COVERAGE() # # DESCRIPTION # # Defines CODE_COVERAGE_CPPFLAGS, CODE_COVERAGE_CFLAGS, # CODE_COVERAGE_CXXFLAGS and CODE_COVERAGE_LIBS which should be included # in the CPPFLAGS, CFLAGS CXXFLAGS and LIBS/LIBADD variables of every # build target (program or library) which should be built with code # coverage support. Also add rules using AX_ADD_AM_MACRO_STATIC; and # $enable_code_coverage which can be used in subsequent configure output. # CODE_COVERAGE_ENABLED is defined and substituted, and corresponds to the # value of the --enable-code-coverage option, which defaults to being # disabled. # # Test also for gcov program and create GCOV variable that could be # substituted. # # Note that all optimization flags in CFLAGS must be disabled when code # coverage is enabled. # # Usage example: # # configure.ac: # # AX_CODE_COVERAGE # # Makefile.am: # # include $(top_srcdir)/aminclude_static.am # # my_program_LIBS = ... $(CODE_COVERAGE_LIBS) ... # my_program_CPPFLAGS = ... $(CODE_COVERAGE_CPPFLAGS) ... # my_program_CFLAGS = ... $(CODE_COVERAGE_CFLAGS) ... # my_program_CXXFLAGS = ... $(CODE_COVERAGE_CXXFLAGS) ... # # clean-local: code-coverage-clean # distclean-local: code-coverage-dist-clean # # This results in a "check-code-coverage" rule being added to any # Makefile.am which do "include $(top_srcdir)/aminclude_static.am" # (assuming the module has been configured with --enable-code-coverage). # Running `make check-code-coverage` in that directory will run the # module's test suite (`make check`) and build a code coverage report # detailing the code which was touched, then print the URI for the report. # # This code was derived from Makefile.decl in GLib, originally licensed # under LGPLv2.1+. # # LICENSE # # Copyright (c) 2012, 2016 Philip Withnall # Copyright (c) 2012 Xan Lopez # Copyright (c) 2012 Christian Persch # Copyright (c) 2012 Paolo Borelli # Copyright (c) 2012 Dan Winship # Copyright (c) 2015,2018 Bastien ROUCARIES # # This library is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or (at # your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser # General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. #serial 34 m4_define(_AX_CODE_COVERAGE_RULES,[ AX_ADD_AM_MACRO_STATIC([ # Code coverage # # Optional: # - CODE_COVERAGE_DIRECTORY: Top-level directory for code coverage reporting. # Multiple directories may be specified, separated by whitespace. # (Default: \$(top_builddir)) # - CODE_COVERAGE_OUTPUT_FILE: Filename and path for the .info file generated # by lcov for code coverage. (Default: # \$(PACKAGE_NAME)-\$(PACKAGE_VERSION)-coverage.info) # - CODE_COVERAGE_OUTPUT_DIRECTORY: Directory for generated code coverage # reports to be created. (Default: # \$(PACKAGE_NAME)-\$(PACKAGE_VERSION)-coverage) # - CODE_COVERAGE_BRANCH_COVERAGE: Set to 1 to enforce branch coverage, # set to 0 to disable it and leave empty to stay with the default. # (Default: empty) # - CODE_COVERAGE_LCOV_SHOPTS_DEFAULT: Extra options shared between both lcov # instances. (Default: based on $CODE_COVERAGE_BRANCH_COVERAGE) # - CODE_COVERAGE_LCOV_SHOPTS: Extra options to shared between both lcov # instances. (Default: $CODE_COVERAGE_LCOV_SHOPTS_DEFAULT) # - CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH: --gcov-tool pathtogcov # - CODE_COVERAGE_LCOV_OPTIONS_DEFAULT: Extra options to pass to the # collecting lcov instance. (Default: $CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH) # - CODE_COVERAGE_LCOV_OPTIONS: Extra options to pass to the collecting lcov # instance. (Default: $CODE_COVERAGE_LCOV_OPTIONS_DEFAULT) # - CODE_COVERAGE_LCOV_RMOPTS_DEFAULT: Extra options to pass to the filtering # lcov instance. (Default: empty) # - CODE_COVERAGE_LCOV_RMOPTS: Extra options to pass to the filtering lcov # instance. (Default: $CODE_COVERAGE_LCOV_RMOPTS_DEFAULT) # - CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT: Extra options to pass to the # genhtml instance. (Default: based on $CODE_COVERAGE_BRANCH_COVERAGE) # - CODE_COVERAGE_GENHTML_OPTIONS: Extra options to pass to the genhtml # instance. (Default: $CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT) # - CODE_COVERAGE_IGNORE_PATTERN: Extra glob pattern of files to ignore # # The generated report will be titled using the \$(PACKAGE_NAME) and # \$(PACKAGE_VERSION). In order to add the current git hash to the title, # use the git-version-gen script, available online. # Optional variables # run only on top dir if CODE_COVERAGE_ENABLED ifeq (\$(abs_builddir), \$(abs_top_builddir)) CODE_COVERAGE_DIRECTORY ?= \$(top_builddir) CODE_COVERAGE_OUTPUT_FILE ?= \$(abs_builddir)/\$(PACKAGE_NAME)-\$(PACKAGE_VERSION)-coverage.info CODE_COVERAGE_OUTPUT_DIRECTORY ?= \$(PACKAGE_NAME)-\$(PACKAGE_VERSION)-coverage CODE_COVERAGE_BRANCH_COVERAGE ?= 1 CODE_COVERAGE_LCOV_SHOPTS_DEFAULT ?= \$(if \$(CODE_COVERAGE_BRANCH_COVERAGE),\ --rc lcov_branch_coverage=\$(CODE_COVERAGE_BRANCH_COVERAGE)) CODE_COVERAGE_LCOV_SHOPTS ?= \$(CODE_COVERAGE_LCOV_SHOPTS_DEFAULT) CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH ?= --gcov-tool \"\$(GCOV)\" CODE_COVERAGE_LCOV_OPTIONS_DEFAULT ?= \$(CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH) CODE_COVERAGE_LCOV_OPTIONS ?= \$(CODE_COVERAGE_LCOV_OPTIONS_DEFAULT) CODE_COVERAGE_LCOV_RMOPTS_DEFAULT ?= CODE_COVERAGE_LCOV_RMOPTS ?= \$(CODE_COVERAGE_LCOV_RMOPTS_DEFAULT) CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT ?=\ \$(if \$(CODE_COVERAGE_BRANCH_COVERAGE),\ --rc genhtml_branch_coverage=\$(CODE_COVERAGE_BRANCH_COVERAGE)) CODE_COVERAGE_GENHTML_OPTIONS ?= \$(CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT) CODE_COVERAGE_IGNORE_PATTERN ?= GITIGNOREFILES := \$(GITIGNOREFILES) \$(CODE_COVERAGE_OUTPUT_FILE) \$(CODE_COVERAGE_OUTPUT_DIRECTORY) code_coverage_v_lcov_cap = \$(code_coverage_v_lcov_cap_\$(V)) code_coverage_v_lcov_cap_ = \$(code_coverage_v_lcov_cap_\$(AM_DEFAULT_VERBOSITY)) code_coverage_v_lcov_cap_0 = @echo \" LCOV --capture\" \$(CODE_COVERAGE_OUTPUT_FILE); code_coverage_v_lcov_ign = \$(code_coverage_v_lcov_ign_\$(V)) code_coverage_v_lcov_ign_ = \$(code_coverage_v_lcov_ign_\$(AM_DEFAULT_VERBOSITY)) code_coverage_v_lcov_ign_0 = @echo \" LCOV --remove /tmp/*\" \$(CODE_COVERAGE_IGNORE_PATTERN); code_coverage_v_genhtml = \$(code_coverage_v_genhtml_\$(V)) code_coverage_v_genhtml_ = \$(code_coverage_v_genhtml_\$(AM_DEFAULT_VERBOSITY)) code_coverage_v_genhtml_0 = @echo \" GEN \" \"\$(CODE_COVERAGE_OUTPUT_DIRECTORY)\"; code_coverage_quiet = \$(code_coverage_quiet_\$(V)) code_coverage_quiet_ = \$(code_coverage_quiet_\$(AM_DEFAULT_VERBOSITY)) code_coverage_quiet_0 = --quiet # sanitizes the test-name: replaces with underscores: dashes and dots code_coverage_sanitize = \$(subst -,_,\$(subst .,_,\$(1))) # Use recursive makes in order to ignore errors during check check-code-coverage: -\$(AM_V_at)\$(MAKE) \$(AM_MAKEFLAGS) -k check \$(AM_V_at)\$(MAKE) \$(AM_MAKEFLAGS) code-coverage-capture # Capture code coverage data code-coverage-capture: code-coverage-capture-hook \$(code_coverage_v_lcov_cap)\$(LCOV) \$(code_coverage_quiet) \$(addprefix --directory ,\$(CODE_COVERAGE_DIRECTORY)) --capture --output-file \"\$(CODE_COVERAGE_OUTPUT_FILE).tmp\" --test-name \"\$(call code_coverage_sanitize,\$(PACKAGE_NAME)-\$(PACKAGE_VERSION))\" --no-checksum --compat-libtool \$(CODE_COVERAGE_LCOV_SHOPTS) \$(CODE_COVERAGE_LCOV_OPTIONS) \$(code_coverage_v_lcov_ign)\$(LCOV) \$(code_coverage_quiet) \$(addprefix --directory ,\$(CODE_COVERAGE_DIRECTORY)) --remove \"\$(CODE_COVERAGE_OUTPUT_FILE).tmp\" \"/tmp/*\" \$(CODE_COVERAGE_IGNORE_PATTERN) --output-file \"\$(CODE_COVERAGE_OUTPUT_FILE)\" \$(CODE_COVERAGE_LCOV_SHOPTS) \$(CODE_COVERAGE_LCOV_RMOPTS) -@rm -f \"\$(CODE_COVERAGE_OUTPUT_FILE).tmp\" \$(code_coverage_v_genhtml)LANG=C \$(GENHTML) \$(code_coverage_quiet) \$(addprefix --prefix ,\$(CODE_COVERAGE_DIRECTORY)) --output-directory \"\$(CODE_COVERAGE_OUTPUT_DIRECTORY)\" --title \"\$(PACKAGE_NAME)-\$(PACKAGE_VERSION) Code Coverage\" --legend --show-details \"\$(CODE_COVERAGE_OUTPUT_FILE)\" \$(CODE_COVERAGE_GENHTML_OPTIONS) @echo \"file://\$(abs_builddir)/\$(CODE_COVERAGE_OUTPUT_DIRECTORY)/index.html\" code-coverage-clean: -\$(LCOV) --directory \$(top_builddir) -z -rm -rf \"\$(CODE_COVERAGE_OUTPUT_FILE)\" \"\$(CODE_COVERAGE_OUTPUT_FILE).tmp\" \"\$(CODE_COVERAGE_OUTPUT_DIRECTORY)\" -find . \\( -name \"*.gcda\" -o -name \"*.gcno\" -o -name \"*.gcov\" \\) -delete code-coverage-dist-clean: A][M_DISTCHECK_CONFIGURE_FLAGS := \$(A][M_DISTCHECK_CONFIGURE_FLAGS) --disable-code-coverage else # ifneq (\$(abs_builddir), \$(abs_top_builddir)) check-code-coverage: code-coverage-capture: code-coverage-capture-hook code-coverage-clean: code-coverage-dist-clean: endif # ifeq (\$(abs_builddir), \$(abs_top_builddir)) else #! CODE_COVERAGE_ENABLED # Use recursive makes in order to ignore errors during check check-code-coverage: @echo \"Need to reconfigure with --enable-code-coverage\" # Capture code coverage data code-coverage-capture: code-coverage-capture-hook @echo \"Need to reconfigure with --enable-code-coverage\" code-coverage-clean: code-coverage-dist-clean: endif #CODE_COVERAGE_ENABLED # Hook rule executed before code-coverage-capture, overridable by the user code-coverage-capture-hook: .PHONY: check-code-coverage code-coverage-capture code-coverage-dist-clean code-coverage-clean code-coverage-capture-hook ]) ]) AC_DEFUN([_AX_CODE_COVERAGE_ENABLED],[ AX_CHECK_GNU_MAKE([],[AC_MSG_ERROR([not using GNU make that is needed for coverage])]) AC_REQUIRE([AX_ADD_AM_MACRO_STATIC]) # check for gcov AC_CHECK_TOOL([GCOV], [$_AX_CODE_COVERAGE_GCOV_PROG_WITH], [:]) AS_IF([test "X$GCOV" = "X:"], [AC_MSG_ERROR([gcov is needed to do coverage])]) AC_SUBST([GCOV]) dnl Check if gcc is being used AS_IF([ test "$GCC" = "no" ], [ AC_MSG_ERROR([not compiling with gcc, which is required for gcov code coverage]) ]) AC_CHECK_PROG([LCOV], [lcov], [lcov]) AC_CHECK_PROG([GENHTML], [genhtml], [genhtml]) AS_IF([ test x"$LCOV" = x ], [ AC_MSG_ERROR([To enable code coverage reporting you must have lcov installed]) ]) AS_IF([ test x"$GENHTML" = x ], [ AC_MSG_ERROR([Could not find genhtml from the lcov package]) ]) dnl Build the code coverage flags dnl Define CODE_COVERAGE_LDFLAGS for backwards compatibility CODE_COVERAGE_CPPFLAGS="" CODE_COVERAGE_CFLAGS="-O0 -g -fprofile-arcs -ftest-coverage" CODE_COVERAGE_CXXFLAGS="-O0 -g -fprofile-arcs -ftest-coverage" CODE_COVERAGE_LIBS="-lgcov" AC_SUBST([CODE_COVERAGE_CPPFLAGS]) AC_SUBST([CODE_COVERAGE_CFLAGS]) AC_SUBST([CODE_COVERAGE_CXXFLAGS]) AC_SUBST([CODE_COVERAGE_LIBS]) ]) AC_DEFUN([AX_CODE_COVERAGE],[ dnl Check for --enable-code-coverage # allow to override gcov location AC_ARG_WITH([gcov], [AS_HELP_STRING([--with-gcov[=GCOV]], [use given GCOV for coverage (GCOV=gcov).])], [_AX_CODE_COVERAGE_GCOV_PROG_WITH=$with_gcov], [_AX_CODE_COVERAGE_GCOV_PROG_WITH=gcov]) AC_MSG_CHECKING([whether to build with code coverage support]) AC_ARG_ENABLE([code-coverage], AS_HELP_STRING([--enable-code-coverage], [Whether to enable code coverage support]),, enable_code_coverage=no) AM_CONDITIONAL([CODE_COVERAGE_ENABLED], [test "x$enable_code_coverage" = xyes]) AC_SUBST([CODE_COVERAGE_ENABLED], [$enable_code_coverage]) AC_MSG_RESULT($enable_code_coverage) AS_IF([ test "x$enable_code_coverage" = xyes ], [ _AX_CODE_COVERAGE_ENABLED ]) _AX_CODE_COVERAGE_RULES ])
M4 Macro
aircrack-ng/build/m4/ax_compare_version.m4
# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_compare_version.html # =========================================================================== # # SYNOPSIS # # AX_COMPARE_VERSION(VERSION_A, OP, VERSION_B, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) # # DESCRIPTION # # This macro compares two version strings. Due to the various number of # minor-version numbers that can exist, and the fact that string # comparisons are not compatible with numeric comparisons, this is not # necessarily trivial to do in a autoconf script. This macro makes doing # these comparisons easy. # # The six basic comparisons are available, as well as checking equality # limited to a certain number of minor-version levels. # # The operator OP determines what type of comparison to do, and can be one # of: # # eq - equal (test A == B) # ne - not equal (test A != B) # le - less than or equal (test A <= B) # ge - greater than or equal (test A >= B) # lt - less than (test A < B) # gt - greater than (test A > B) # # Additionally, the eq and ne operator can have a number after it to limit # the test to that number of minor versions. # # eq0 - equal up to the length of the shorter version # ne0 - not equal up to the length of the shorter version # eqN - equal up to N sub-version levels # neN - not equal up to N sub-version levels # # When the condition is true, shell commands ACTION-IF-TRUE are run, # otherwise shell commands ACTION-IF-FALSE are run. The environment # variable 'ax_compare_version' is always set to either 'true' or 'false' # as well. # # Examples: # # AX_COMPARE_VERSION([3.15.7],[lt],[3.15.8]) # AX_COMPARE_VERSION([3.15],[lt],[3.15.8]) # # would both be true. # # AX_COMPARE_VERSION([3.15.7],[eq],[3.15.8]) # AX_COMPARE_VERSION([3.15],[gt],[3.15.8]) # # would both be false. # # AX_COMPARE_VERSION([3.15.7],[eq2],[3.15.8]) # # would be true because it is only comparing two minor versions. # # AX_COMPARE_VERSION([3.15.7],[eq0],[3.15]) # # would be true because it is only comparing the lesser number of minor # versions of the two values. # # Note: The characters that separate the version numbers do not matter. An # empty string is the same as version 0. OP is evaluated by autoconf, not # configure, so must be a string, not a variable. # # The author would like to acknowledge Guido Draheim whose advice about # the m4_case and m4_ifvaln functions make this macro only include the # portions necessary to perform the specific comparison specified by the # OP argument in the final configure script. # # LICENSE # # Copyright (c) 2008 Tim Toolan <toolan@ele.uri.edu> # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 13 dnl ######################################################################### AC_DEFUN([AX_COMPARE_VERSION], [ AC_REQUIRE([AC_PROG_AWK]) # Used to indicate true or false condition ax_compare_version=false # Convert the two version strings to be compared into a format that # allows a simple string comparison. The end result is that a version # string of the form 1.12.5-r617 will be converted to the form # 0001001200050617. In other words, each number is zero padded to four # digits, and non digits are removed. AS_VAR_PUSHDEF([A],[ax_compare_version_A]) A=`echo "$1" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \ -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \ -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \ -e 's/[[^0-9]]//g'` AS_VAR_PUSHDEF([B],[ax_compare_version_B]) B=`echo "$3" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \ -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \ -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \ -e 's/[[^0-9]]//g'` dnl # In the case of le, ge, lt, and gt, the strings are sorted as necessary dnl # then the first line is used to determine if the condition is true. dnl # The sed right after the echo is to remove any indented white space m4_case(m4_tolower($2), [lt],[ ax_compare_version=`echo "x$A x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/false/;s/x${B}/true/;1q"` ], [gt],[ ax_compare_version=`echo "x$A x$B" | sed 's/^ *//' | sort | sed "s/x${A}/false/;s/x${B}/true/;1q"` ], [le],[ ax_compare_version=`echo "x$A x$B" | sed 's/^ *//' | sort | sed "s/x${A}/true/;s/x${B}/false/;1q"` ], [ge],[ ax_compare_version=`echo "x$A x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/true/;s/x${B}/false/;1q"` ],[ dnl Split the operator from the subversion count if present. m4_bmatch(m4_substr($2,2), [0],[ # A count of zero means use the length of the shorter version. # Determine the number of characters in A and B. ax_compare_version_len_A=`echo "$A" | $AWK '{print(length)}'` ax_compare_version_len_B=`echo "$B" | $AWK '{print(length)}'` # Set A to no more than B's length and B to no more than A's length. A=`echo "$A" | sed "s/\(.\{$ax_compare_version_len_B\}\).*/\1/"` B=`echo "$B" | sed "s/\(.\{$ax_compare_version_len_A\}\).*/\1/"` ], [[0-9]+],[ # A count greater than zero means use only that many subversions A=`echo "$A" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"` B=`echo "$B" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"` ], [.+],[ AC_WARNING( [invalid OP numeric parameter: $2]) ],[]) # Pad zeros at end of numbers to make same length. ax_compare_version_tmp_A="$A`echo $B | sed 's/./0/g'`" B="$B`echo $A | sed 's/./0/g'`" A="$ax_compare_version_tmp_A" # Check for equality or inequality as necessary. m4_case(m4_tolower(m4_substr($2,0,2)), [eq],[ test "x$A" = "x$B" && ax_compare_version=true ], [ne],[ test "x$A" != "x$B" && ax_compare_version=true ], [],[ ],[ AC_WARNING([invalid OP parameter: $2]) ]) ]) AS_VAR_POPDEF([A])dnl AS_VAR_POPDEF([B])dnl dnl # Execute ACTION-IF-TRUE / ACTION-IF-FALSE. if test "$ax_compare_version" = "true" ; then m4_ifvaln([$4],[$4],[:])dnl m4_ifvaln([$5],[else $5])dnl fi ]) dnl AX_COMPARE_VERSION
M4 Macro
aircrack-ng/build/m4/ax_compiler_vendor.m4
# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_compiler_vendor.html # =========================================================================== # # SYNOPSIS # # AX_COMPILER_VENDOR # # DESCRIPTION # # Determine the vendor of the C/C++ compiler, e.g., gnu, intel, ibm, sun, # hp, borland, comeau, dec, cray, kai, lcc, metrowerks, sgi, microsoft, # watcom, etc. The vendor is returned in the cache variable # $ax_cv_c_compiler_vendor for C and $ax_cv_cxx_compiler_vendor for C++. # # LICENSE # # Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu> # Copyright (c) 2008 Matteo Frigo # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation, either version 3 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see <https://www.gnu.org/licenses/>. # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 16 AC_DEFUN([AX_COMPILER_VENDOR], [AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor, dnl Please add if possible support to ax_compiler_version.m4 [# note: don't check for gcc first since some other compilers define __GNUC__ vendors="intel: __ICC,__ECC,__INTEL_COMPILER ibm: __xlc__,__xlC__,__IBMC__,__IBMCPP__ pathscale: __PATHCC__,__PATHSCALE__ clang: __clang__ cray: _CRAYC fujitsu: __FUJITSU gnu: __GNUC__ sun: __SUNPRO_C,__SUNPRO_CC hp: __HP_cc,__HP_aCC dec: __DECC,__DECCXX,__DECC_VER,__DECCXX_VER borland: __BORLANDC__,__CODEGEARC__,__TURBOC__ comeau: __COMO__ kai: __KCC lcc: __LCC__ sgi: __sgi,sgi microsoft: _MSC_VER metrowerks: __MWERKS__ watcom: __WATCOMC__ portland: __PGI tcc: __TINYC__ unknown: UNKNOWN" for ventest in $vendors; do case $ventest in *:) vendor=$ventest; continue ;; *) vencpp="defined("`echo $ventest | sed 's/,/) || defined(/g'`")" ;; esac AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ #if !($vencpp) thisisanerror; #endif ])], [break]) done ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=`echo $vendor | cut -d: -f1` ]) ])
M4 Macro
aircrack-ng/build/m4/ax_compiler_version.m4
# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_compiler_version.html # =========================================================================== # # SYNOPSIS # # AX_COMPILER_VERSION # # DESCRIPTION # # This macro retrieves the compiler version and returns it in the cache # variable $ax_cv_c_compiler_version for C and $ax_cv_cxx_compiler_version # for C++. # # Version is returned as epoch:major.minor.patchversion # # Epoch is used in order to have an increasing version number in case of # marketing change. # # Epoch use: * borland compiler use chronologically 0turboc for turboc # era, # # 1borlanc BORLANDC++ before 5, 2cppbuilder for cppbuilder era, # 3borlancpp for return of BORLANDC++ (after version 5.5), # 4cppbuilder for cppbuilder with year version, # and 5xe for XE era. # # An empty string is returned otherwise. # # LICENSE # # Copyright (c) 2014 Bastien ROUCARIES <roucaries.bastien+autoconf@gmail.com> # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 9 # for intel AC_DEFUN([_AX_COMPILER_VERSION_INTEL], [ dnl AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, [__INTEL_COMPILER/100],, AC_MSG_FAILURE([[[$0]] unknown intel compiler version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, [(__INTEL_COMPILER%100)/10],, AC_MSG_FAILURE([[[$0]] unknown intel compiler version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, [(__INTEL_COMPILER%10)],, AC_MSG_FAILURE([[[$0]] unknown intel compiler version])) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" ]) # for IBM AC_DEFUN([_AX_COMPILER_VERSION_IBM], [ dnl dnl check between z/OS C/C++ and XL C/C++ AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([], [ #if defined(__COMPILER_VER__) choke me; #endif ])], [ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, [__xlC__/100],, AC_MSG_FAILURE([[[$0]] unknown IBM compiler major version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, [__xlC__%100],, AC_MSG_FAILURE([[[$0]] unknown IBM compiler minor version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, [__xlC_ver__/0x100],, AC_MSG_FAILURE([[[$0]] unknown IBM compiler patch version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_build, [__xlC_ver__%0x100],, AC_MSG_FAILURE([[[$0]] unknown IBM compiler build version])) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_build" ], [ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, [__xlC__%1000],, AC_MSG_FAILURE([[[$0]] unknown IBM compiler patch version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, [(__xlC__/10000)%10],, AC_MSG_FAILURE([[[$0]] unknown IBM compiler minor version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, [(__xlC__/100000)%10],, AC_MSG_FAILURE([[[$0]] unknown IBM compiler major version])) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" ]) ]) # for pathscale AC_DEFUN([_AX_COMPILER_VERSION_PATHSCALE],[ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, __PATHCC__,, AC_MSG_FAILURE([[[$0]] unknown pathscale major])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, __PATHCC_MINOR__,, AC_MSG_FAILURE([[[$0]] unknown pathscale minor])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, [__PATHCC_PATCHLEVEL__],, AC_MSG_FAILURE([[[$0]] unknown pathscale patch level])) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" ]) # for clang AC_DEFUN([_AX_COMPILER_VERSION_CLANG],[ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, __clang_major__,, AC_MSG_FAILURE([[[$0]] unknown clang major])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, __clang_minor__,, AC_MSG_FAILURE([[[$0]] unknown clang minor])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, [__clang_patchlevel__],,0) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" ]) # for crayc AC_DEFUN([_AX_COMPILER_VERSION_CRAY],[ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, _RELEASE,, AC_MSG_FAILURE([[[$0]] unknown crayc release])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, _RELEASE_MINOR,, AC_MSG_FAILURE([[[$0]] unknown crayc minor])) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor" ]) # for fujitsu AC_DEFUN([_AX_COMPILER_VERSION_FUJITSU],[ AC_COMPUTE_INT(ax_cv_[]_AC_LANG_ABBREV[]_compiler_version, __FCC_VERSION,, AC_MSG_FAILURE([[[$0]]unknown fujitsu release])) ]) # for GNU AC_DEFUN([_AX_COMPILER_VERSION_GNU],[ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, __GNUC__,, AC_MSG_FAILURE([[[$0]] unknown gcc major])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, __GNUC_MINOR__,, AC_MSG_FAILURE([[[$0]] unknown gcc minor])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, [__GNUC_PATCHLEVEL__],, AC_MSG_FAILURE([[[$0]] unknown gcc patch level])) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" ]) # For sun AC_DEFUN([_AX_COMPILER_VERSION_SUN],[ m4_define([_AX_COMPILER_VERSION_SUN_NUMBER], [ #if defined(__SUNPRO_CC) __SUNPRO_CC #else __SUNPRO_C #endif ]) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_until59, !!(_AX_COMPILER_VERSION_SUN_NUMBER < 0x1000),, AC_MSG_FAILURE([[[$0]] unknown sun release version])) AS_IF([test "X$_ax_[]_AC_LANG_ABBREV[]_compiler_version_until59" = X1], [dnl AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, _AX_COMPILER_VERSION_SUN_NUMBER % 0x10,, AC_MSG_FAILURE([[[$0]] unknown sun patch version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, (_AX_COMPILER_VERSION_SUN_NUMBER / 0x10) % 0x10,, AC_MSG_FAILURE([[[$0]] unknown sun minor version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, (_AX_COMPILER_VERSION_SUN_NUMBER / 0x100),, AC_MSG_FAILURE([[[$0]] unknown sun major version])) ], [dnl AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, _AX_COMPILER_VERSION_SUN_NUMBER % 0x10,, AC_MSG_FAILURE([[[$0]] unknown sun patch version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, (_AX_COMPILER_VERSION_SUN_NUMBER / 0x100) % 0x100,, AC_MSG_FAILURE([[[$0]] unknown sun minor version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, (_AX_COMPILER_VERSION_SUN_NUMBER / 0x1000),, AC_MSG_FAILURE([[[$0]] unknown sun major version])) ]) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" ]) AC_DEFUN([_AX_COMPILER_VERSION_HP],[ m4_define([_AX_COMPILER_VERSION_HP_NUMBER], [ #if defined(__HP_cc) __HP_cc #else __HP_aCC #endif ]) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_untilA0121, !!(_AX_COMPILER_VERSION_HP_NUMBER <= 1),, AC_MSG_FAILURE([[[$0]] unknown hp release version])) AS_IF([test "X$_ax_[]_AC_LANG_ABBREV[]_compiler_version_untilA0121" = X1], [dnl By default output last version with this behavior. dnl it is so old ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="01.21.00" ], [dnl AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, (_AX_COMPILER_VERSION_HP_NUMBER % 100),, AC_MSG_FAILURE([[[$0]] unknown hp release version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, ((_AX_COMPILER_VERSION_HP_NUMBER / 100)%100),, AC_MSG_FAILURE([[[$0]] unknown hp minor version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, ((_AX_COMPILER_VERSION_HP_NUMBER / 10000)%100),, AC_MSG_FAILURE([[[$0]] unknown hp major version])) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" ]) ]) AC_DEFUN([_AX_COMPILER_VERSION_DEC],[dnl m4_define([_AX_COMPILER_VERSION_DEC_NUMBER], [ #if defined(__DECC_VER) __DECC_VER #else __DECCXX_VER #endif ]) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, (_AX_COMPILER_VERSION_DEC_NUMBER % 10000),, AC_MSG_FAILURE([[[$0]] unknown dec release version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, ((_AX_COMPILER_VERSION_DEC_NUMBER / 100000UL)%100),, AC_MSG_FAILURE([[[$0]] unknown dec minor version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, ((_AX_COMPILER_VERSION_DEC_NUMBER / 10000000UL)%100),, AC_MSG_FAILURE([[[$0]] unknown dec major version])) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" ]) # borland AC_DEFUN([_AX_COMPILER_VERSION_BORLAND],[dnl m4_define([_AX_COMPILER_VERSION_TURBOC_NUMBER], [ #if defined(__TURBOC__) __TURBOC__ #else choke me #endif ]) m4_define([_AX_COMPILER_VERSION_BORLANDC_NUMBER], [ #if defined(__BORLANDC__) __BORLANDC__ #else __CODEGEARC__ #endif ]) AC_COMPILE_IFELSE( [AC_LANG_PROGRAM(, _AX_COMPILER_VERSION_TURBOC_NUMBER)], [dnl TURBOC AC_COMPUTE_INT( _ax_[]_AC_LANG_ABBREV[]_compiler_version_turboc_raw, _AX_COMPILER_VERSION_TURBOC_NUMBER,, AC_MSG_FAILURE([[[$0]] unknown turboc version])) AS_IF( [test $_ax_[]_AC_LANG_ABBREV[]_compiler_version_turboc_raw -lt 661 || test $_ax_[]_AC_LANG_ABBREV[]_compiler_version_turboc_raw -gt 1023], [dnl compute normal version AC_COMPUTE_INT( _ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, _AX_COMPILER_VERSION_TURBOC_NUMBER % 0x100,, AC_MSG_FAILURE([[[$0]] unknown turboc minor version])) AC_COMPUTE_INT( _ax_[]_AC_LANG_ABBREV[]_compiler_version_major, (_AX_COMPILER_VERSION_TURBOC_NUMBER/0x100)%0x100,, AC_MSG_FAILURE([[[$0]] unknown turboc major version])) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="0turboc:$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor"], [dnl special version AS_CASE([$_ax_[]_AC_LANG_ABBREV[]_compiler_version_turboc_raw], [661],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="0turboc:1.00"], [662],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="0turboc:1.01"], [663],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="0turboc:2.00"], [ AC_MSG_WARN([[[$0]] unknown turboc version between 0x295 and 0x400 please report bug]) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="" ]) ]) ], # borlandc [ AC_COMPUTE_INT( _ax_[]_AC_LANG_ABBREV[]_compiler_version_borlandc_raw, _AX_COMPILER_VERSION_BORLANDC_NUMBER,, AC_MSG_FAILURE([[[$0]] unknown borlandc version])) AS_CASE([$_ax_[]_AC_LANG_ABBREV[]_compiler_version_borlandc_raw], dnl BORLANDC++ before 5.5 [512] ,[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:2.00"], [1024],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:3.00"], [1024],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:3.00"], [1040],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:3.1"], [1106],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:4.0"], [1280],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:5.0"], [1312],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:5.02"], dnl C++ Builder era [1328],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="2cppbuilder:3.0"], [1344],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="2cppbuilder:4.0"], dnl BORLANDC++ after 5.5 [1360],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="3borlancpp:5.5"], [1361],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="3borlancpp:5.51"], [1378],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="3borlancpp:5.6.4"], dnl C++ Builder with year number [1392],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="4cppbuilder:2006"], [1424],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="4cppbuilder:2007"], [1555],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="4cppbuilder:2009"], [1569],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="4cppbuilder:2010"], dnl XE version [1584],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="5xe"], [1600],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="5xe:2"], [1616],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="5xe:3"], [1632],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="5xe:4"], [ AC_MSG_WARN([[[$0]] Unknown borlandc compiler version $_ax_[]_AC_LANG_ABBREV[]_compiler_version_borlandc_raw please report bug]) ]) ]) ]) # COMO AC_DEFUN([_AX_COMPILER_VERSION_COMEAU], [ dnl AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, [__COMO_VERSION__%100],, AC_MSG_FAILURE([[[$0]] unknown comeau compiler minor version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, [(__COMO_VERSION__/100)%10],, AC_MSG_FAILURE([[[$0]] unknown comeau compiler major version])) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor" ]) # KAI AC_DEFUN([_AX_COMPILER_VERSION_KAI],[ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, [__KCC_VERSION%100],, AC_MSG_FAILURE([[[$0]] unknown kay compiler patch version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, [(__KCC_VERSION/100)%10],, AC_MSG_FAILURE([[[$0]] unknown kay compiler minor version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, [(__KCC_VERSION/1000)%10],, AC_MSG_FAILURE([[[$0]] unknown kay compiler major version])) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" ]) dnl LCC dnl LCC does not output version... # SGI AC_DEFUN([_AX_COMPILER_VERSION_SGI],[ m4_define([_AX_COMPILER_VERSION_SGI_NUMBER], [ #if defined(_COMPILER_VERSION) _COMPILER_VERSION #else _SGI_COMPILER_VERSION #endif ]) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, [_AX_COMPILER_VERSION_SGI_NUMBER%10],, AC_MSG_FAILURE([[[$0]] unknown SGI compiler patch version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, [(_AX_COMPILER_VERSION_SGI_NUMBER/10)%10],, AC_MSG_FAILURE([[[$0]] unknown SGI compiler minor version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, [(_AX_COMPILER_VERSION_SGI_NUMBER/100)%10],, AC_MSG_FAILURE([[[$0]] unknown SGI compiler major version])) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" ]) # microsoft AC_DEFUN([_AX_COMPILER_VERSION_MICROSOFT],[ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, _MSC_VER%100,, AC_MSG_FAILURE([[[$0]] unknown microsoft compiler minor version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, (_MSC_VER/100)%100,, AC_MSG_FAILURE([[[$0]] unknown microsoft compiler major version])) dnl could be overridden _ax_[]_AC_LANG_ABBREV[]_compiler_version_patch=0 _ax_[]_AC_LANG_ABBREV[]_compiler_version_build=0 # special case for version 6 AS_IF([test "X$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major" = "X12"], [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, _MSC_FULL_VER%1000,, _ax_[]_AC_LANG_ABBREV[]_compiler_version_patch=0)]) # for version 7 AS_IF([test "X$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major" = "X13"], [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, _MSC_FULL_VER%1000,, AC_MSG_FAILURE([[[$0]] unknown microsoft compiler patch version])) ]) # for version > 8 AS_IF([test $_ax_[]_AC_LANG_ABBREV[]_compiler_version_major -ge 14], [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, _MSC_FULL_VER%10000,, AC_MSG_FAILURE([[[$0]] unknown microsoft compiler patch version])) ]) AS_IF([test $_ax_[]_AC_LANG_ABBREV[]_compiler_version_major -ge 15], [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_build, _MSC_BUILD,, AC_MSG_FAILURE([[[$0]] unknown microsoft compiler build version])) ]) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_build" ]) # for metrowerks AC_DEFUN([_AX_COMPILER_VERSION_METROWERKS],[dnl AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, __MWERKS__%0x100,, AC_MSG_FAILURE([[[$0]] unknown metrowerks compiler patch version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, (__MWERKS__/0x100)%0x10,, AC_MSG_FAILURE([[[$0]] unknown metrowerks compiler minor version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, (__MWERKS__/0x1000)%0x10,, AC_MSG_FAILURE([[[$0]] unknown metrowerks compiler major version])) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" ]) # for watcom AC_DEFUN([_AX_COMPILER_VERSION_WATCOM],[dnl AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, __WATCOMC__%100,, AC_MSG_FAILURE([[[$0]] unknown watcom compiler minor version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, (__WATCOMC__/100)%100,, AC_MSG_FAILURE([[[$0]] unknown watcom compiler major version])) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor" ]) # for PGI AC_DEFUN([_AX_COMPILER_VERSION_PORTLAND],[ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, __PGIC__,, AC_MSG_FAILURE([[[$0]] unknown pgi major])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, __PGIC_MINOR__,, AC_MSG_FAILURE([[[$0]] unknown pgi minor])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, [__PGIC_PATCHLEVEL__],, AC_MSG_FAILURE([[[$0]] unknown pgi patch level])) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" ]) # tcc AC_DEFUN([_AX_COMPILER_VERSION_TCC],[ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version=[`tcc -v | $SED 's/^[ ]*tcc[ ]\+version[ ]\+\([0-9.]\+\).*/\1/g'`] ]) # main entry point AC_DEFUN([AX_COMPILER_VERSION],[dnl AC_REQUIRE([AX_COMPILER_VENDOR]) AC_REQUIRE([AC_PROG_SED]) AC_CACHE_CHECK([for _AC_LANG compiler version], ax_cv_[]_AC_LANG_ABBREV[]_compiler_version, [ dnl AS_CASE([$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor], [intel],[_AX_COMPILER_VERSION_INTEL], [ibm],[_AX_COMPILER_VERSION_IBM], [pathscale],[_AX_COMPILER_VERSION_PATHSCALE], [clang],[_AX_COMPILER_VERSION_CLANG], [cray],[_AX_COMPILER_VERSION_CRAY], [fujitsu],[_AX_COMPILER_VERSION_FUJITSU], [gnu],[_AX_COMPILER_VERSION_GNU], [sun],[_AX_COMPILER_VERSION_SUN], [hp],[_AX_COMPILER_VERSION_HP], [dec],[_AX_COMPILER_VERSION_DEC], [borland],[_AX_COMPILER_VERSION_BORLAND], [comeau],[_AX_COMPILER_VERSION_COMEAU], [kai],[_AX_COMPILER_VERSION_KAI], [sgi],[_AX_COMPILER_VERSION_SGI], [microsoft],[_AX_COMPILER_VERSION_MICROSOFT], [metrowerks],[_AX_COMPILER_VERSION_METROWERKS], [watcom],[_AX_COMPILER_VERSION_WATCOM], [portland],[_AX_COMPILER_VERSION_PORTLAND], [tcc],[_AX_COMPILER_VERSION_TCC], [ax_cv_[]_AC_LANG_ABBREV[]_compiler_version=""]) ]) ])
M4 Macro
aircrack-ng/build/m4/ax_cxx_compile_stdcxx.m4
# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html # =========================================================================== # # SYNOPSIS # # AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional]) # # DESCRIPTION # # Check for baseline language coverage in the compiler for the specified # version of the C++ standard. If necessary, add switches to CXX and # CXXCPP to enable support. VERSION may be '11' (for the C++11 standard) # or '14' (for the C++14 standard). # # The second argument, if specified, indicates whether you insist on an # extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. # -std=c++11). If neither is specified, you get whatever works, with # preference for an extended mode. # # The third argument, if specified 'mandatory' or if left unspecified, # indicates that baseline support for the specified C++ standard is # required and that the macro should error out if no mode with that # support is found. If specified 'optional', then configuration proceeds # regardless, after defining HAVE_CXX${VERSION} if and only if a # supporting mode is found. # # LICENSE # # Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com> # Copyright (c) 2012 Zack Weinberg <zackw@panix.com> # Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu> # Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com> # Copyright (c) 2015 Paul Norman <penorman@mac.com> # Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu> # Copyright (c) 2016, 2018 Krzesimir Nowak <qdlacz@gmail.com> # Copyright (c) 2019 Enji Cooper <yaneurabeya@gmail.com> # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 11 dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro dnl (serial version number 13). AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"], [$1], [14], [ax_cxx_compile_alternatives="14 1y"], [$1], [17], [ax_cxx_compile_alternatives="17 1z"], [m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl m4_if([$2], [], [], [$2], [ext], [], [$2], [noext], [], [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX])])dnl m4_if([$3], [], [ax_cxx_compile_cxx$1_required=true], [$3], [mandatory], [ax_cxx_compile_cxx$1_required=true], [$3], [optional], [ax_cxx_compile_cxx$1_required=false], [m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])]) AC_LANG_PUSH([C++])dnl ac_success=no m4_if([$2], [noext], [], [dnl if test x$ac_success = xno; then for alternative in ${ax_cxx_compile_alternatives}; do switch="-std=gnu++${alternative}" cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, $cachevar, [ac_save_CXX="$CXX" CXX="$CXX $switch" AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], [eval $cachevar=yes], [eval $cachevar=no]) CXX="$ac_save_CXX"]) if eval test x\$$cachevar = xyes; then CXX="$CXX $switch" if test -n "$CXXCPP" ; then CXXCPP="$CXXCPP $switch" fi ac_success=yes break fi done fi]) m4_if([$2], [ext], [], [dnl if test x$ac_success = xno; then dnl HP's aCC needs +std=c++11 according to: dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf dnl Cray's crayCC needs "-h std=c++11" for alternative in ${ax_cxx_compile_alternatives}; do for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, $cachevar, [ac_save_CXX="$CXX" CXX="$CXX $switch" AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], [eval $cachevar=yes], [eval $cachevar=no]) CXX="$ac_save_CXX"]) if eval test x\$$cachevar = xyes; then CXX="$CXX $switch" if test -n "$CXXCPP" ; then CXXCPP="$CXXCPP $switch" fi ac_success=yes break fi done if test x$ac_success = xyes; then break fi done fi]) AC_LANG_POP([C++]) if test x$ax_cxx_compile_cxx$1_required = xtrue; then if test x$ac_success = xno; then AC_MSG_ERROR([*** A compiler with support for C++$1 language features is required.]) fi fi if test x$ac_success = xno; then HAVE_CXX$1=0 AC_MSG_NOTICE([No compiler with C++$1 support was found]) else HAVE_CXX$1=1 AC_DEFINE(HAVE_CXX$1,1, [define if the compiler supports basic C++$1 syntax]) fi AC_SUBST(HAVE_CXX$1) ]) dnl Test body for checking C++11 support m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11], _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 ) dnl Test body for checking C++14 support m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14], _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 ) m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17], _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 _AX_CXX_COMPILE_STDCXX_testbody_new_in_17 ) dnl Tests for new features in C++11 m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[ // If the compiler admits that it is not ready for C++11, why torture it? // Hopefully, this will speed up the test. #ifndef __cplusplus #error "This is not a C++ compiler" #elif __cplusplus < 201103L #error "This is not a C++11 compiler" #else namespace cxx11 { namespace test_static_assert { template <typename T> struct check { static_assert(sizeof(int) <= sizeof(T), "not big enough"); }; } namespace test_final_override { struct Base { virtual ~Base() {} virtual void f() {} }; struct Derived : public Base { virtual ~Derived() override {} virtual void f() override {} }; } namespace test_double_right_angle_brackets { template < typename T > struct check {}; typedef check<void> single_type; typedef check<check<void>> double_type; typedef check<check<check<void>>> triple_type; typedef check<check<check<check<void>>>> quadruple_type; } namespace test_decltype { int f() { int a = 1; decltype(a) b = 2; return a + b; } } namespace test_type_deduction { template < typename T1, typename T2 > struct is_same { static const bool value = false; }; template < typename T > struct is_same<T, T> { static const bool value = true; }; template < typename T1, typename T2 > auto add(T1 a1, T2 a2) -> decltype(a1 + a2) { return a1 + a2; } int test(const int c, volatile int v) { static_assert(is_same<int, decltype(0)>::value == true, ""); static_assert(is_same<int, decltype(c)>::value == false, ""); static_assert(is_same<int, decltype(v)>::value == false, ""); auto ac = c; auto av = v; auto sumi = ac + av + 'x'; auto sumf = ac + av + 1.0; static_assert(is_same<int, decltype(ac)>::value == true, ""); static_assert(is_same<int, decltype(av)>::value == true, ""); static_assert(is_same<int, decltype(sumi)>::value == true, ""); static_assert(is_same<int, decltype(sumf)>::value == false, ""); static_assert(is_same<int, decltype(add(c, v))>::value == true, ""); return (sumf > 0.0) ? sumi : add(c, v); } } namespace test_noexcept { int f() { return 0; } int g() noexcept { return 0; } static_assert(noexcept(f()) == false, ""); static_assert(noexcept(g()) == true, ""); } namespace test_constexpr { template < typename CharT > unsigned long constexpr strlen_c_r(const CharT *const s, const unsigned long acc) noexcept { return *s ? strlen_c_r(s + 1, acc + 1) : acc; } template < typename CharT > unsigned long constexpr strlen_c(const CharT *const s) noexcept { return strlen_c_r(s, 0UL); } static_assert(strlen_c("") == 0UL, ""); static_assert(strlen_c("1") == 1UL, ""); static_assert(strlen_c("example") == 7UL, ""); static_assert(strlen_c("another\0example") == 7UL, ""); } namespace test_rvalue_references { template < int N > struct answer { static constexpr int value = N; }; answer<1> f(int&) { return answer<1>(); } answer<2> f(const int&) { return answer<2>(); } answer<3> f(int&&) { return answer<3>(); } void test() { int i = 0; const int c = 0; static_assert(decltype(f(i))::value == 1, ""); static_assert(decltype(f(c))::value == 2, ""); static_assert(decltype(f(0))::value == 3, ""); } } namespace test_uniform_initialization { struct test { static const int zero {}; static const int one {1}; }; static_assert(test::zero == 0, ""); static_assert(test::one == 1, ""); } namespace test_lambdas { void test1() { auto lambda1 = [](){}; auto lambda2 = lambda1; lambda1(); lambda2(); } int test2() { auto a = [](int i, int j){ return i + j; }(1, 2); auto b = []() -> int { return '0'; }(); auto c = [=](){ return a + b; }(); auto d = [&](){ return c; }(); auto e = [a, &b](int x) mutable { const auto identity = [](int y){ return y; }; for (auto i = 0; i < a; ++i) a += b--; return x + identity(a + b); }(0); return a + b + c + d + e; } int test3() { const auto nullary = [](){ return 0; }; const auto unary = [](int x){ return x; }; using nullary_t = decltype(nullary); using unary_t = decltype(unary); const auto higher1st = [](nullary_t f){ return f(); }; const auto higher2nd = [unary](nullary_t f1){ return [unary, f1](unary_t f2){ return f2(unary(f1())); }; }; return higher1st(nullary) + higher2nd(nullary)(unary); } } namespace test_variadic_templates { template <int...> struct sum; template <int N0, int... N1toN> struct sum<N0, N1toN...> { static constexpr auto value = N0 + sum<N1toN...>::value; }; template <> struct sum<> { static constexpr auto value = 0; }; static_assert(sum<>::value == 0, ""); static_assert(sum<1>::value == 1, ""); static_assert(sum<23>::value == 23, ""); static_assert(sum<1, 2>::value == 3, ""); static_assert(sum<5, 5, 11>::value == 21, ""); static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, ""); } // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function // because of this. namespace test_template_alias_sfinae { struct foo {}; template<typename T> using member = typename T::member_type; template<typename T> void func(...) {} template<typename T> void func(member<T>*) {} void test(); void test() { func<foo>(0); } } } // namespace cxx11 #endif // __cplusplus >= 201103L ]]) dnl Tests for new features in C++14 m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[ // If the compiler admits that it is not ready for C++14, why torture it? // Hopefully, this will speed up the test. #ifndef __cplusplus #error "This is not a C++ compiler" #elif __cplusplus < 201402L #error "This is not a C++14 compiler" #else namespace cxx14 { namespace test_polymorphic_lambdas { int test() { const auto lambda = [](auto&&... args){ const auto istiny = [](auto x){ return (sizeof(x) == 1UL) ? 1 : 0; }; const int aretiny[] = { istiny(args)... }; return aretiny[0]; }; return lambda(1, 1L, 1.0f, '1'); } } namespace test_binary_literals { constexpr auto ivii = 0b0000000000101010; static_assert(ivii == 42, "wrong value"); } namespace test_generalized_constexpr { template < typename CharT > constexpr unsigned long strlen_c(const CharT *const s) noexcept { auto length = 0UL; for (auto p = s; *p; ++p) ++length; return length; } static_assert(strlen_c("") == 0UL, ""); static_assert(strlen_c("x") == 1UL, ""); static_assert(strlen_c("test") == 4UL, ""); static_assert(strlen_c("another\0test") == 7UL, ""); } namespace test_lambda_init_capture { int test() { auto x = 0; const auto lambda1 = [a = x](int b){ return a + b; }; const auto lambda2 = [a = lambda1(x)](){ return a; }; return lambda2(); } } namespace test_digit_separators { constexpr auto ten_million = 100'000'000; static_assert(ten_million == 100000000, ""); } namespace test_return_type_deduction { auto f(int& x) { return x; } decltype(auto) g(int& x) { return x; } template < typename T1, typename T2 > struct is_same { static constexpr auto value = false; }; template < typename T > struct is_same<T, T> { static constexpr auto value = true; }; int test() { auto x = 0; static_assert(is_same<int, decltype(f(x))>::value, ""); static_assert(is_same<int&, decltype(g(x))>::value, ""); return x; } } } // namespace cxx14 #endif // __cplusplus >= 201402L ]]) dnl Tests for new features in C++17 m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[ // If the compiler admits that it is not ready for C++17, why torture it? // Hopefully, this will speed up the test. #ifndef __cplusplus #error "This is not a C++ compiler" #elif __cplusplus < 201703L #error "This is not a C++17 compiler" #else #include <initializer_list> #include <utility> #include <type_traits> namespace cxx17 { namespace test_constexpr_lambdas { constexpr int foo = [](){return 42;}(); } namespace test::nested_namespace::definitions { } namespace test_fold_expression { template<typename... Args> int multiply(Args... args) { return (args * ... * 1); } template<typename... Args> bool all(Args... args) { return (args && ...); } } namespace test_extended_static_assert { static_assert (true); } namespace test_auto_brace_init_list { auto foo = {5}; auto bar {5}; static_assert(std::is_same<std::initializer_list<int>, decltype(foo)>::value); static_assert(std::is_same<int, decltype(bar)>::value); } namespace test_typename_in_template_template_parameter { template<template<typename> typename X> struct D; } namespace test_fallthrough_nodiscard_maybe_unused_attributes { int f1() { return 42; } [[nodiscard]] int f2() { [[maybe_unused]] auto unused = f1(); switch (f1()) { case 17: f1(); [[fallthrough]]; case 42: f1(); } return f1(); } } namespace test_extended_aggregate_initialization { struct base1 { int b1, b2 = 42; }; struct base2 { base2() { b3 = 42; } int b3; }; struct derived : base1, base2 { int d; }; derived d1 {{1, 2}, {}, 4}; // full initialization derived d2 {{}, {}, 4}; // value-initialized bases } namespace test_general_range_based_for_loop { struct iter { int i; int& operator* () { return i; } const int& operator* () const { return i; } iter& operator++() { ++i; return *this; } }; struct sentinel { int i; }; bool operator== (const iter& i, const sentinel& s) { return i.i == s.i; } bool operator!= (const iter& i, const sentinel& s) { return !(i == s); } struct range { iter begin() const { return {0}; } sentinel end() const { return {5}; } }; void f() { range r {}; for (auto i : r) { [[maybe_unused]] auto v = i; } } } namespace test_lambda_capture_asterisk_this_by_value { struct t { int i; int foo() { return [*this]() { return i; }(); } }; } namespace test_enum_class_construction { enum class byte : unsigned char {}; byte foo {42}; } namespace test_constexpr_if { template <bool cond> int f () { if constexpr(cond) { return 13; } else { return 42; } } } namespace test_selection_statement_with_initializer { int f() { return 13; } int f2() { if (auto i = f(); i > 0) { return 3; } switch (auto i = f(); i + 4) { case 17: return 2; default: return 1; } } } namespace test_template_argument_deduction_for_class_templates { template <typename T1, typename T2> struct pair { pair (T1 p1, T2 p2) : m1 {p1}, m2 {p2} {} T1 m1; T2 m2; }; void f() { [[maybe_unused]] auto p = pair{13, 42u}; } } namespace test_non_type_auto_template_parameters { template <auto n> struct B {}; B<5> b1; B<'a'> b2; } namespace test_structured_bindings { int arr[2] = { 1, 2 }; std::pair<int, int> pr = { 1, 2 }; auto f1() -> int(&)[2] { return arr; } auto f2() -> std::pair<int, int>& { return pr; } struct S { int x1 : 2; volatile double y1; }; S f3() { return {}; } auto [ x1, y1 ] = f1(); auto& [ xr1, yr1 ] = f1(); auto [ x2, y2 ] = f2(); auto& [ xr2, yr2 ] = f2(); const auto [ x3, y3 ] = f3(); } namespace test_exception_spec_type_system { struct Good {}; struct Bad {}; void g1() noexcept; void g2(); template<typename T> Bad f(T*, T*); template<typename T1, typename T2> Good f(T1*, T2*); static_assert (std::is_same_v<Good, decltype(f(g1, g2))>); } namespace test_inline_variables { template<class T> void f(T) {} template<class T> inline T g(T) { return T{}; } template<> inline void f<>(int) {} template<> int g<>(int) { return 5; } } } // namespace cxx17 #endif // __cplusplus < 201703L ]])
M4 Macro
aircrack-ng/build/m4/ax_ext_have_static_lib.m4
# =========================================================================== # # SYNOPSIS # # AX_EXT_HAVE_STATIC_LIB(VARIABLE-PREFIX, SEARCH-PATHS, LIBRARY-NAMES, # FUNCTION-NAME, [EXTRA-LIBRARIES]) # # DESCRIPTION # # Provides a generic test for locating an appropriate static library # to force link against, even when one's application is dynamically # linked. The macro was inspired by the PKG_CHECK_MODULES macro. # # If the library is found, [VARIABLE-PREFIX]_FOUND is defined, and # in all cases [VARIABLE-PREFIX]_LIBS is substituted. # # Example: # # AX_EXT_HAVE_STATIC_LIB_DETECT # AX_EXT_HAVE_STATIC_LIB(ZLIB, [${DEFAULT_STATIC_LIB_SEARCH_PATHS}], # z libz, compress) # # LICENSE # # Copyright (c) 2018 Joseph Benden <joe@benden.us> # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation, either version 3 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see <https://www.gnu.org/licenses/>. # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 1 AC_DEFUN([AX_EXT_HAVE_STATIC_LIB_DETECT], [ AC_REQUIRE([AC_CANONICAL_HOST]) AC_ARG_VAR([STATIC_HOST_ALIAS], [The alias name for host, default @<:@HOST@:>@.])dnl AC_ARG_VAR([STATIC_LIBDIR_NAME], [The libdir name for host, default @<:@lib@:>@.])dnl AC_CACHE_VAL([ext_cv_static_libdir_name], [ ext_cv_static_libdir_name="${STATIC_LIBDIR_NAME:-lib}" ]) AC_CACHE_VAL([ext_cv_default_static_lib_search_paths], [ AC_MSG_CHECKING([Default static library search path]) static_extpath="" if test -n "${STATIC_HOST_ALIAS}" then static_host="${STATIC_HOST_ALIAS}" else if test "${GCC}" = "yes" then static_host=`${CC} -dumpmachine 2>/dev/null` static_extpath=`${CC} -print-search-dirs 2> /dev/null | grep '^libraries' | sed -e 's/@<:@^=@:>@*=//' -e 's/:/ /g'` else static_host="${host}" fi fi ext_cv_default_static_lib_search_paths=" \ ${static_extpath} \ /opt/${ext_cv_static_libdir_name}/${static_host} \ /opt/${ext_cv_static_libdir_name} \ /usr/local/${ext_cv_static_libdir_name}/${static_host} \ /usr/local/${ext_cv_static_libdir_name} \ /usr/${ext_cv_static_libdir_name}/${static_host} \ /usr/${ext_cv_static_libdir_name} \ /${ext_cv_static_libdir_name} \ /opt/lib/${static_host} \ /opt/lib \ " AC_MSG_RESULT([${ext_cv_default_static_lib_search_paths}]) ]) DEFAULT_STATIC_LIB_SEARCH_PATHS="${ext_cv_default_static_lib_search_paths}" STATIC_LIBDIR_NAME="${ext_cv_static_libdir_name}" ]) AC_DEFUN([AX_EXT_HAVE_STATIC_LIB], [ AC_ARG_VAR([$1][_FOUND], [set if the static library $1 is available, already.])dnl AC_ARG_VAR([$1][_LIBS], [static library linker flags for $1.])dnl for dir in m4_normalize($2) do ext_haslib_cvdir=`echo $dir | $as_tr_sh` ext_haslib_cvname=`echo $3 | $as_tr_sh` AC_CACHE_VAL([ext_cv${ext_haslib_cvdir}_haslib_${ext_haslib_cvname}], [ for name in $3 do dnl Does an archive file exists in our current path? AC_CHECK_FILE("${dir}/${name}.a", [ dnl If so, can we link a simple program with it? ext_func_search_save_LIBS=$LIBS ext_func_save_ldflags=${LDFLAGS} LIBS="${dir}/${name}.a $5 ${ext_func_search_save_LIBS}" LDFLAGS="${ext_func_save_ldflags}" AC_LINK_IFELSE([AC_LANG_CALL([], [$4])], [ eval "ext_cv${ext_haslib_cvdir}_haslib_${ext_haslib_cvname}"="${dir}/${name}.a" AC_MSG_NOTICE([Found static library: ${dir}/${name}.a]) ], [ eval "ext_cv${ext_haslib_cvdir}_haslib_${ext_haslib_cvname}"="" ]) LIBS=$ext_func_search_save_LIBS LDFLAGS=$ext_func_save_ldflags ]) done ]) if eval `echo 'test x${'ext_cv${ext_haslib_cvdir}_haslib_${ext_haslib_cvname}'}' != "x"`; then $1[]_LIBS="`eval echo '\${'ext_cv${ext_haslib_cvdir}_haslib_${ext_haslib_cvname}'}'`" $1[]_FOUND=yes ext_lib_found="yes" AC_SUBST($1[]_LIBS) AC_SUBST($1[]_FOUND) fi done ])
M4 Macro
aircrack-ng/build/m4/ax_file_escapes.m4
# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_file_escapes.html # =========================================================================== # # SYNOPSIS # # AX_FILE_ESCAPES # # DESCRIPTION # # Writes the specified data to the specified file. # # LICENSE # # Copyright (c) 2008 Tom Howard <tomhoward@users.sf.net> # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 8 AC_DEFUN([AX_FILE_ESCAPES],[ AX_DOLLAR="\$" AX_SRB="\\135" AX_SLB="\\133" AX_BS="\\\\" AX_DQ="\"" ])
M4 Macro
aircrack-ng/build/m4/ax_gcc_x86_cpu_supports.m4
# ============================================================================ # https://www.gnu.org/software/autoconf-archive/ax_gcc_x86_cpu_supports.html # ============================================================================ # # SYNOPSIS # # AX_GCC_X86_CPU_SUPPORTS(X86-INSTRUCTION-SET, # [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND]) # # DESCRIPTION # # Checks if the host cpu supports X86-INSTRUCTION-SET. The instruction set # that can be tested are "mmx, popcnt, sse, sse2, sse3, sse4.1, sse4.2, # sse4a, avx, avx2, avx512f, fma, fma4, bmi, bmi2". If the instruction set # is supported by the host cpu, the C preprocessor macro # HAVE_XXX_INSTRUCTIONS is set to 1. The XXX is up-cased instruction case # with dot replaced by underscore. For example, the test for "sse4.2" # would export HAVE_SSE4_2_INSTRUCTIONS=1. This macro requires gcc # extended builtin function "__builtin_cpu_init" and # "__builtin_cpu_supports" to detect the cpu features. It will error out # if the compiler doesn't has these builtins. # # If the test for the instruction set succeeded, the hook ACTION-IF-FOUND # would run. Otherwise the hook ACTION-IF-NOT-FOUND would run if # specified. # # See also AX_CHECK_X86_FEATURES, which checks all the possible # instruction set and export the corresponding CFLAGS. # # LICENSE # # Copyright (c) 2016 Felix Chern <idryman@gmail.com> # Copyright (c) 2017 Joseph Benden <joe@benden.us> # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see <https://www.gnu.org/licenses/>. # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 4 AC_DEFUN_ONCE([_AX_GCC_X86_CPU_INIT], [AC_LANG_PUSH([C]) AC_CACHE_CHECK([for gcc __builtin_cpu_init function], [ax_cv_gcc_check_x86_cpu_init], [AC_RUN_IFELSE( [AC_LANG_PROGRAM([#include <stdlib.h>], [__builtin_cpu_init ();]) ], [ax_cv_gcc_check_x86_cpu_init=yes], [ax_cv_gcc_check_x86_cpu_init=no],[ax_cv_gcc_check_x86_cpu_init=no])]) ]) AC_DEFUN([AX_GCC_X86_CPU_SUPPORTS], [AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([_AX_GCC_X86_CPU_INIT]) AC_LANG_PUSH([C]) AS_VAR_PUSHDEF([gcc_x86_feature], [AS_TR_SH([ax_cv_gcc_x86_cpu_supports_$1])]) AC_CACHE_CHECK([for x86 $1 instruction support], [gcc_x86_feature], [AC_RUN_IFELSE( [AC_LANG_PROGRAM([ #include <stdlib.h> #if defined(__INTEL_COMPILER) #include <immintrin.h> #endif ],[ #if defined(__INTEL_COMPILER) int result = 0; if (!strcmp("$1", "avx2")) result = _may_i_use_cpu_feature(_FEATURE_AVX2); else if (!strcmp("$1", "avx")) result = _may_i_use_cpu_feature(_FEATURE_AVX); else if (!strcmp("$1", "sse2")) result = _may_i_use_cpu_feature(_FEATURE_SSE2); else if (!strcmp("$1", "mmx")) result = _may_i_use_cpu_feature(_FEATURE_MMX); return result ? 0 : 1; #else #if defined(__GNUC__) && !defined(__clang__) __builtin_cpu_init (); #endif if (__builtin_cpu_supports("$1")) return 0; return 1; #endif ])], [gcc_x86_feature=yes], [gcc_x86_feature=no], [gcc_x86_feature=no] )] ) AC_LANG_POP([C]) AS_VAR_IF([gcc_x86_feature],[yes], [AC_DEFINE( AS_TR_CPP([HAVE_$1_INSTRUCTIONS]), [1], [Define if $1 instructions are supported]) $2], [$3] ) AS_VAR_POPDEF([gcc_x86_feature]) ])
M4 Macro
aircrack-ng/build/m4/ax_lib_gcrypt.m4
# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_lib_gcrypt.html # =========================================================================== # # SYNOPSIS # # AX_LIB_GCRYPT([yes|no|auto]) # # DESCRIPTION # # Searches for the 'gcrypt' library with the --with... option. # # If found, define HAVE_GCRYPT and macro GCRYPT_LIBS and GCRYPT_CFLAGS. # Also defines GCRYPT_WITH_<algo> for the algorithms found available. # Possible algorithms are: AES ARCFOUR BLOWFISH CAST5 DES IDEA RFC2268 # SERPENT TWOFISH CRC HAVAL MD2 MD4 MD5 RMD160 SHA0 SHA1 SHA224 SHA256 # SHA384 SHA512 TIGER WHIRLPOOL DSA ELGAMAL RSA # # The argument is used if no --with...-gcrypt option is set. Value "yes" # requires the configuration by default. Value "no" does not require it by # default. Value "auto" configures the library only if available. # # See also AX_LIB_BEECRYPT and AX_LIB_CRYPTO. # # LICENSE # # Copyright (c) 2009 Fabien Coelho <autoconf.archive@coelho.net> # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 12 # AX_CHECK_GCRYPT_ALGO([algo]) # generate convenient defines for each algorithm AC_DEFUN([AX_CHECK_GCRYPT_ALGO],[ AC_REQUIRE([AC_PROG_EGREP]) AC_MSG_CHECKING([for $1 in gcrypt]) if echo $gcrypt_algos | $EGREP -i ":.*( $1 | $1$)" > /dev/null ; then AC_DEFINE([GCRYPT_WITH_$1],[1],[Algorithm $1 in gcrypt library]) AC_SUBST([GCRYPT_WITH_$1], [1]) AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi ]) # AX_LIB_GCRYPT([yes|no|auto]) AC_DEFUN([AX_LIB_GCRYPT],[ AC_MSG_CHECKING([whether gcrypt is enabled]) AC_ARG_WITH([gcrypt],[ --with-gcrypt require gcrypt library --without-gcrypt disable gcrypt library],[ AC_MSG_RESULT([$withval]) ac_with_gcrypt=$withval ],[ AC_MSG_RESULT($1) ac_with_gcrypt=$1 ]) if test "$ac_with_gcrypt" = "yes" -o "$ac_with_gcrypt" = "auto" ; then AM_PATH_LIBGCRYPT([1.2.0],[ AC_DEFINE([HAVE_GCRYPT],[1],[Gcrypt library is available]) HAVE_GCRYPT=1 # checking for available algorithms... gcrypt_algos=`$LIBGCRYPT_CONFIG --algorithms` # ciphers # this does not work with a "for" loop: nothing generated in config.h:-( AX_CHECK_GCRYPT_ALGO([AES]) AX_CHECK_GCRYPT_ALGO([ARCFOUR]) AX_CHECK_GCRYPT_ALGO([BLOWFISH]) AX_CHECK_GCRYPT_ALGO([CAST5]) AX_CHECK_GCRYPT_ALGO([DES]) AX_CHECK_GCRYPT_ALGO([IDEA]) AX_CHECK_GCRYPT_ALGO([RFC2268]) AX_CHECK_GCRYPT_ALGO([SERPENT]) AX_CHECK_GCRYPT_ALGO([TWOFISH]) # digests AX_CHECK_GCRYPT_ALGO([CRC]) AX_CHECK_GCRYPT_ALGO([HAVAL]) AX_CHECK_GCRYPT_ALGO([MD2]) AX_CHECK_GCRYPT_ALGO([MD4]) AX_CHECK_GCRYPT_ALGO([MD5]) AX_CHECK_GCRYPT_ALGO([RMD160]) AX_CHECK_GCRYPT_ALGO([SHA0]) AX_CHECK_GCRYPT_ALGO([SHA1]) AX_CHECK_GCRYPT_ALGO([SHA224]) AX_CHECK_GCRYPT_ALGO([SHA256]) AX_CHECK_GCRYPT_ALGO([SHA384]) AX_CHECK_GCRYPT_ALGO([SHA512]) AX_CHECK_GCRYPT_ALGO([TIGER]) AX_CHECK_GCRYPT_ALGO([WHIRLPOOL]) # others AX_CHECK_GCRYPT_ALGO([DSA]) AX_CHECK_GCRYPT_ALGO([ELGAMAL]) AX_CHECK_GCRYPT_ALGO([RSA]) # CMAC support AC_MSG_CHECKING([for CMAC_AES in gcrypt]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gcrypt.h>]], [[ int ok = GCRY_MAC_CMAC_AES; (void)ok; ]])],[ AC_MSG_RESULT([yes]) AC_DEFINE([GCRYPT_WITH_CMAC_AES],[1],[Algorithm CMAC_AES in gcrypt library]) AC_SUBST([GCRYPT_WITH_CMAC_AES], [1]) HAVE_CMAC=yes ], [ AC_MSG_RESULT([no]) HAVE_CMAC=no ]) # conclusion GCRYPT_CFLAGS=`$LIBGCRYPT_CONFIG --cflags` GCRYPT_LIBS=`$LIBGCRYPT_CONFIG --libs` AC_SUBST(GCRYPT_CFLAGS) AC_SUBST(GCRYPT_LIBS) ],[ # complain only if explicitly required if test "$ac_with_gcrypt" = "yes" ; then AC_MSG_ERROR([cannot configure required gcrypt library]) fi ]) fi ])
M4 Macro
aircrack-ng/build/m4/ax_lib_socket_nsl.m4
# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_lib_socket_nsl.html # =========================================================================== # # SYNOPSIS # # AX_LIB_SOCKET_NSL # # DESCRIPTION # # This macro figures out what libraries are required on this platform to # link sockets programs. # # The common cases are not to need any extra libraries, or to need # -lsocket and -lnsl. We need to avoid linking with libnsl unless we need # it, though, since on some OSes where it isn't necessary it will totally # break networking. Unisys also includes gethostbyname() in libsocket but # needs libnsl for socket(). # # LICENSE # # Copyright (c) 2008 Russ Allbery <rra@stanford.edu> # Copyright (c) 2008 Stepan Kasal <kasal@ucw.cz> # Copyright (c) 2008 Warren Young <warren@etr-usa.com> # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 7 AU_ALIAS([LIB_SOCKET_NSL], [AX_LIB_SOCKET_NSL]) AC_DEFUN([AX_LIB_SOCKET_NSL], [ AC_SEARCH_LIBS([gethostbyname], [nsl]) AC_SEARCH_LIBS([socket], [socket], [], [ AC_CHECK_LIB([socket], [socket], [LIBS="-lsocket -lnsl $LIBS"], [], [-lnsl])]) ])
M4 Macro
aircrack-ng/build/m4/ax_lib_sqlite3.m4
# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_lib_sqlite3.html # =========================================================================== # # SYNOPSIS # # AX_LIB_SQLITE3([MINIMUM-VERSION]) # # DESCRIPTION # # Test for the SQLite 3 library of a particular version (or newer) # # This macro takes only one optional argument, required version of SQLite # 3 library. If required version is not passed, 3.0.0 is used in the test # of existence of SQLite 3. # # If no installation prefix to the installed SQLite library is given the # macro searches under /usr, /usr/local, and /opt. # # This macro calls: # # AC_SUBST(SQLITE3_CFLAGS) # AC_SUBST(SQLITE3_LDFLAGS) # AC_SUBST(SQLITE3_VERSION) # # And sets: # # HAVE_SQLITE3 # # LICENSE # # Copyright (c) 2008 Mateusz Loskot <mateusz@loskot.net> # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 18 AC_DEFUN([AX_LIB_SQLITE3], [ AC_REQUIRE([AX_EXT_HAVE_STATIC_LIB_DETECT]) AC_ARG_WITH([sqlite3], AS_HELP_STRING( [--with-sqlite3=@<:@ARG@:>@], [use SQLite 3 library @<:@default=yes@:>@, optionally specify the prefix for sqlite3 library] ), [ if test "$withval" = "no"; then WANT_SQLITE3="no" elif test "$withval" = "yes"; then WANT_SQLITE3="yes" ac_sqlite3_path="" else WANT_SQLITE3="yes" ac_sqlite3_path="$withval" fi ], [WANT_SQLITE3="yes"] ) SQLITE3_CFLAGS="" SQLITE3_LDFLAGS="" SQLITE3_VERSION="" if test "x$WANT_SQLITE3" = "xyes"; then ac_sqlite3_header="sqlite3.h" sqlite3_version_req=ifelse([$1], [], [3.0.0], [$1]) sqlite3_version_req_shorten=`expr $sqlite3_version_req : '\([[0-9]]*\.[[0-9]]*\)'` sqlite3_version_req_major=`expr $sqlite3_version_req : '\([[0-9]]*\)'` sqlite3_version_req_minor=`expr $sqlite3_version_req : '[[0-9]]*\.\([[0-9]]*\)'` sqlite3_version_req_micro=`expr $sqlite3_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'` if test "x$sqlite3_version_req_micro" = "x" ; then sqlite3_version_req_micro="0" fi sqlite3_version_req_number=`expr $sqlite3_version_req_major \* 1000000 \ \+ $sqlite3_version_req_minor \* 1000 \ \+ $sqlite3_version_req_micro` AC_MSG_CHECKING([for SQLite3 header]) if test "$ac_sqlite3_path" != ""; then ac_sqlite3_ldflags="-L$ac_sqlite3_path/${STATIC_LIBDIR_NAME}" ac_sqlite3_cppflags="-I$ac_sqlite3_path/include" AC_MSG_RESULT([explicitly set; $ac_sqlite3_path]) else for ac_sqlite3_path_tmp in /usr /usr/local /opt $lt_sysroot ; do if test -f "$ac_sqlite3_path_tmp/include/$ac_sqlite3_header" \ && test -r "$ac_sqlite3_path_tmp/include/$ac_sqlite3_header"; then ac_sqlite3_path=$ac_sqlite3_path_tmp ac_sqlite3_cppflags="-I$ac_sqlite3_path_tmp/include" ac_sqlite3_ldflags="-L$ac_sqlite3_path_tmp/${STATIC_LIBDIR_NAME}" AC_MSG_RESULT([found; $ac_sqlite3_path_tmp/include/$ac_sqlite3_header]) break; fi done if test "$ac_sqlite3_path" = ""; then AC_MSG_RESULT([not found]) fi fi ac_sqlite3_ldflags="$ac_sqlite3_ldflags -lsqlite3" saved_CPPFLAGS="$CPPFLAGS" saved_LDFLAGS="$LDFLAGS" CPPFLAGS="$CPPFLAGS $ac_sqlite3_cppflags" LDFLAGS="$LDFLAGS $ac_sqlite3_ldflags" AC_LANG_PUSH(C) AC_CHECK_HEADERS([sqlite3.h], [HAVE_SQLITE3=yes], [HAVE_SQLITE3=no]) AS_IF([test "$HAVE_SQLITE3" = yes], [ AC_CHECK_LIB([sqlite3], [sqlite3_open], [:], [HAVE_SQLITE3=no]) ]) AS_IF([test "$HAVE_SQLITE3" = yes], [ AC_MSG_CHECKING([for SQLite3 library version >= $sqlite3_version_req]) AC_COMPILE_IFELSE( [ AC_LANG_PROGRAM([[@%:@include <sqlite3.h>]], [[ #if (SQLITE_VERSION_NUMBER >= $sqlite3_version_req_number) /* Everything is okay */ #else # error SQLite version is too old #endif ]] ) ], [ AC_MSG_RESULT([yes]) ], [ AC_MSG_RESULT([not found]) HAVE_SQLITE3=no ] ) ]) AC_LANG_POP(C) CPPFLAGS="$saved_CPPFLAGS" LDFLAGS="$saved_LDFLAGS" if test "$HAVE_SQLITE3" = "yes"; then SQLITE3_CFLAGS="$ac_sqlite3_cppflags" SQLITE3_LDFLAGS="$ac_sqlite3_ldflags" ac_sqlite3_header_path="$ac_sqlite3_path/include/$ac_sqlite3_header" dnl Retrieve SQLite release version if test "x$ac_sqlite3_header_path" != "x"; then ac_sqlite3_version=`cat $ac_sqlite3_header_path \ | grep '#define.*SQLITE_VERSION.*"' | sed -e 's/.* "//' \ | sed -e 's/"//'` if test "$ac_sqlite3_version" != ""; then SQLITE3_VERSION=$ac_sqlite3_version else AC_MSG_WARN([Cannot find SQLITE_VERSION macro in sqlite3.h header to retrieve SQLite version!]) fi fi AC_SUBST(SQLITE3_CFLAGS) AC_SUBST(SQLITE3_LDFLAGS) AC_SUBST(SQLITE3_VERSION) AC_SUBST(HAVE_SQLITE3) AC_DEFINE([HAVE_SQLITE3], [1], [Have the SQLITE3 library]) fi fi ])
M4 Macro
aircrack-ng/build/m4/ax_pthread.m4
# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_pthread.html # =========================================================================== # # SYNOPSIS # # AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) # # DESCRIPTION # # This macro figures out how to build C programs using POSIX threads. It # sets the PTHREAD_LIBS output variable to the threads library and linker # flags, and the PTHREAD_CFLAGS output variable to any special C compiler # flags that are needed. (The user can also force certain compiler # flags/libs to be tested by setting these environment variables.) # # Also sets PTHREAD_CC to any special C compiler that is needed for # multi-threaded programs (defaults to the value of CC otherwise). (This # is necessary on AIX to use the special cc_r compiler alias.) # # NOTE: You are assumed to not only compile your program with these flags, # but also to link with them as well. For example, you might link with # $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS # # If you are only building threaded programs, you may wish to use these # variables in your default LIBS, CFLAGS, and CC: # # LIBS="$PTHREAD_LIBS $LIBS" # CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # CC="$PTHREAD_CC" # # In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant # has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to # that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX). # # Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the # PTHREAD_PRIO_INHERIT symbol is defined when compiling with # PTHREAD_CFLAGS. # # ACTION-IF-FOUND is a list of shell commands to run if a threads library # is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it # is not found. If ACTION-IF-FOUND is not specified, the default action # will define HAVE_PTHREAD. # # Please let the authors know if this macro fails on any platform, or if # you have any other suggestions or comments. This macro was based on work # by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help # from M. Frigo), as well as ac_pthread and hb_pthread macros posted by # Alejandro Forero Cuervo to the autoconf macro repository. We are also # grateful for the helpful feedback of numerous users. # # Updated for Autoconf 2.68 by Daniel Richard G. # # LICENSE # # Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu> # Copyright (c) 2011 Daniel Richard G. <skunk@iSKUNK.ORG> # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation, either version 3 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see <https://www.gnu.org/licenses/>. # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 24 AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) AC_DEFUN([AX_PTHREAD], [ AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([AC_PROG_SED]) AC_LANG_PUSH([C]) ax_pthread_ok=no # We used to check for pthread.h first, but this fails if pthread.h # requires special compiler flags (e.g. on Tru64 or Sequent). # It gets checked for in the link test anyway. # First of all, check if the user has set any of the PTHREAD_LIBS, # etcetera environment variables, and if threads linking works using # them: if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then ax_pthread_save_CC="$CC" ax_pthread_save_CFLAGS="$CFLAGS" ax_pthread_save_LIBS="$LIBS" AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"]) CFLAGS="$CFLAGS $PTHREAD_CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS]) AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_join])], [ax_pthread_ok=yes]) AC_MSG_RESULT([$ax_pthread_ok]) if test "x$ax_pthread_ok" = "xno"; then PTHREAD_LIBS="" PTHREAD_CFLAGS="" fi CC="$ax_pthread_save_CC" CFLAGS="$ax_pthread_save_CFLAGS" LIBS="$ax_pthread_save_LIBS" fi # We must check for the threads library under a number of different # names; the ordering is very important because some systems # (e.g. DEC) have both -lpthread and -lpthreads, where one of the # libraries is broken (non-POSIX). # Create a list of thread flags to try. Items starting with a "-" are # C compiler flags, and other items are library names, except for "none" # which indicates that we try without any flags at all, and "pthread-config" # which is a program returning the flags for the Pth emulation library. ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" # The ordering *is* (sometimes) important. Some notes on the # individual items follow: # pthreads: AIX (must check this before -lpthread) # none: in case threads are in libc; should be tried before -Kthread and # other compiler flags to prevent continual compiler warnings # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64 # (Note: HP C rejects this with "bad form for `-t' option") # -pthreads: Solaris/gcc (Note: HP C also rejects) # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it # doesn't hurt to check since this sometimes defines pthreads and # -D_REENTRANT too), HP C (must be checked before -lpthread, which # is present but should not be used directly; and before -mthreads, # because the compiler interprets this as "-mt" + "-hreads") # -mthreads: Mingw32/gcc, Lynx/gcc # pthread: Linux, etcetera # --thread-safe: KAI C++ # pthread-config: use pthread-config program (for GNU Pth library) case $host_os in freebsd*) # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) ax_pthread_flags="-kthread lthread $ax_pthread_flags" ;; hpux*) # From the cc(1) man page: "[-mt] Sets various -D flags to enable # multi-threading and also sets -lpthread." ax_pthread_flags="-mt -pthread pthread $ax_pthread_flags" ;; openedition*) # IBM z/OS requires a feature-test macro to be defined in order to # enable POSIX threads at all, so give the user a hint if this is # not set. (We don't define these ourselves, as they can affect # other portions of the system API in unpredictable ways.) AC_EGREP_CPP([AX_PTHREAD_ZOS_MISSING], [ # if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS) AX_PTHREAD_ZOS_MISSING # endif ], [AC_MSG_WARN([IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support.])]) ;; solaris*) # On Solaris (at least, for some versions), libc contains stubbed # (non-functional) versions of the pthreads routines, so link-based # tests will erroneously succeed. (N.B.: The stubs are missing # pthread_cleanup_push, or rather a function called by this macro, # so we could check for that, but who knows whether they'll stub # that too in a future libc.) So we'll check first for the # standard Solaris way of linking pthreads (-mt -lpthread). ax_pthread_flags="-mt,pthread pthread $ax_pthread_flags" ;; esac # GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC) AS_IF([test "x$GCC" = "xyes"], [ax_pthread_flags="-pthread -pthreads $ax_pthread_flags"]) # The presence of a feature test macro requesting re-entrant function # definitions is, on some systems, a strong hint that pthreads support is # correctly enabled case $host_os in darwin* | hpux* | linux* | osf* | solaris*) ax_pthread_check_macro="_REENTRANT" ;; aix*) ax_pthread_check_macro="_THREAD_SAFE" ;; *) ax_pthread_check_macro="--" ;; esac AS_IF([test "x$ax_pthread_check_macro" = "x--"], [ax_pthread_check_cond=0], [ax_pthread_check_cond="!defined($ax_pthread_check_macro)"]) # Are we compiling with Clang? AC_CACHE_CHECK([whether $CC is Clang], [ax_cv_PTHREAD_CLANG], [ax_cv_PTHREAD_CLANG=no # Note that Autoconf sets GCC=yes for Clang as well as GCC if test "x$GCC" = "xyes"; then AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG], [/* Note: Clang 2.7 lacks __clang_[a-z]+__ */ # if defined(__clang__) && defined(__llvm__) AX_PTHREAD_CC_IS_CLANG # endif ], [ax_cv_PTHREAD_CLANG=yes]) fi ]) ax_pthread_clang="$ax_cv_PTHREAD_CLANG" ax_pthread_clang_warning=no # Clang needs special handling, because older versions handle the -pthread # option in a rather... idiosyncratic way if test "x$ax_pthread_clang" = "xyes"; then # Clang takes -pthread; it has never supported any other flag # (Note 1: This will need to be revisited if a system that Clang # supports has POSIX threads in a separate library. This tends not # to be the way of modern systems, but it's conceivable.) # (Note 2: On some systems, notably Darwin, -pthread is not needed # to get POSIX threads support; the API is always present and # active. We could reasonably leave PTHREAD_CFLAGS empty. But # -pthread does define _REENTRANT, and while the Darwin headers # ignore this macro, third-party headers might not.) PTHREAD_CFLAGS="-pthread" PTHREAD_LIBS= ax_pthread_ok=yes # However, older versions of Clang make a point of warning the user # that, in an invocation where only linking and no compilation is # taking place, the -pthread option has no effect ("argument unused # during compilation"). They expect -pthread to be passed in only # when source code is being compiled. # # Problem is, this is at odds with the way Automake and most other # C build frameworks function, which is that the same flags used in # compilation (CFLAGS) are also used in linking. Many systems # supported by AX_PTHREAD require exactly this for POSIX threads # support, and in fact it is often not straightforward to specify a # flag that is used only in the compilation phase and not in # linking. Such a scenario is extremely rare in practice. # # Even though use of the -pthread flag in linking would only print # a warning, this can be a nuisance for well-run software projects # that build with -Werror. So if the active version of Clang has # this misfeature, we search for an option to squash it. AC_CACHE_CHECK([whether Clang needs flag to prevent "argument unused" warning when linking with -pthread], [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG], [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown # Create an alternate version of $ac_link that compiles and # links in two steps (.c -> .o, .o -> exe) instead of one # (.c -> exe), because the warning occurs only in the second # step ax_pthread_save_ac_link="$ac_link" ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g' ax_pthread_link_step=`echo "$ac_link" | sed "$ax_pthread_sed"` ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)" ax_pthread_save_CFLAGS="$CFLAGS" for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do AS_IF([test "x$ax_pthread_try" = "xunknown"], [break]) CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS" ac_link="$ax_pthread_save_ac_link" AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])], [ac_link="$ax_pthread_2step_ac_link" AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])], [break]) ]) done ac_link="$ax_pthread_save_ac_link" CFLAGS="$ax_pthread_save_CFLAGS" AS_IF([test "x$ax_pthread_try" = "x"], [ax_pthread_try=no]) ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try" ]) case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in no | unknown) ;; *) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;; esac fi # $ax_pthread_clang = yes if test "x$ax_pthread_ok" = "xno"; then for ax_pthread_try_flag in $ax_pthread_flags; do case $ax_pthread_try_flag in none) AC_MSG_CHECKING([whether pthreads work without any flags]) ;; -mt,pthread) AC_MSG_CHECKING([whether pthreads work with -mt -lpthread]) PTHREAD_CFLAGS="-mt" PTHREAD_LIBS="-lpthread" ;; -*) AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag]) PTHREAD_CFLAGS="$ax_pthread_try_flag" ;; pthread-config) AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no]) AS_IF([test "x$ax_pthread_config" = "xno"], [continue]) PTHREAD_CFLAGS="`pthread-config --cflags`" PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" ;; *) AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag]) PTHREAD_LIBS="-l$ax_pthread_try_flag" ;; esac ax_pthread_save_CFLAGS="$CFLAGS" ax_pthread_save_LIBS="$LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" # Check for various functions. We must include pthread.h, # since some functions may be macros. (On the Sequent, we # need a special flag -Kthread to make this header compile.) # We check for pthread_join because it is in -lpthread on IRIX # while pthread_create is in libc. We check for pthread_attr_init # due to DEC craziness with -lpthreads. We check for # pthread_cleanup_push because it is one of the few pthread # functions on Solaris that doesn't have a non-functional libc stub. # We try pthread_create on general principles. AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h> # if $ax_pthread_check_cond # error "$ax_pthread_check_macro must be defined" # endif static void routine(void *a) { a = 0; (void)a; } static void *start_routine(void *a) { return a; }], [pthread_t th; pthread_attr_t attr; pthread_create(&th, 0, start_routine, 0); pthread_join(th, 0); pthread_attr_init(&attr); pthread_cleanup_push(routine, 0); pthread_cleanup_pop(0) /* ; */])], [ax_pthread_ok=yes], []) CFLAGS="$ax_pthread_save_CFLAGS" LIBS="$ax_pthread_save_LIBS" AC_MSG_RESULT([$ax_pthread_ok]) AS_IF([test "x$ax_pthread_ok" = "xyes"], [break]) PTHREAD_LIBS="" PTHREAD_CFLAGS="" done fi # Various other checks: if test "x$ax_pthread_ok" = "xyes"; then ax_pthread_save_CFLAGS="$CFLAGS" ax_pthread_save_LIBS="$LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. AC_CACHE_CHECK([for joinable pthread attribute], [ax_cv_PTHREAD_JOINABLE_ATTR], [ax_cv_PTHREAD_JOINABLE_ATTR=unknown for ax_pthread_attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>], [int attr = $ax_pthread_attr; return attr /* ; */])], [ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr; break], []) done ]) AS_IF([test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xunknown" && \ test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xPTHREAD_CREATE_JOINABLE" && \ test "x$ax_pthread_joinable_attr_defined" != "xyes"], [AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], [$ax_cv_PTHREAD_JOINABLE_ATTR], [Define to necessary symbol if this constant uses a non-standard name on your system.]) ax_pthread_joinable_attr_defined=yes ]) AC_CACHE_CHECK([whether more special flags are required for pthreads], [ax_cv_PTHREAD_SPECIAL_FLAGS], [ax_cv_PTHREAD_SPECIAL_FLAGS=no case $host_os in solaris*) ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS" ;; esac ]) AS_IF([test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \ test "x$ax_pthread_special_flags_added" != "xyes"], [PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS" ax_pthread_special_flags_added=yes]) AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT], [ax_cv_PTHREAD_PRIO_INHERIT], [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], [[int i = PTHREAD_PRIO_INHERIT;]])], [ax_cv_PTHREAD_PRIO_INHERIT=yes], [ax_cv_PTHREAD_PRIO_INHERIT=no]) ]) AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes" && \ test "x$ax_pthread_prio_inherit_defined" != "xyes"], [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.]) ax_pthread_prio_inherit_defined=yes ]) CFLAGS="$ax_pthread_save_CFLAGS" LIBS="$ax_pthread_save_LIBS" # More AIX lossage: compile with *_r variant if test "x$GCC" != "xyes"; then case $host_os in aix*) AS_CASE(["x/$CC"], [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6], [#handle absolute path differently from PATH based program lookup AS_CASE(["x$CC"], [x/*], [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])], [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])]) ;; esac fi fi test -n "$PTHREAD_CC" || PTHREAD_CC="$CC" AC_SUBST([PTHREAD_LIBS]) AC_SUBST([PTHREAD_CFLAGS]) AC_SUBST([PTHREAD_CC]) # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: if test "x$ax_pthread_ok" = "xyes"; then ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1]) : else ax_pthread_ok=no $2 fi AC_LANG_POP ])dnl AX_PTHREAD
M4 Macro
aircrack-ng/build/m4/ax_require_defined.m4
# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_require_defined.html # =========================================================================== # # SYNOPSIS # # AX_REQUIRE_DEFINED(MACRO) # # DESCRIPTION # # AX_REQUIRE_DEFINED is a simple helper for making sure other macros have # been defined and thus are available for use. This avoids random issues # where a macro isn't expanded. Instead the configure script emits a # non-fatal: # # ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found # # It's like AC_REQUIRE except it doesn't expand the required macro. # # Here's an example: # # AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG]) # # LICENSE # # Copyright (c) 2014 Mike Frysinger <vapier@gentoo.org> # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 2 AC_DEFUN([AX_REQUIRE_DEFINED], [dnl m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])]) ])dnl AX_REQUIRE_DEFINED
M4 Macro
aircrack-ng/build/m4/libgcrypt.m4
# libgcrypt.m4 - Autoconf macros to detect libgcrypt # Copyright (C) 2002, 2003, 2004, 2011, 2014 g10 Code GmbH # # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # # This file is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # # Last-changed: 2014-10-02 dnl AM_PATH_LIBGCRYPT([MINIMUM-VERSION, dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]]) dnl Test for libgcrypt and define LIBGCRYPT_CFLAGS and LIBGCRYPT_LIBS. dnl MINIMUN-VERSION is a string with the version number optionally prefixed dnl with the API version to also check the API compatibility. Example: dnl a MINIMUN-VERSION of 1:1.2.5 won't pass the test unless the installed dnl version of libgcrypt is at least 1.2.5 *and* the API number is 1. Using dnl this features allows one to prevent build against newer versions of dnl libgcrypt with a changed API. dnl dnl If a prefix option is not used, the config script is first dnl searched in $SYSROOT/bin and then along $PATH. If the used dnl config script does not match the host specification the script dnl is added to the gpg_config_script_warn variable. dnl AC_DEFUN([AM_PATH_LIBGCRYPT], [ AC_REQUIRE([AC_CANONICAL_HOST]) AC_ARG_WITH(libgcrypt-prefix, AS_HELP_STRING([--with-libgcrypt-prefix=PFX], [prefix where LIBGCRYPT is installed (optional)]), libgcrypt_config_prefix="$withval", libgcrypt_config_prefix="") if test x"${LIBGCRYPT_CONFIG}" = x ; then if test x"${libgcrypt_config_prefix}" != x ; then LIBGCRYPT_CONFIG="${libgcrypt_config_prefix}/bin/libgcrypt-config" else case "${SYSROOT}" in /*) if test -x "${SYSROOT}/bin/libgcrypt-config" ; then LIBGCRYPT_CONFIG="${SYSROOT}/bin/libgcrypt-config" fi ;; '') ;; *) AC_MSG_WARN([Ignoring \$SYSROOT as it is not an absolute path.]) ;; esac fi fi AC_PATH_PROG(LIBGCRYPT_CONFIG, libgcrypt-config, no) tmp=ifelse([$1], ,1:1.2.0,$1) if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then req_libgcrypt_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'` min_libgcrypt_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'` else req_libgcrypt_api=0 min_libgcrypt_version="$tmp" fi AC_MSG_CHECKING(for LIBGCRYPT - version >= $min_libgcrypt_version) ok=no if test "$LIBGCRYPT_CONFIG" != "no" ; then req_major=`echo $min_libgcrypt_version | \ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'` req_minor=`echo $min_libgcrypt_version | \ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'` req_micro=`echo $min_libgcrypt_version | \ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'` libgcrypt_config_version=`$LIBGCRYPT_CONFIG --version` major=`echo $libgcrypt_config_version | \ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'` minor=`echo $libgcrypt_config_version | \ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'` micro=`echo $libgcrypt_config_version | \ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'` if test "$major" -gt "$req_major"; then ok=yes else if test "$major" -eq "$req_major"; then if test "$minor" -gt "$req_minor"; then ok=yes else if test "$minor" -eq "$req_minor"; then if test "$micro" -ge "$req_micro"; then ok=yes fi fi fi fi fi fi if test $ok = yes; then AC_MSG_RESULT([yes ($libgcrypt_config_version)]) else AC_MSG_RESULT(no) fi if test $ok = yes; then # If we have a recent libgcrypt, we should also check that the # API is compatible if test "$req_libgcrypt_api" -gt 0 ; then tmp=`$LIBGCRYPT_CONFIG --api-version 2>/dev/null || echo 0` if test "$tmp" -gt 0 ; then AC_MSG_CHECKING([LIBGCRYPT API version]) if test "$req_libgcrypt_api" -eq "$tmp" ; then AC_MSG_RESULT([okay]) else ok=no AC_MSG_RESULT([does not match. want=$req_libgcrypt_api got=$tmp]) fi fi fi fi if test $ok = yes; then LIBGCRYPT_CFLAGS=`$LIBGCRYPT_CONFIG --cflags` LIBGCRYPT_LIBS=`$LIBGCRYPT_CONFIG --libs` ifelse([$2], , :, [$2]) libgcrypt_config_host=`$LIBGCRYPT_CONFIG --host 2>/dev/null || echo none` if test x"$libgcrypt_config_host" != xnone ; then if test x"$libgcrypt_config_host" != x"$host" ; then AC_MSG_WARN([[ *** *** The config script $LIBGCRYPT_CONFIG was *** built for $libgcrypt_config_host and thus may not match the *** used host $host. *** You may want to use the configure option --with-libgcrypt-prefix *** to specify a matching config script or use \$SYSROOT. ***]]) gpg_config_script_warn="$gpg_config_script_warn libgcrypt" fi fi else LIBGCRYPT_CFLAGS="" LIBGCRYPT_LIBS="" ifelse([$3], , :, [$3]) fi AC_SUBST(LIBGCRYPT_CFLAGS) AC_SUBST(LIBGCRYPT_LIBS) ])
YAML
aircrack-ng/build/pipelines/package.yaml
--- ## # Aircrack-ng Pipeline Definition # # Built with the PyDeployer tool! # # https://github.com/jbenden/deployer ## - name: Packaging Preparations tags: - pkg stage: scope: false tasks: - name: Set package metadata set: artifacts: artifacts/aircrack-ng www: '{% if env.ARTIFACT_WWW_ROOT %}{{ env.ARTIFACT_WWW_ROOT }}{% else %}/tmp/www{% endif %}' description: | Aircrack-ng is a complete suite of tools to assess WiFi network security. It focuses on different areas of WiFi security: - Monitoring: Packet capture and export of data to text files for further processing by third party tools. - Attacking: Replay attacks, deauthentication, fake access points and others via packet injection. - Testing: Checking WiFi cards and driver capabilities (capture and injection). - Cracking: WEP and WPA PSK (WPA 1 and 2). All tools are command line which allows for heavy scripting. A lot of GUIs have taken advantage of this feature. It works primarily with Linux but also Windows, OS X, FreeBSD, OpenBSD, NetBSD, as well as Solaris and even the eComStation 2. fpm: | [ -e "{{ item.pkg }}" ] && rm -f "{{ item.pkg }}" fpm -s dir \ -t "{{ item.pkg_type }}" \ -n "{{ item.pkg_name }}" \ -v "{{ item.pkg_version }}" \ --epoch 1 \ -C "{{ destdir }}" \ --license GPLv2 \ -m "info@aircrack-ng.org" \ --vendor 'The Aircrack-ng Project' \ --url 'https://aircrack-ng.org/' \ --description "{{ description }}" \ -p "{{ item.pkg_template }}" \ -x *.la \ {{ item.pkg_deps }} \ {{ item.pkg_content }} [ "{{ item.pkg_type }}" = deb ] && dpkg-deb -c "{{ item.pkg }}" || : [ "{{ item.pkg_type }}" = deb ] && dpkg-deb -I "{{ item.pkg }}" || : [ "{{ item.pkg_type }}" = rpm ] && rpm -qp "{{ item.pkg }}" --info || : pkg: - pkg: "aircrack-ng_{{ pkg_deb_revision }}_amd64.deb" pkg_name: aircrack-ng pkg_type: deb pkg_template: "aircrack-ng_VERSION_ARCH.deb" pkg_deps: "--category net --deb-priority optional -d iw -d wireless-tools -d ethtool -d usbutils -d rfkill -d libc6 -d libgcc1 -d libltdl7 -d libnl-3-200 -d libnl-genl-3-200 -d libstdc++6" pkg_content: "usr/bin usr/include usr/lib usr/sbin usr/share/man" pkg_version: "{{ pkg_deb_revision }}" - pkg: "aircrack-ng-{{ pkg_rpm_revision }}.x86_64.rpm" pkg_name: aircrack-ng pkg_type: rpm pkg_template: "aircrack-ng-VERSION.ARCH.rpm" pkg_deps: "-d iw -d wireless-tools -d ethtool -d usbutils -d rfkill -d glibc -d libgcc -d libtool-ltdl -d libnl3 -d libstdc++" pkg_content: "usr/bin usr/include usr/lib usr/sbin usr/share/man" pkg_version: "{{ pkg_rpm_revision }}" - command: mktemp -d register: destdir - shell: script: ./evalrev | sed -e 's/_rev//g' register: revision - command: git rev-parse HEAD register: commit_id - command: git rev-parse --abbrev-ref HEAD register: branch - shell: script: 'git describe --abbrev=0 --tags 2>/dev/null || echo unknown' register: closest_tag - shell: script: 'git describe --abbrev=0 --tags --exact-match 2>/dev/null || echo' register: exact_tag - command: date -u +%Y%m%d%H%M%S register: pkg_date # Development package naming - name: Calculating the Debian package version command: echo {{ closest_tag }}+git{{ pkg_date }}-1 register: pkg_deb_revision when: "exact_tag | trim | count == 0" - name: Calculating the RPM package version shell: script: echo {{ closest_tag }}.{% print pkg_date.stdout[:8] %}git$(git rev-parse --short HEAD) register: pkg_rpm_revision when: "exact_tag | trim | count == 0" # Stable package naming - name: Calculating the Debian package version command: echo {{ exact_tag }}-1 register: pkg_deb_revision when: "exact_tag | trim | count > 0" - name: Calculating the RPM package version shell: script: echo {{ exact_tag }} register: pkg_rpm_revision when: "exact_tag | trim | count > 0" - name: Metadata Evaluation echo: | destdir : {{ destdir }} revision : {{ revision }} commit : {{ commit_id }} branch : {{ branch }} closest_tag : {{ closest_tag }} exact_tag : {{ exact_tag }} pkg_date : {{ pkg_date }} pkg_deb_revision: {{ pkg_deb_revision }} pkg_rpm_revision: {{ pkg_rpm_revision }} - name: Packaging Build tags: - pkg stage: tasks: - name: Clean build artifacts shell: script: | find . -name '.deps' -a -type d -exec rm -fr {} ';' 2>/dev/null || : find . -name '.libs' -a -type d -exec rm -fr {} ';' 2>/dev/null || : silent: true - name: Ensure configure is present command: autoreconf -vi - name: Configure command: > ./configure --prefix=/usr --with-experimental --enable-static-crypto --enable-static-hwloc --enable-static-sqlite3 --enable-static-pcre2 --enable-static-pcap - name: Make clean shell: script: make clean silent: true - name: Compile shell: script: make V=1 silent: true - name: Run unit-tests command: make check - name: Staging Installation command: "make install-strip DESTDIR={{ destdir }}" - name: Produce dist artifacts command: make dist - name: Packaging shell: script: "{{ fpm }}" with_items: "{{ pkg }}" - name: Packaging Deployment tags: - deploy stage: tasks: - name: Deploying development packages to the web server tags: - www stage: tasks: - shell: script: | {% set path = "{{ www }}/{{ artifacts }}/development/{{ commit_id }}/{{ item.pkg_type }}" %} {% set prefix = "{{ www }}/{{ artifacts }}" %} mkdir -p "{{ path }}" chmod 777 "{{ www }}/{{ artifacts }}/development/{{ commit_id }}" chmod 777 "{{ path }}" ( cd "{{ prefix }}/development" && ln -sfnd "{{ commit_id }}" "{{ branch }}" ) cp -p "{{ item.pkg }}" "{{ path }}" chmod 664 "{{ path }}/{{ item.pkg }}" with_items: "{{ pkg }}" - shell: script: | {% set path = "{{ www }}/{{ artifacts }}/development/{{ commit_id }}" %} find . -name '*.zip' -o -name '*.tar.*' -print0 | xargs -0 -I {} cp -p {} "{{ path }}" - name: Deploying development package manifest tags: - www shell: script: | mkdir -p "{{ www }}/{{ artifacts }}" cat > "{{ www }}/{{ artifacts }}/development.json" <<-EOF { "build": "development", "commit": "{{ commit_id }}", "tag": "{{ closest_tag }}", "date": "$(date -u)", "url": "https://packages.aircrack-ng.org/artifacts/aircrack-ng/development/{{ commit_id }}" } EOF - name: Deploying stable packages to the web server tags: - www shell: script: | {% set prefix = "{{ www }}/{{ artifacts }}" %} mkdir -p "{{ prefix }}/stable" chmod 777 "{{ prefix }}/stable" ( cd "{{ prefix }}/stable" && ln -sfnd "../development/{{ commit_id }}" "{{ exact_tag }}" ) when: "exact_tag | trim | count > 0" - name: Deploying stable package manifest tags: - www shell: script: | cat > "{{ www }}/{{ artifacts }}/stable.json" <<-EOF { "build": "stable", "commit": "{{ commit_id }}", "tag": "{{ exact_tag }}", "date": "$(date -u)", "url": "https://packages.aircrack-ng.org/artifacts/aircrack-ng/stable/{{ exact_tag }}" } EOF when: "exact_tag | trim | count > 0" - name: Deploying development packages to PackageCloud.io tags: - package_cloud matrix: tags: - deb - rpm tasks: - name: Deploy Debian Packages when: "matrix_tag == 'deb'" matrix: tags: - any/any tasks: - command: "package_cloud push --yes aircrack-ng/git/{{ matrix_tag }} {{ item.pkg }}" with_items: "{{ pkg | selectattr('pkg_type', 'equalto', 'deb') | list }}" - command: "package_cloud push --yes aircrack-ng/release/{{ matrix_tag }} {{ item.pkg }}" when: "exact_tag | trim | count > 0" with_items: "{{ pkg | selectattr('pkg_type', 'equalto', 'deb') | list }}" - name: Deploy RPM Packages when: "matrix_tag == 'rpm'" matrix: tags: - rpm_any/rpm_any tasks: - command: "package_cloud push --yes aircrack-ng/git/{{ matrix_tag }} {{ item.pkg }}" with_items: "{{ pkg | selectattr('pkg_type', 'equalto', 'rpm') | list }}" - command: "package_cloud push --yes aircrack-ng/release/{{ matrix_tag }} {{ item.pkg }}" when: "exact_tag | trim | count > 0" with_items: "{{ pkg | selectattr('pkg_type', 'equalto', 'rpm') | list }}"
C
aircrack-ng/contrib/airpcap/airpcap.c
#include <string.h> #include <stdlib.h> #include <stdio.h> #include <windows.h> #include <airpcap.h> #include "osdep.h" #include "tap-win32/common.h" static const char * DEFAULT_ADAPT_NAME = "\\\\.\\airpcap00"; static const char * DEVICE_HEADER = "\\\\.\\"; //pcap_t *winpcap_adapter; static PAirpcapHandle airpcap_handle; // Use PPI later #define PPH_PH_VERSION ((u_int8_t)0x00) #define PPI_FIELD_TYPE_802_11_COMMON ((u_int16_t)0x02) typedef struct _PPI_PACKET_HEADER { u_int8_t PphVersion; u_int8_t PphFlags; u_int16_t PphLength; u_int32_t PphDlt; } PPI_PACKET_HEADER, *PPPI_PACKET_HEADER; typedef struct _PPI_FIELD_HEADER { u_int16_t PfhType; u_int16_t PfhLength; } PPI_FIELD_HEADER, *PPPI_FIELD_HEADER; typedef struct _PPI_FIELD_802_11_COMMON { u_int64_t TsfTimer; u_int16_t Flags; u_int16_t Rate; u_int16_t ChannelFrequency; u_int16_t ChannelFlags; u_int8_t FhssHopset; u_int8_t FhssPattern; int8_t DbmAntSignal; int8_t DbmAntNoise; } PPI_FIELD_802_11_COMMON, *PPPI_FIELD_802_11_COMMON; static int ppi_decode(const u_char *p, int caplen, int *hdrlen, int *power) { PPPI_PACKET_HEADER pPpiPacketHeader; PPPI_FIELD_HEADER pFieldHeader; ULONG position = 0; // Sanity checks if (caplen < sizeof(*pPpiPacketHeader)) { // Packet smaller than the PPI fixed header return( 1 ); } pPpiPacketHeader = (PPPI_PACKET_HEADER)p; *hdrlen = pPpiPacketHeader->PphLength; if(caplen < *hdrlen) { // Packet smaller than the PPI fixed header return( 1 ); } position = sizeof(*pPpiPacketHeader); if (pPpiPacketHeader->PphVersion != PPH_PH_VERSION) { fprintf( stderr, "Unknown PPI packet header version (%u)\n", pPpiPacketHeader->PphVersion); return( 1 ); } do { // now we suppose to have an 802.11-Common header if (*hdrlen < sizeof(*pFieldHeader) + position) { break; } pFieldHeader = (PPPI_FIELD_HEADER)(p + position); position += sizeof(*pFieldHeader); switch(pFieldHeader->PfhType) { case PPI_FIELD_TYPE_802_11_COMMON: if (pFieldHeader->PfhLength != sizeof(PPI_FIELD_802_11_COMMON) || caplen - position < sizeof(PPI_FIELD_802_11_COMMON)) { // the header is bogus, just skip it fprintf( stderr, "Bogus 802.11-Common Field. Skipping it.\n"); } else { PPPI_FIELD_802_11_COMMON pField = (PPPI_FIELD_802_11_COMMON)(p + position); if (pField->DbmAntSignal != -128) { *power = (int)pField->DbmAntSignal; } else { *power = 0; } } break; default: // we do not know this field. Just print type and length and skip break; } position += pFieldHeader->PfhLength; } while(TRUE); return( 0 ); } int cygwin_set_mac(unsigned char *mac) { if (*mac) {} return 0; } void cygwin_close(void) { // By default, when plugged in, the adapter is set in monitor mode; // Application may assume it's already in monitor mode and forget to set it // So, do not remove monitor mode. if (airpcap_handle != NULL) { AirpcapClose(airpcap_handle); } } int cygwin_get_mac(unsigned char *mac) { // Don't use the function from Airpcap if (*mac) {} return 0; } // Use PPI headers to obtain the different information for ri // Use AirpcapConvertFrequencyToChannel() to get channel // Add an option to give frequency instead of channel int cygwin_sniff(void *buf, int len, struct rx_info *ri) { UINT BytesReceived = 0; // Wait for the next packet // Maybe add an event packets to read // WaitForSingleObject(ReadEvent, INFINITE); // Read a packet if(AirpcapRead(airpcap_handle, buf, len, &BytesReceived)) return (int)BytesReceived; return -1; } int cygwin_inject(void *buf, int len, struct tx_info *ti) { if (AirpcapWrite (airpcap_handle, buf, len) != 1) return -1; return len; } static int printErrorCloseAndReturn(const char * err, int retValue) { if (err && airpcap_handle) { if (strlen(err)) { if (airpcap_handle) fprintf( stderr, err, AirpcapGetLastError(airpcap_handle)); else fprintf( stderr, err); } } cygwin_close(); return retValue; } int cygwin_init(char *param) { char * iface; char errbuf[AIRPCAP_ERRBUF_SIZE ]; iface = (char *)calloc(1, strlen(param) + strlen(DEVICE_HEADER) +1); strcpy (iface, DEFAULT_ADAPT_NAME); if (param) { // if it's empty, use the default adapter if (*param != 0) { // Make sure the adapter name contains the '\\.\' at its beginning memset(iface, 0, strlen(param) + strlen(DEVICE_HEADER) +1); if (strstr(param, DEVICE_HEADER) == NULL) { // Not found, add it strcpy(iface, DEVICE_HEADER); strcat(iface, param); } else { // Already contains the adapter header strcpy(iface, param); } } } airpcap_handle = AirpcapOpen(iface, errbuf); if(airpcap_handle == NULL) { fprintf( stderr, "This adapter doesn't have wireless extensions. Quitting\n"); //pcap_close( winpcap_adapter ); return( -1 ); } /* Tell the adapter that the packets we'll send and receive don't include the FCS */ if(!AirpcapSetFcsPresence(airpcap_handle, FALSE)) return printErrorCloseAndReturn("Error setting FCS presence: %s\n", -1); /* Set the link layer to bare 802.11 */ if(!AirpcapSetLinkType(airpcap_handle, AIRPCAP_LT_802_11)) return printErrorCloseAndReturn("Error setting the link type: %s\n", -1); /* Accept correct frames only */ if( !AirpcapSetFcsValidation(airpcap_handle, AIRPCAP_VT_ACCEPT_CORRECT_FRAMES) ) return printErrorCloseAndReturn("Error setting FCS validation: %s\n", -1); /* Set a low mintocopy for better responsiveness */ if(!AirpcapSetMinToCopy(airpcap_handle, 1)) return printErrorCloseAndReturn("Error setting MinToCopy: %s\n", -1); return 0; } int cygwin_set_chan(int chan) { // Make sure a valid channel is given if (chan <= 0) return -1; if(!AirpcapSetDeviceChannel(airpcap_handle, chan)) { printf("Error setting the channel to %d: %s\n", chan, AirpcapGetLastError(airpcap_handle)); return -1; } return 0; }
aircrack-ng/contrib/airpcap/Makefile
ROOT = ../.. include $(ROOT)/common.mak CFLAGS = -g -I$(ROOT)/../developers/Airpcap_Devpack/include -I$(ROOT)/src/osdep #LIBS = -L $(ROOT)/../developers/Airpcap_Devpack/lib -lairpcap -L $(ROOT)/src/osdep -losdep LIBS = -L $(ROOT)/../developers/Airpcap_Devpack/lib -lairpcap CFLAGS += $(PIC) OBJS = airpcap.o DLL = airpcap.dll all: $(DLL) $(DLL): $(OBJS) $(CC) ${CFLAGS} -shared -o $(DLL) $(OBJS) ${LIBS} clean: rm -f $(DLL) $(OBJS)
C
aircrack-ng/contrib/commview/commview.c
#include <net/if.h> #include <sys/ioctl.h> #include <string.h> #include <dlfcn.h> #include <assert.h> #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <fcntl.h> #include <wchar.h> #include <windows.h> #include <iphlpapi.h> #include <setupapi.h> #include <devguid.h> #include <pthread.h> #include "osdep.h" #include "tap-win32/common.h" #define BUFSIZE 0x3E8000 struct CV_Header { unsigned int TickCount; // GetTickCount() / 1000 at time of packet unsigned int Micros; // Microsecond counter at time of packet /* The following might be backwards, unsure */ int PacketSize; // Full packet size? int SliceSize; // Truncated packet size? int Unknown; // Not sure what this is. }; struct CV_Header2 { char ErrorFlag; // ErrorFlag & 1 = CRC error char Unknown2[6]; // Unknown char Power; // Power char Unknown3[6]; // Unknown }; struct cstate { char cs_param[256]; int cs_ioctls; struct ifreq cs_ifreq; char cs_guid[256]; HKEY cs_key; int cs_chan; volatile int cs_restarting; void *cs_lib; pthread_mutex_t cs_mtx; int cs_debug; char (__cdecl *cs_F1)(int Code); char (__cdecl *cs_F2)(void); char (__cdecl *cs_T1)(int Size, unsigned char *Buffer); char (__cdecl *cs_CC)(int Channel); char (__cdecl *cs_S1)(int Channel); int (__cdecl *cs_S5)(unsigned char *Buffer, int Length); int (__cdecl *cs_GN)(wchar_t *); int (*cs_SC)(int band); } _cs; static struct cstate *get_cs(void) { return &_cs; } static int print_error(char *fmt, ...) { va_list ap; va_start(ap, fmt); vprintf(fmt, ap); va_end(ap); printf("\n"); return -1; } static void print_debug(char *fmt, ...) { struct cstate *cs = get_cs(); va_list ap; if (!cs->cs_debug) return; va_start(ap, fmt); vprintf(fmt, ap); va_end(ap); printf("\n"); } static int do_init_lib(struct cstate *cs) { /* init */ if (!cs->cs_F1(BUFSIZE)) return print_error("F1"); /* start monitor */ if (!cs->cs_S1(cs->cs_chan)) return print_error("S1"); /* change chan */ if (!cs->cs_CC(cs->cs_chan)) return print_error("CC"); return 0; } static int init_lib(struct cstate *cs) { char *lib = "ca2k.dll"; void *ca2k_dll; ca2k_dll = dlopen(lib, RTLD_LAZY); if (!ca2k_dll) return print_error("dlopen(%s)", lib); cs->cs_lib = ca2k_dll; // Initialise cs->cs_F1 = dlsym(ca2k_dll, "F1"); // Transmit cs->cs_T1 = dlsym(ca2k_dll, "T1"); // Change monitoring channel cs->cs_CC = dlsym(ca2k_dll, "CC"); // Start monitoring cs->cs_S1 = dlsym(ca2k_dll, "S1"); // Read packets cs->cs_S5 = dlsym(ca2k_dll, "S5"); // Finalize cs->cs_F2 = dlsym(ca2k_dll, "F2"); // Get Adapter Name cs->cs_GN = dlsym(ca2k_dll, "GN"); if (!(cs->cs_F1 && cs->cs_T1 && cs->cs_CC && cs->cs_S1 && cs->cs_S5 && cs->cs_F2 && cs->cs_GN)) return print_error("Can't find syms"); return do_init_lib(cs); } static int get_name(struct cstate *cs, char *name) { wchar_t wname[1024]; unsigned int i; if (!(cs->cs_GN(wname) & 1)) return print_error("GN()"); /* XXX */ for (i = 0; i < (sizeof(wname)/sizeof(wchar_t)); i++) { if (wname[i] == 0) break; *name++ = (char) ((unsigned char) wname[i]); } *name = 0; return 0; } static int get_guid(struct cstate *cs, char *param) { IP_ADAPTER_INFO ai[16]; DWORD len = sizeof(ai); PIP_ADAPTER_INFO p; char name[1024]; int found; if (get_name(cs, name) == -1) return print_error("get_name()"); print_debug("Name: %s", name); if (GetAdaptersInfo(ai, &len) != ERROR_SUCCESS) return print_error("GetAdaptersInfo()"); p = ai; while (p) { print_debug("get_guid: name: %s desc: %s", p->AdapterName, p->Description); found = (param && strcmp(p->AdapterName, param) == 0) || strstr(p->Description, name); /* XXX */ if (cs->cs_debug) { char yea[512]; printf("Does this look like your card? [y/n]\n"); yea[0] = 0; fgets(yea, sizeof(yea), stdin); if (yea[0] == 'y') found = 1; else found = 0; } if (found) { snprintf(cs->cs_guid, sizeof(cs->cs_guid)-1, "%s", p->AdapterName); return 0; } p = p->Next; } return print_error("Adapter not found"); } static int open_key(struct cstate *cs, char *name) { char key[256]; DWORD dt, len = sizeof(key); /* open key */ snprintf(key, sizeof(key)-1, "%s\\%s", ADAPTER_KEY, name); if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, key, 0, KEY_ALL_ACCESS, &cs->cs_key) != ERROR_SUCCESS) return print_error("RegOpenKeyEx()"); /* check if its our guid */ if ((RegQueryValueEx(cs->cs_key, "NetCfgInstanceId", NULL, &dt, (unsigned char*)key, &len) == ERROR_SUCCESS) && (dt == REG_SZ) && (strcmp(key, cs->cs_guid) == 0)) return 1; /* closekey done by cleanup */ /* nope */ RegCloseKey(cs->cs_key); cs->cs_key = NULL; return 0; } static int open_conf(struct cstate *cs) { HKEY ak47; int rc = -1; int i; char name[256]; DWORD len; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, ADAPTER_KEY, 0, KEY_READ, &ak47) != ERROR_SUCCESS) return print_error("RegOpenKeyEx()"); for (i = 0;; i++) { len = sizeof(name); if (RegEnumKeyEx(ak47, i, name, &len, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) break; rc = open_key(cs, name); if (rc) break; else rc = -1; } RegCloseKey(ak47); return rc; } static int check_param(struct cstate *cs, char **p) { char *param = *p; /* assume it's ifname */ if (strncmp(param, "eth", 3) == 0) { snprintf(cs->cs_param, sizeof(cs->cs_param), "%s", param); snprintf(cs->cs_ifreq.ifr_name, sizeof(cs->cs_ifreq.ifr_name), "%s", cs->cs_param); cs->cs_ioctls = socket(PF_INET, SOCK_DGRAM, 0); if (cs->cs_ioctls == -1) { cs->cs_ioctls = 0; return print_error("socket()"); } } else if(strcmp(param, "debug") == 0) { cs->cs_debug = 1; *p = NULL; } return 0; } int cygwin_init(char *param) { struct cstate *cs = get_cs(); memset(cs, 0, sizeof(*cs)); cs->cs_chan = 1; if (pthread_mutex_init(&cs->cs_mtx, NULL)) return print_error("pthread_mutex_init()"); if (param) { if (check_param(cs, &param)) return -1; } if (init_lib(cs) == -1) return print_error("init_lib()"); if (get_guid(cs, param) == -1) return print_error("get_guid()"); if (open_conf(cs) == -1) return print_error("open_conf()"); return 0; } int cygwin_set_chan(int chan) { struct cstate *cs = get_cs(); if (!cs->cs_CC(chan)) return -1; cs->cs_chan = chan; return 0; } int cygwin_inject(void *buf, int len, struct tx_info *ti) { struct cstate *cs = get_cs(); if (ti) {} /* XXX unused */ if (!cs->cs_T1(len, buf)) return -1; return len; } static int read_single_packet(struct cstate *cs, unsigned char *buf, int len, struct rx_info *ri) { static unsigned char data[BUFSIZE]; static int totlen = 0; static unsigned char *next; struct CV_Header *cvh; struct CV_Header2 *cvh2; unsigned char *hdr; int align, plen; /* read data if necessary */ if (totlen == 0) { /* XXX can't kill iface if we're reading */ if (pthread_mutex_lock(&cs->cs_mtx)) return -1; totlen = cs->cs_S5(data, sizeof(data)); if (pthread_mutex_unlock(&cs->cs_mtx)) return -1; if (totlen < 1) return -1; next = data; } /* copy packet */ cvh = (struct CV_Header*) next; cvh2 = (struct CV_Header2*) (cvh+1); hdr = (unsigned char*) (cvh2+1); plen = cvh->SliceSize - sizeof(*cvh2); assert(plen > 0); if (plen < len) len = plen; memcpy(buf, hdr, len); if (ri) ri->ri_power = cvh2->Power; /* go to next packet */ next = hdr + plen; align = ((unsigned long)next - (unsigned long)cvh ) % 4; if (align) align = 4 - align; next += align; totlen -= sizeof(*cvh) + cvh->SliceSize; assert(totlen >= 0); if (totlen > 0) totlen -= align; assert(totlen >= 0); return (cvh2->ErrorFlag & 1) ? 0 : len; } int cygwin_sniff(void *buf, int len, struct rx_info *ri) { struct cstate *cs = get_cs(); int rc; int tries = 60; while ((rc = read_single_packet(cs, buf, len, ri)) == 0); if (rc != -1) return rc; /* check if we're restarting */ while (cs->cs_restarting && tries--) { /* try again */ if (cs->cs_restarting == 2) { cs->cs_restarting = 0; return cygwin_sniff(buf, len, ri); } sleep(1); } return rc; } static int do_get_mac_win(struct cstate *cs, unsigned char *mac) { IP_ADAPTER_INFO ai[16]; DWORD len = sizeof(ai); PIP_ADAPTER_INFO p; if (GetAdaptersInfo(ai, &len) != ERROR_SUCCESS) return -1; p = ai; while (p) { if (strcmp(cs->cs_guid, p->AdapterName) == 0) { memcpy(mac, p->Address, 6); return 0; } p = p->Next; } return -1; } static int do_get_mac_cygwin(struct cstate *cs, unsigned char *mac) { if (ioctl(cs->cs_ioctls, SIOCGIFHWADDR, &cs->cs_ifreq) == -1) return -1; memcpy(mac, cs->cs_ifreq.ifr_addr.sa_data, 6); return 0; } int cygwin_get_mac(unsigned char *mac) { struct cstate *cs = get_cs(); if (cs->cs_ioctls) return do_get_mac_cygwin(cs, mac); return do_get_mac_win(cs, mac); } static int is_us2(struct cstate *cs, HDEVINFO *hdi, SP_DEVINFO_DATA *did) { char buf[256]; DWORD len = sizeof(buf), dt; if (cs) {} /* XXX unused */ if (!SetupDiGetDeviceRegistryProperty(*hdi, did, SPDRP_DEVICEDESC, &dt, (unsigned char*)buf, len, &len)) return 0; if (dt != REG_SZ) return 0; return strstr(buf, "CommView") != NULL; } static int reset_state(HDEVINFO *hdi, SP_DEVINFO_DATA *did, DWORD state) { SP_PROPCHANGE_PARAMS parm; parm.ClassInstallHeader.cbSize = sizeof(parm.ClassInstallHeader); parm.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE; parm.Scope = DICS_FLAG_GLOBAL; parm.StateChange = state; if (!SetupDiSetClassInstallParams(*hdi, did, (SP_CLASSINSTALL_HEADER*) &parm, sizeof(parm))) return -1; if (!SetupDiCallClassInstaller(DIF_PROPERTYCHANGE, *hdi, did)) return -1; return 0; } static int do_reset(HDEVINFO *hdi, SP_DEVINFO_DATA *did) { int rc; rc = reset_state(hdi, did, DICS_DISABLE); if (rc) return rc; return reset_state(hdi, did, DICS_ENABLE); } static int restart(struct cstate *cs) { int rc; rc = do_init_lib(cs); return rc; } static int reset(struct cstate *cs) { HDEVINFO hdi; SP_DEVINFO_DATA did; int i; int rc = -1; hdi = SetupDiGetClassDevs(&GUID_DEVCLASS_NET, NULL, NULL, DIGCF_PRESENT); if (hdi == INVALID_HANDLE_VALUE) return -1; /* find device */ for (i = 0;; i++) { did.cbSize = sizeof(did); if (!SetupDiEnumDeviceInfo(hdi, i, &did)) break; if (!is_us2(cs, &hdi, &did)) continue; /* XXX we are blocked on reader. */ if (pthread_mutex_lock(&cs->cs_mtx)) break; cs->cs_restarting = 1; /* kill lib */ if (!cs->cs_F2()) break; /* reset NIC */ rc = do_reset(&hdi, &did); if (rc) break; sleep(1); /* XXX seems necessary */ /* reinit lib */ rc = restart(cs); cs->cs_restarting = 2; /* done */ if (pthread_mutex_unlock(&cs->cs_mtx)) break; break; } SetupDiDestroyDeviceInfoList(hdi); return rc; } int cygwin_set_mac(unsigned char *mac) { struct cstate *cs = get_cs(); char str[2*6+1]; char strold[sizeof(str)]; int i; char *key = "NetworkAddress"; DWORD dt, len = sizeof(strold); /* convert */ str[0] = 0; for (i = 0; i < 6; i++) { char tmp[3]; if (sprintf(tmp, "%.2X", *mac++) != 2) return -1; strcat(str, tmp); } /* check old */ if ((RegQueryValueEx(cs->cs_key, key, NULL, &dt, (unsigned char*) strold, &len) == ERROR_SUCCESS) && (dt == REG_SZ)) { if (strcmp(str, strold) == 0) return 0; } /* set */ if (RegSetValueEx(cs->cs_key, key, 0, REG_SZ, (unsigned char *)str, strlen(str)+1) != ERROR_SUCCESS) return -1; if (reset(cs) == -1) return -1; return 0; } void cygwin_close(void) { struct cstate *cs = get_cs(); if (cs->cs_ioctls) close(cs->cs_ioctls); if (cs->cs_key) RegCloseKey(cs->cs_key); if (cs->cs_lib) { cs->cs_F2(); dlclose(cs->cs_lib); } }
aircrack-ng/contrib/commview/Makefile
ROOT = ../.. include $(ROOT)/common.mak CFLAGS += $(PIC) -I$(ROOT)/src/osdep OBJS = commview.o DLL = commview.dll LIBS = -liphlpapi -lsetupapi -luuid -lpthread all: $(DLL) $(DLL): $(OBJS) $(CC) -shared -o $(DLL) $(OBJS) $(LIBS) clean: rm -f $(DLL) $(OBJS)
aircrack-ng/contrib/peek/Makefile
ROOT = ../.. include $(ROOT)/common.mak CFLAGS += $(PIC) -I$(ROOT)/src/osdep NAME = omnipeek OBJS = $(NAME).o DLL = $(NAME).dll LIBS = all: $(DLL) $(DLL): $(OBJS) $(CC) -shared -o $(DLL) $(OBJS) $(LIBS) clean: rm -f $(DLL) $(OBJS)
C
aircrack-ng/contrib/peek/omnipeek.c
/* ripped from devine's windows airodump */ #include <string.h> #include <dlfcn.h> #include <windows.h> #include <pthread.h> #include <assert.h> #include <err.h> #include "osdep.h" #include "cygwin.h" #ifdef UNUSED #elif defined(__GNUC__) # define UNUSED(x) UNUSED_ ## x __attribute__((unused)) #elif defined(__LCLINT__) # define UNUSED(x) /*@unused@*/ x #else # define UNUSED(x) x #endif #define MAGIC1 0x3E8000 #define MAGIC2 0x21 #define MAGICCHAN 0xFF636713 struct pstate { void *ps_lib; HANDLE ps_adapter; HANDLE ps_ctx; pthread_cond_t ps_sem; pthread_mutex_t ps_mtx; unsigned char ps_data[4096]; int ps_len; int (*ps_peek_initialize_library)(void); HANDLE (*ps_peek_open_adapter)(LPSTR); int (*ps_peek_start_capture)(HANDLE); int (*ps_peek_request)(HANDLE, void*, void*); int (*ps_peek_stop_capture)(HANDLE); int (*ps_peek_close_adapter)(HANDLE); int (*ps_peek_packet_send)(HANDLE, void*, int, int*, LPOVERLAPPED, int); HANDLE (*ps_peek_create_capture_context)(HANDLE, void*, int, int, void*); } _pstate; static struct pstate *get_ps(void) { return &_pstate; } static int init_lib(struct pstate *ps) { char *libname = "Peek.dll"; void *lib; if (!(lib = dlopen(libname, RTLD_LAZY))) return -1; ps->ps_lib = lib; ps->ps_peek_open_adapter = dlsym(lib, "PeekOpenAdapter"); ps->ps_peek_start_capture = dlsym(lib, "PeekStartCapture"); ps->ps_peek_request = dlsym(lib, "PeekRequest"); ps->ps_peek_stop_capture = dlsym(lib, "PeekStopCapture"); ps->ps_peek_close_adapter = dlsym(lib, "PeekCloseAdapter"); ps->ps_peek_packet_send = dlsym(lib, "PeekPacketSend"); ps->ps_peek_create_capture_context = dlsym(lib, "PeekCreateCaptureContext"); ps->ps_peek_initialize_library = dlsym(lib, "PeekInitializeLibrary"); if (!(ps->ps_peek_open_adapter && ps->ps_peek_start_capture && ps->ps_peek_request && ps->ps_peek_stop_capture && ps->ps_peek_close_adapter && ps->ps_peek_packet_send && ps->ps_peek_create_capture_context && ps->ps_peek_initialize_library )) return -1; return 0; } static void do_cleanup(struct pstate *ps) { if (!ps->ps_lib) return; if (ps->ps_ctx != INVALID_HANDLE_VALUE) ps->ps_peek_stop_capture(ps->ps_ctx); if (ps->ps_adapter != INVALID_HANDLE_VALUE) ps->ps_peek_close_adapter(ps->ps_adapter); dlclose(ps->ps_lib); } static int set_chan(struct pstate *ps, int channel) { unsigned long reqdata[139]; OVERLAPPED iodata; memset(reqdata, 0, sizeof(reqdata)); memset(&iodata, 0, sizeof(iodata)); iodata.hEvent = CreateEvent(0, 0, 0, 0); reqdata[5] = 1; reqdata[6] = MAGICCHAN; reqdata[7] = (unsigned long) &channel; reqdata[8] = 4; return ps->ps_peek_request(ps->ps_adapter, reqdata, &iodata); } static void do_lock(struct pstate *ps) { if (pthread_mutex_lock(&ps->ps_mtx)) err(1, "pthread_mutex_lock()"); } static void do_signal(struct pstate *ps) { do_lock(ps); if (pthread_cond_signal(&ps->ps_sem)) err(1, "pthread_cond_signal()"); } static void do_wait(struct pstate *ps) { do_lock(ps); if (pthread_cond_wait(&ps->ps_sem, &ps->ps_mtx)) err(1, "pthread_cond_wait()"); } static int WINAPI callback(unsigned char *data, int len, int UNUSED(caplen), __int64 UNUSED(timestamp), int flags, int UNUSED(arg7)) { struct pstate *ps = get_ps(); if ((flags & 1) != 0) return 1; assert(len <= (int) sizeof(ps->ps_data)); ps->ps_len = len; memcpy(ps->ps_data, data, ps->ps_len); /* tell him we wrote */ do_signal(ps); /* wait for him to copy */ do_wait(ps); return 1; } static int init_card(struct pstate *ps, char *dev) { int rc, len; char *unicode, *p; if (ps->ps_peek_initialize_library() == 0) return -1; /* convert dev to unicode - i'm sure there's a standard function, but * aingottime. * Format: \Device\{GUID} */ if (!dev) return -1; len = strlen(dev); unicode = p = malloc((len+1)*2); if (!unicode) return -1; for (rc = 0; rc < len; rc++) { *p++ = dev[rc]; *p++ = 0; } *p++ = 0; *p++ = 0; ps->ps_adapter = ps->ps_peek_open_adapter(unicode); free(unicode); if (ps->ps_adapter == INVALID_HANDLE_VALUE) return -1; ps->ps_ctx = ps->ps_peek_create_capture_context(ps->ps_adapter, callback, MAGIC1, MAGIC2, NULL); if ((rc = ps->ps_peek_start_capture(ps->ps_ctx))) return rc; return set_chan(ps, 1); } int CYGWIN_DLL_INIT (char *param) { struct pstate *ps = get_ps(); int rc; memset(ps, 0, sizeof(*ps)); ps->ps_adapter = INVALID_HANDLE_VALUE; ps->ps_ctx = INVALID_HANDLE_VALUE; if ((rc = pthread_cond_init(&ps->ps_sem, NULL))) goto out; if ((rc = pthread_mutex_init(&ps->ps_mtx, NULL))) goto out; if ((rc = init_lib(ps))) goto out; if ((rc = init_card(ps, param))) goto out; return 0; out: do_cleanup(ps); return rc; } int CYGWIN_DLL_SET_CHAN (int chan) { struct pstate *ps = get_ps(); return set_chan(ps, chan) ? -1 : 0; } int CYGWIN_DLL_INJECT (void* buf, int len, struct tx_info* UNUSED(ti)) { struct pstate *ps = get_ps(); int rc; int wrote = 0; OVERLAPPED iodata; memset(&iodata, 0, sizeof(iodata)); iodata.hEvent = CreateEvent(0, 0, 0, 0); rc = ps->ps_peek_packet_send(ps->ps_adapter, buf, len, &wrote, &iodata, 0); if (rc) return rc; return len; } int CYGWIN_DLL_SNIFF (void *buf, int len, struct rx_info* UNUSED(ri)) { struct pstate *ps = get_ps(); /* wait for shit */ do_wait(ps); /* copy it */ if (ps->ps_len < len) len = ps->ps_len; memcpy(buf, ps->ps_data, len); /* tell him we're done */ do_signal(ps); return len; } int CYGWIN_DLL_GET_MAC (unsigned char* UNUSED(mac)) { return -1; } int CYGWIN_DLL_SET_MAC (unsigned char* UNUSED(mac)) { return -1; } void CYGWIN_DLL_CLOSE (void) { struct pstate *ps = get_ps(); do_cleanup(ps); }
Include
aircrack-ng/include/Makefile.inc
# Aircrack-ng # # Copyright (C) 2019 Joseph Benden <joe@benden.us> # # Autotool support was written by: Joseph Benden <joe@benden.us> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA # # In addition, as a special exception, the copyright holders give # permission to link the code of portions of this program with the # OpenSSL library under certain conditions as described in each # individual source file, and distribute linked combinations # including the two. # # You must obey the GNU General Public License in all respects # for all of the code used other than OpenSSL. # # If you modify file(s) with this exception, you may extend this # exception to your dnl version of the file(s), but you are not obligated # to do so. # # If you dnl do not wish to do so, delete this exception statement from your # version. # # If you delete this exception statement from all source files in the # program, then also delete it here. aircrackdir = $(includedir)/../ nobase_aircrack_HEADERS = %D%/aircrack-ng/adt/avl_tree.h \ %D%/aircrack-ng/adt/circular_buffer.h \ %D%/aircrack-ng/adt/circular_queue.h \ %D%/aircrack-ng/aircrack-ng.h \ %D%/aircrack-ng/ce-wep/uniqueiv.h \ %D%/aircrack-ng/ce-wpa/wpapsk.h \ %D%/aircrack-ng/ce-wpa/arch.h \ %D%/aircrack-ng/ce-wpa/simd-intrinsics-load-flags.h \ %D%/aircrack-ng/ce-wpa/misc.h \ %D%/aircrack-ng/ce-wpa/simd-intrinsics.h \ %D%/aircrack-ng/ce-wpa/pseudo_intrinsics.h \ %D%/aircrack-ng/ce-wpa/memory.h \ %D%/aircrack-ng/ce-wpa/aligned.h \ %D%/aircrack-ng/ce-wpa/johnswap.h \ %D%/aircrack-ng/ce-wpa/jcommon.h \ %D%/aircrack-ng/ce-wpa/crypto_engine.h \ %D%/aircrack-ng/cowpatty/cowpatty.h \ %D%/aircrack-ng/cpu/cpuset.h \ %D%/aircrack-ng/cpu/simd_cpuid.h \ %D%/aircrack-ng/cpu/trampoline.h \ %D%/aircrack-ng/crypto/aes.h \ %D%/aircrack-ng/crypto/arcfour.h \ %D%/aircrack-ng/crypto/crctable.h \ %D%/aircrack-ng/crypto/crypto.h \ %D%/aircrack-ng/crypto/mac.h \ %D%/aircrack-ng/crypto/md5.h \ %D%/aircrack-ng/crypto/sha1.h \ %D%/aircrack-ng/crypto/sha1-git.h \ %D%/aircrack-ng/crypto/sha256.h \ %D%/aircrack-ng/compat.h \ %D%/aircrack-ng/defs.h \ %D%/aircrack-ng/osdep/byteorder.h \ %D%/aircrack-ng/osdep/channel.h \ %D%/aircrack-ng/osdep/common.h \ %D%/aircrack-ng/osdep/network.h \ %D%/aircrack-ng/osdep/osdep.h \ %D%/aircrack-ng/osdep/packed.h \ %D%/aircrack-ng/pcre/compat-pcre.h \ %D%/aircrack-ng/ptw/aircrack-ptw-lib.h \ %D%/aircrack-ng/support/common.h \ %D%/aircrack-ng/support/communications.h \ %D%/aircrack-ng/support/crypto_engine_loader.h \ %D%/aircrack-ng/support/fragments.h \ %D%/aircrack-ng/support/mcs_index_rates.h \ %D%/aircrack-ng/support/pcap_local.h \ %D%/aircrack-ng/support/station.h \ %D%/aircrack-ng/third-party/ieee80211.h \ %D%/aircrack-ng/third-party/if_arp.h \ %D%/aircrack-ng/third-party/eapol.h \ %D%/aircrack-ng/third-party/ethernet.h \ %D%/aircrack-ng/third-party/if_llc.h \ %D%/aircrack-ng/third-party/hashcat.h \ %D%/aircrack-ng/tui/console.h \ %D%/aircrack-ng/utf8/verifyssid.h \ %D%/aircrack-ng/version.h EXTRA_DIST += $(nobase_aircrack_HEADERS)
C/C++
aircrack-ng/include/aircrack-ng/aircrack-ng.h
/* * 802.11 WEP / WPA-PSK Key Cracker * * Copyright (C) 2007-2012 Martin Beck <martin.beck2@gmx.de> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef _AIRCRACK_NG_H #define _AIRCRACK_NG_H #include <stddef.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <time.h> #include <sys/time.h> #if defined(__FreeBSD__) || defined(__MidnightBSD__) #include <unistd.h> #endif #include <pthread.h> #include <aircrack-ng/ptw/aircrack-ptw-lib.h> #include <aircrack-ng/third-party/eapol.h> #include <aircrack-ng/ce-wpa/crypto_engine.h> #include <aircrack-ng/adt/avl_tree.h> #include <aircrack-ng/adt/circular_queue.h> #define SUCCESS 0 #define FAILURE 1 #define RESTART 2 #ifndef O_BINARY #define O_BINARY 0 #endif #define MAX_DICTS 128 #define ASCII_LOW_T 0x21 #define ASCII_HIGH_T 0x7E #define ASCII_VOTE_STRENGTH_T 150 #define ASCII_DISREGARD_STRENGTH 1 #define TEST_MIN_IVS 4 #define TEST_MAX_IVS 32 #define PTW_TRY_STEP 5000 #define KEYHSBYTES PTW_KEYHSBYTES #define MAX_THREADS 256 #ifndef WL_CIRCULAR_QUEUE_SIZE #define WL_CIRCULAR_QUEUE_SIZE (32 * 1024) #endif #define CLOSE_IT 100000 #define S_LLC_SNAP "\xAA\xAA\x03\x00\x00\x00" #define S_LLC_SNAP_ARP (S_LLC_SNAP "\x08\x06") #define S_LLC_SNAP_IP (S_LLC_SNAP "\x08\x00") #define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */ #define KEYLIMIT 1000000 #define N_ATTACKS 17 enum KoreK_attacks { A_u15, /* semi-stable 15% */ A_s13, /* stable 13% */ A_u13_1, /* unstable 13% */ A_u13_2, /* unstable ? 13% */ A_u13_3, /* unstable ? 13% */ A_s5_1, /* standard 5% (~FMS) */ A_s5_2, /* other stable 5% */ A_s5_3, /* other stable 5% */ A_u5_1, /* unstable 5% no good ? */ A_u5_2, /* unstable 5% */ A_u5_3, /* unstable 5% no good */ A_u5_4, /* unstable 5% */ A_s3, /* stable 3% */ A_4_s13, /* stable 13% on q = 4 */ A_4_u5_1, /* unstable 5% on q = 4 */ A_4_u5_2, /* unstable 5% on q = 4 */ A_neg /* helps reject false positives */ }; struct dictfiles { off_t dictsize; /* Total file size */ off_t dictpos; /* Current position of dictionary */ off_t wordcount; /* Total amount of words in dict file */ int loaded; /* Have finished processing? */ }; struct options { int amode; /* attack mode */ int essid_set; /* essid set flag */ int bssid_set; /* bssid set flag */ char essid[33]; /* target ESSID */ unsigned char bssid[6]; /* target BSSID */ int nbcpu; /* # of cracker threads (= # of CPU) */ int is_quiet; /* quiet mode flag */ unsigned char debug[64]; /* user-defined WEP key */ int debug_row[64]; /* user-defined Row WEP key */ unsigned char maddr[6]; /* MAC address filter */ int keylen; /* WEP key length */ int index; /* WEP key index */ float ffact; /* bruteforce factor */ int korek; /* attack strategy */ int is_fritz; /* use numeric keyspace */ int is_alnum; /* alphanum keyspace */ int is_bcdonly; /* binary coded decimal */ int do_brute; /* bruteforce last 2 KB */ int do_mt_brute; /* bruteforce last 2 KB multithreaded for SMP*/ int do_testy; /* experimental attack */ int do_ptw; /* PTW WEP attack */ char * dicts[MAX_DICTS]; /* dictionary files */ FILE * dict; /* dictionary file */ int nbdict; /* current dict number */ int no_stdin; /* if dict == stdin */ int hexdict[MAX_DICTS]; /* if dict in hex */ size_t wordcount; /* Total wordcount for all dicts*/ struct dictfiles dictidx[MAX_DICTS]; /* Dictionary structure */ int totaldicts; /* total loaded dictionaries */ int dictfinish; /* finished processing all dicts*/ int showASCII; /* Show ASCII version of*/ /* the wepkey */ int l33t; /* no comment */ int stdin_dict; int probability; /* %of correct answers */ int votes[N_ATTACKS]; /* votes for korek attacks */ int brutebytes[64]; /* bytes to bruteforce */ int next_ptw_try; int max_ivs; char * bssidmerge; unsigned char * firstbssid; struct mergeBSSID * bssid_list_1st; struct AP_info * ap; int wep_decloak; int ptw_attack; int visual_inspection; /* Enabling/disabling visual */ /* inspection of the different */ /* keybytes */ int oneshot; /* Do PTW once */ char * logKeyToFile; int forced_amode; /* signals disregarding automatic detection of encryption type */ char * wkp; /* EWSA Project file */ char * hccap; /* Hashcat capture file */ char * hccapx; /* Hashcat X (3.6+) capture file */ }; typedef struct { int idx, val; } vote; struct WEP_data { unsigned char key[64]; /* the current chosen WEP key */ unsigned char * ivbuf; /* buffer holding all the IVs */ int nb_aps; /* number of targeted APs */ long nb_ivs; /* # of unique IVs in buffer */ long nb_ivs_now; /* # of unique IVs available */ int fudge[64]; /* bruteforce level (1 to 256) */ int depth[64]; /* how deep we are in the fudge */ vote poll[64][256]; /* KoreK cryptanalysis results */ }; #include <aircrack-ng/support/station.h> struct mergeBSSID { unsigned char bssid[6]; /* BSSID */ char unused[2]; /* Alignment */ int convert; /* Does this BSSID has to */ /* be converted */ struct mergeBSSID * next; }; #define WPA_DATA_KEY_BUFFER_LENGTH 128 struct WPA_data { int active; ac_crypto_engine_t engine; struct AP_info * ap; /* AP information */ int thread; /* number of this thread */ int threadid; /* id of this thread */ char key[WPA_DATA_KEY_BUFFER_LENGTH]; /* cracked key (0 while not found) */ uint8_t * key_buffer; cqueue_handle_t cqueue; pthread_mutex_t mutex; }; void show_wep_stats(int B, int force, PTW_tableentry table[PTW_KEYHSBYTES][PTW_n], int choices[KEYHSBYTES], int depth[KEYHSBYTES], int prod); static inline int cmp_votes(const void * bs1, const void * bs2) { REQUIRE(bs1 != NULL); REQUIRE(bs2 != NULL); if (((vote *) bs1)->val < ((vote *) bs2)->val) return (1); if (((vote *) bs1)->val > ((vote *) bs2)->val) return (-1); return (0); } #endif /* _AIRCRACK_NG_H */
C/C++
aircrack-ng/include/aircrack-ng/compat.h
/** * Copyright (C) 2020-2022 Joseph Benden <joe@benden.us> * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. **/ #ifndef AIRCRACK_NG_COMPAT_H #define AIRCRACK_NG_COMPAT_H #include <stdint.h> #ifdef __cplusplus extern "C" { #endif #ifdef HAVE_BSD_STRING_H #include <bsd/string.h> #endif #if !defined(HAVE_STRLCAT) && !defined(__APPLE__) && !defined(__MACH__) /** * Appends src to string dst of size dsize (unlike strncat, dsize is the * full size of dst, not space left). At most dsize-1 characters * will be copied. Always NUL terminates (unless dsize <= strlen(dst)). * Returns strlen(src) + MIN(dsize, strlen(initial dst)). * If retval >= dsize, truncation occurred. */ API_IMPORT size_t strlcat(char * restrict dst, const char * restrict src, size_t dsize); #endif #if !defined(HAVE_STRLCPY) && !defined(__APPLE__) && !defined(__MACH__) /** * Copy string src to buffer dst of size dsize. At most dsize-1 * chars will be copied. Always NUL terminates (unless dsize == 0). * Returns strlen(src); if retval >= dsize, truncation occurred. */ API_IMPORT size_t strlcpy(char * restrict dst, const char * restrict src, size_t dsize); #endif #ifdef __cplusplus } #endif #endif
C/C++
aircrack-ng/include/aircrack-ng/defs.h
/** * Copyright (C) 2018-2022 Joseph Benden <joe@benden.us> * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. **/ #ifndef AIRCRACK_NG_DEFS_H #define AIRCRACK_NG_DEFS_H #include <stdlib.h> #include <stdint.h> #include <stdio.h> #include <stddef.h> #include <stdbool.h> #include <string.h> #include <assert.h> // PVS-Studio warning opt-outs: //-V:ALLEGE:547 //-V:REQUIRE:547 //-V:ENSURE:547 //-V:INVARIANT:547 // NOTE(jbenden): These macros violates MISRA C:2012. 20.10 - The # // and ## preprocessor operators should not be used. #define ALLEGE(c) \ do \ { \ if (!(c)) \ { \ fprintf(stderr, "FAILED:%s:%d: %s\n", __FILE__, __LINE__, #c); \ abort(); \ } \ } while (0) #define REQUIRE(c) \ do \ { \ if (!(c)) \ { \ fprintf(stderr, "Pre-condition Failed: %s\n", #c); \ abort(); \ } \ } while (0) #define ENSURE(c) \ do \ { \ if (!(c)) \ { \ fprintf(stderr, "Post-condition Failed: %s\n", #c); \ abort(); \ } \ } while (0) #define INVARIANT(c) \ do \ { \ if (!(c)) \ { \ fprintf(stderr, "Invariant Failed: %s\n", #c); \ abort(); \ } \ } while (0) #ifdef NDEBUG #undef REQUIRE #define REQUIRE(c) #undef ENSURE #define ENSURE(c) #undef INVARIANT #define INVARIANT(c) #endif #if defined(_MSC_VER) // Microsoft #define API_EXPORT __declspec(dllexport) #define API_IMPORT __declspec(dllimport) #elif defined(__GNUC__) || defined(__llvm__) || defined(__clang__) \ || defined(__INTEL_COMPILER) #define API_EXPORT __attribute__((visibility("default"))) #define API_IMPORT #else // do nothing and hope for the best? #define API_EXPORT #define API_IMPORT #pragma warning Unknown dynamic link import / export semantics. #endif #define STATIC_ASSERT(COND, MSG) \ typedef char static_assertion_##MSG[(!!(COND)) * 2 - 1] // token pasting madness: #define COMPILE_TIME_ASSERT3(X, L) \ STATIC_ASSERT(X, static_assertion_at_line_##L) #define COMPILE_TIME_ASSERT2(X, L) COMPILE_TIME_ASSERT3(X, L) #define COMPILE_TIME_ASSERT(X) COMPILE_TIME_ASSERT2(X, __LINE__) #if defined(__GNUC__) || defined(__llvm__) || defined(__clang__) \ || defined(__INTEL_COMPILER) #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #else #define likely(x) (x) #define unlikely(x) (x) #endif #if defined(HAS_ATTRIBUTE) #undef HAS_ATTRIBUTE #endif #if defined(__has_attribute) #define HAS_ATTRIBUTE(attribute) __has_attribute(attribute) #else #define HAS_ATTRIBUTE(attribute) (0) #endif #if defined(fallthrough) #undef fallthrough #endif #if defined(__GNUC__) && __GNUC__ >= 11 && !defined(__INTEL_COMPILER) \ && !defined(__llvm__) && !defined(__clang__) #define fallthrough __attribute__((fallthrough)) #elif HAS_ATTRIBUTE(fallthrough) \ || (defined(__GNUC__) && __GNUC__ >= 7 && !defined(__INTEL_COMPILER) \ && !defined(__llvm__) \ && !defined(__clang__)) #define fallthrough __attribute__((__fallthrough__)) #else #define fallthrough #endif #define UNUSED_PARAM(x) (void) x #ifdef UNUSED #elif defined(__GNUC__) #define UNUSED(x) UNUSED_##x __attribute__((unused)) #elif defined(__LCLINT__) #define UNUSED(x) /*@unused@*/ x #else #define UNUSED(x) x #endif #define ArrayCount(a) (sizeof((a)) / sizeof((a)[0])) #define THREAD_ENTRY(fn) void * __attribute__((noinline)) fn(void * arg) #define IGNORE_LTZ(c) \ do \ { \ int __rc = (c); \ if (__rc < 0) \ { \ fprintf(stderr, \ "%s:%d:Function failed(%d:%d): %s\n", \ __FILE__, \ __LINE__, \ __rc, \ errno, \ #c); \ } \ } while (0) #define IGNORE_NZ(c) \ do \ { \ int __rc = (c); \ if (__rc != 0) \ { \ fprintf(stderr, \ "%s:%d:Function failed(%d:%d): %s\n", \ __FILE__, \ __LINE__, \ __rc, \ errno, \ #c); \ } \ } while (0) #define IGNORE_ZERO(c) \ do \ { \ if ((c) == 0) \ { \ fprintf(stderr, \ "%s:%d:Function failed(%d): %s\n", \ __FILE__, \ __LINE__, \ errno, \ #c); \ } \ } while (0) #if __STDC_VERSION__ >= 199901L #define DO_PRAGMA(x) _Pragma(#x) #else #define DO_PRAGMA(x) #endif #if defined(__clang_major__) && __clang_major__ >= 4 #define UNROLL_LOOP_N_TIME(n) DO_PRAGMA(clang loop unroll_count(n)) #elif defined(__GNUC__) && __GNUC__ >= 8 #define UNROLL_LOOP_N_TIME(n) DO_PRAGMA(GCC unroll n) #else #define UNROLL_LOOP_N_TIME(n) #endif #include <aircrack-ng/compat.h> #ifdef __cplusplus extern "C" { #endif static inline size_t ustrlen(const uint8_t * s1) { return strlen((const char *) s1); } #define destroy(var, fn) \ __extension__({ \ if ((var) != NULL) \ { \ fn((__typeof__(var))(var)); \ \ (var) = NULL; \ } \ }) #ifdef __cplusplus } #endif #endif
Inno Setup Script
aircrack-ng/include/aircrack-ng/version.h.in
/* * (c) 2010-2022 Thomas d'Otreppe <tdotreppe@aircrack-ng.org> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #define _MAJ @_MAJ@ #define _MIN @_MIN@ #define _SUB_MIN @_SUB_MIN@ #define _BETA @_BETA@ #define _RC @_RC@ #define _SCM "@_SCM@" #define LT_VER @LT_VER@ #define WEBSITE "https://aircrack-ng.org" extern char * getVersion(const char * progname, const unsigned int maj, const unsigned int min, const unsigned int submin, const char * rev, const unsigned int beta, const unsigned int rc);
C/C++
aircrack-ng/include/aircrack-ng/adt/avl_tree.h
/** * collectd - src/utils_avltree.h * Copyright (C) 2006,2007 Florian octo Forster * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * * Authors: * Florian octo Forster <octo at collectd.org> **/ #ifndef UTILS_AVLTREE_H #define UTILS_AVLTREE_H 1 struct c_avl_tree_s; typedef struct c_avl_tree_s c_avl_tree_t; struct c_avl_iterator_s; typedef struct c_avl_iterator_s c_avl_iterator_t; /* * NAME * c_avl_create * * DESCRIPTION * Allocates a new AVL-tree. * * PARAMETERS * `compare' The function-pointer `compare' is used to compare two keys. It * has to return less than zero if its first argument is smaller * then the second argument, more than zero if the first argument * is bigger than the second argument and zero if they are equal. * If your keys are char-pointers, you can use the `strcmp' * function from the libc here. * * RETURN VALUE * A c_avl_tree_t-pointer upon success or NULL upon failure. */ c_avl_tree_t * c_avl_create(int (*compare)(const void *, const void *)); /* * NAME * c_avl_destroy * * DESCRIPTION * Deallocates an AVL-tree. Stored value- and key-pointer are lost, but of * course not freed. */ void c_avl_destroy(c_avl_tree_t * t); /* * NAME * c_avl_insert * * DESCRIPTION * Stores the key-value-pair in the AVL-tree pointed to by `t'. * * PARAMETERS * `t' AVL-tree to store the data in. * `key' Key used to store the value under. This is used to get back to * the value again. The pointer is stored in an internal structure * and _not_ copied. So the memory pointed to may _not_ be freed * before this entry is removed. You can use the `rkey' argument * to `avl_remove' to get the original pointer back and free it. * `value' Value to be stored. * * RETURN VALUE * Zero upon success, non-zero otherwise. It's less than zero if an error * occurred or greater than zero if the key is already stored in the tree. */ int c_avl_insert(c_avl_tree_t * t, void * key, void * value); /* * NAME * c_avl_remove * * DESCRIPTION * Removes a key-value-pair from the tree t. The stored key and value may be * returned in `rkey' and `rvalue'. * * PARAMETERS * `t' AVL-tree to remove key-value-pair from. * `key' Key to identify the entry. * `rkey' Pointer to a pointer in which to store the key. May be NULL. * Since the `key' pointer is not copied when creating an entry, * the pointer may not be available anymore from outside the tree. * You can use this argument to get the actual pointer back and * free the memory pointed to by it. * `rvalue' Pointer to a pointer in which to store the value. May be NULL. * * RETURN VALUE * Zero upon success or non-zero if the key isn't found in the tree. */ int c_avl_remove(c_avl_tree_t * t, const void * key, void ** rkey, void ** rvalue); /* * NAME * c_avl_get * * DESCRIPTION * Retrieve the `value' belonging to `key'. * * PARAMETERS * `t' AVL-tree to get the value from. * `key' Key to identify the entry. * `value' Pointer to a pointer in which to store the value. May be NULL. * * RETURN VALUE * Zero upon success or non-zero if the key isn't found in the tree. */ int c_avl_get(c_avl_tree_t * t, const void * key, void ** value); /* * NAME * c_avl_pick * * DESCRIPTION * Remove a (pseudo-)random element from the tree and return its `key' and * `value'. Entries are not returned in any particular order. This function * is intended for cache-flushes that don't care about the order but simply * want to remove all elements, one at a time. * * PARAMETERS * `t' AVL-tree to get the value from. * `key' Pointer to a pointer in which to store the key. * `value' Pointer to a pointer in which to store the value. * * RETURN VALUE * Zero upon success or non-zero if the tree is empty or key or value is * NULL. */ int c_avl_pick(c_avl_tree_t * t, void ** key, void ** value); c_avl_iterator_t * c_avl_get_iterator(c_avl_tree_t * t); int c_avl_iterator_next(c_avl_iterator_t * iter, void ** key, void ** value); int c_avl_iterator_prev(c_avl_iterator_t * iter, void ** key, void ** value); void c_avl_iterator_destroy(c_avl_iterator_t * iter); /* * NAME * c_avl_size * * DESCRIPTION * Return the size (number of nodes) of the specified tree. * * PARAMETERS * `t' AVL-tree to get the size of. * * RETURN VALUE * Number of nodes in the tree, 0 if the tree is empty or NULL. */ int c_avl_size(c_avl_tree_t * t); #endif /* UTILS_AVLTREE_H */
C/C++
aircrack-ng/include/aircrack-ng/adt/circular_buffer.h
/** * Copyright (C) 2018-2022 Joseph Benden <joe@benden.us> * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. **/ #ifndef AIRCRACK_UTIL_CIRCULAR_BUFFER_H #define AIRCRACK_UTIL_CIRCULAR_BUFFER_H #include <aircrack-ng/defs.h> /** * @file circular_buffer.h * * @brief An implementation of a non-thread-safe circular buffer. * * @author Joseph Benden <joe@benden.us> */ #ifdef __cplusplus extern "C" { #endif /// The type representing the internal data structure for a single /// circular buffer; unaccessible to public API consumers. typedef struct circular_buffer_t circular_buffer_t; /// The type representing a handle to a single circular buffer. typedef circular_buffer_t * cbuf_handle_t; /*! * @brief Create a new circular buffer. * @param[in] buffer A region of memory to be used for element storage. * @param[in] bufferSize The number of bytes available at @a buffer. * @param[in] elementSize The number of bytes used by a single entry stored. * @return A brand-new circular buffer handle, else NULL on error. */ API_IMPORT cbuf_handle_t circular_buffer_init(uint8_t * buffer, size_t bufferSize, size_t elementSize); /*! * @brief Release the memory used by the circular buffer. * @param[in] cbuf The circular buffer handle to operate upon. * * @par * The API consumer is expected to release the memory region * given to the @a circular_buffer_init function, by themselves. */ API_IMPORT void circular_buffer_free(cbuf_handle_t cbuf); /*! * @brief Reset the circular buffer back to its' initial state. * @param[in] cbuf The circular buffer handle to operate upon. */ API_IMPORT void circular_buffer_reset(cbuf_handle_t cbuf); /*! * @brief Store an entry to the circular buffer. * @param[in] cbuf The circular buffer handle to operate upon. * @param[in] data A buffer location for which we copy the data in from. * @param[in] size The length of the @a data memory buffer. This is * permitted to be less-than or equal-to the * element size. If less-than, the remaining bytes * of the element store are zeroed. * * @par * The memory location of @a data must not overlap the circular * buffer's memory location. This is because we internally use * the @f memcpy function. */ API_IMPORT void circular_buffer_put(cbuf_handle_t cbuf, void const * const data, size_t size); /*! * @brief Acquire an entry from the circular buffer. * @param[in] cbuf The circular buffer handle to operate upon. * @param[in] data A buffer location to which to copy the data out to. * @param[in] size The length of the @a data memory buffer. This is * permitted to be less-than or equal-to the * element size. * * @par * The memory location of @a data must not overlap the circular * buffer's memory location. This is because we internally use * the @f memcpy function. */ API_IMPORT void circular_buffer_get(cbuf_handle_t cbuf, void * const * data, size_t size); /*! * @brief Returns whether the circular buffer is empty. * @param[in] cbuf The circular buffer handle to operate upon. * @return A boolean representing the emptiness state of the * circular buffer. */ API_IMPORT bool circular_buffer_is_empty(cbuf_handle_t cbuf); /*! * @brief Returns whether the circular buffer is full. * @param[in] cbuf The circular buffer handle to operate upon. * @return A boolean representing the fullness state of the * circular buffer. */ API_IMPORT bool circular_buffer_is_full(cbuf_handle_t cbuf); /*! * @brief Returns the number of storable entries. * @param[in] cbuf The circular buffer handle to operate upon. * @return The number of entries that may be stored within the * circular buffer. */ API_IMPORT size_t circular_buffer_capacity(cbuf_handle_t cbuf); /*! * @brief Returns the number of currently stored entries. * @param[in] cbuf The circular buffer handle to operate upon. * @return The number of entries within the circular buffer. */ API_IMPORT size_t circular_buffer_size(cbuf_handle_t cbuf); #ifdef __cplusplus } #endif #endif
C/C++
aircrack-ng/include/aircrack-ng/adt/circular_queue.h
/* * Copyright (C) 2018-2022 Joseph Benden <joe@benden.us> * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ #ifndef AIRCRACK_UTIL_CIRCULAR_QUEUE_H #define AIRCRACK_UTIL_CIRCULAR_QUEUE_H #include <aircrack-ng/defs.h> /** * @file circular_queue.h * * @brief An implementation of a multi-threaded, blocking queue; which * internally uses a circular buffer for element storage. * * @author Joseph Benden <joe@benden.us> */ #ifdef __cplusplus extern "C" { #endif /// The type representing the internal data structure for a single /// blocking circular queue; unaccessible to public API consumers. typedef struct circular_queue_t circular_queue_t; /// The type representing a handle to a single blocking circular queue. typedef circular_queue_t * cqueue_handle_t; /*! * @brief Create a new blocking circular queue. * @param[in] buffer A region of memory to be used for element storage. * @param[in] bufferSize The number of bytes available at @a buffer. * @param[in] elementSize The number of bytes used by a single entry stored. * @return A brand-new circular queue handle, else NULL on error. */ API_IMPORT cqueue_handle_t circular_queue_init(uint8_t * buffer, size_t bufferSize, size_t elementSize); /*! * @brief Release the memory used by the circular queue. * @param[in] cq The circular queue handle to operate upon. * * @par * The API consumer is expected to release the memory region * given to the @a circular_queue_init function, by themselves. */ API_IMPORT void circular_queue_free(cqueue_handle_t cq); /*! * @brief Reset the circular queue back to its initial state. * @param[in] cq The circular queue handle to operate upon. */ API_IMPORT void circular_queue_reset(cqueue_handle_t cq); /*! * @brief Store an entry to the circular queue. * @param[in] cq The circular queue handle to operate upon. * @param[in] data A buffer location for which we copy the data in from. * @param[in] size The length of the @a data memory buffer. This is * permitted to be less-than or equal-to the * element size. If less-than, the remaining bytes * of the element stored are zeroed. * * @par * The memory location of @a data must not overlap the circular * queue's memory location. This is because we internally use * the @f memcpy function. */ API_IMPORT void circular_queue_push(cqueue_handle_t cq, void const * const data, size_t size); /*! * @brief Attempts to store an entry to the circular queue, if possible. * @param[in] cq The circular queue handle to operate upon. * @param[in] data A buffer location for which we copy the data in from. * @param[in] size The length of the @a data memory buffer. This is * permitted to be less-than or equal-to the * element size. If less-than, the remaining bytes * of the element stored are zeroed. * @return Result of operation is zero on success. * * @par * The memory location of @a data must not overlap the circular * queue's memory location. This is because we internally use * the @f memcpy function. */ API_IMPORT int circular_queue_try_push(cqueue_handle_t cq, void const * const data, size_t size); /*! * @brief Acquire an entry from the circular queue. * @param[in] cq The circular queue handle to operate upon. * @param[in] data A buffer location to which to copy the data out to. * @param[in] size The length of the @a data memory buffer. This is * permitted to be less-than or equal-to the * element size. * * @par * The memory location of @a data must not overlap the circular * queue's memory location. This is because we internally use * the @f memcpy function. */ API_IMPORT void circular_queue_pop(cqueue_handle_t cq, void * const * data, size_t size); /*! * @brief Returns whether the circular queue is empty. * @param[in] cq The circular queue handle to operate upon. * @return A boolean representing the emptiness state of the * circular queue. */ API_IMPORT bool circular_queue_is_empty(cqueue_handle_t cq); /*! * @brief Returns whether the circular queue is full. * @param[in] cq The circular queue handle to operate upon. * @return A boolean representing the fullness state of the * circular queue. */ API_IMPORT bool circular_queue_is_full(cqueue_handle_t cq); #ifdef __cplusplus } #endif #endif
C/C++
aircrack-ng/include/aircrack-ng/ce-wep/uniqueiv.h
/* * 802.11 WEP / WPA-PSK Key Cracker * * Copyright (C) 2007-2012 Martin Beck <martin.beck2@gmx.de> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef _UNIQUEIV_H #define _UNIQUEIV_H #define IV_NOTHERE 0 #define IV_PRESENT 1 /* select byte within which desired bit is located */ #define BITWISE_OFFT(x) ((x) >> 3) /* mask to extract desired bit */ #define BITWISE_MASK(x) (1 << ((x) &7)) unsigned char ** uniqueiv_init(void); int uniqueiv_mark(unsigned char ** uiv_root, unsigned char IV[3]); int uniqueiv_check(unsigned char ** uiv_root, unsigned char IV[3]); void uniqueiv_wipe(unsigned char ** uiv_root); #define NO_CLOAKING 0 #define CLOAKING 1 unsigned char * data_init(void); int data_check(unsigned char * data_root, unsigned char IV[3], unsigned char data[2]); void data_wipe(unsigned char * data); #endif
C/C++
aircrack-ng/include/aircrack-ng/ce-wpa/aligned.h
/* * Based on John the Ripper and modified to integrate with aircrack * * John the Ripper copyright and license. * * John the Ripper password cracker, * Copyright (c) 1996-2013 by Solar Designer. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * As a special exception to the GNU General Public License terms, * permission is hereby granted to link the code of this program, with or * without modification, with any version of the OpenSSL library and/or any * version of unRAR, and to distribute such linked combinations. You must * obey the GNU GPL in all respects for all of the code used other than * OpenSSL and unRAR. If you modify this program, you may extend this * exception to your version of the program, but you are not obligated to * do so. (In other words, you may release your derived work under pure * GNU GPL version 2 or later as published by the FSF.) * * (This exception from the GNU GPL is not required for the core tree of * John the Ripper, but arguably it is required for -jumbo.) * * Relaxed terms for certain components. * * In addition or alternatively to the license above, many components are * available to you under more relaxed terms (most commonly under cut-down * BSD license) as specified in the corresponding source files. * * For more information on John the Ripper licensing please visit: * * http://www.openwall.com/john/doc/LICENSE.shtml * * This software was written by JimF jfoug AT cox dot net * in 2013. No copyright is claimed, and the software is hereby * placed in the public domain. In case this attempt to disclaim * copyright and place the software in the public domain is deemed * null and void, then the software is Copyright (c) 2013 JimF * and it is hereby released to the general public under the following * terms: This software may be modified, redistributed, and used for any * purpose, in source and binary forms, with or without modification. */ #ifndef _ALIGNED_H_ #define _ALIGNED_H_ #if defined(__GNUC__) #define JTR_ALIGN(n) __attribute__((aligned(n))) #elif defined(_MSC_VER) #define JTR_ALIGN(n) __declspec(align(n)) #else #define JTR_ALIGN(n) #endif #endif
C/C++
aircrack-ng/include/aircrack-ng/ce-wpa/arch.h
/* * Based on John the Ripper and modified to integrate with aircrack * * John the Ripper copyright and license. * * John the Ripper password cracker, * Copyright (c) 1996-2013 by Solar Designer. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * As a special exception to the GNU General Public License terms, * permission is hereby granted to link the code of this program, with or * without modification, with any version of the OpenSSL library and/or any * version of unRAR, and to distribute such linked combinations. You must * obey the GNU GPL in all respects for all of the code used other than * OpenSSL and unRAR. If you modify this program, you may extend this * exception to your version of the program, but you are not obligated to * do so. (In other words, you may release your derived work under pure * GNU GPL version 2 or later as published by the FSF.) * * (This exception from the GNU GPL is not required for the core tree of * John the Ripper, but arguably it is required for -jumbo.) * * Relaxed terms for certain components. * * In addition or alternatively to the license above, many components are * available to you under more relaxed terms (most commonly under cut-down * BSD license) as specified in the corresponding source files. * * For more information on John the Ripper licensing please visit: * * http://www.openwall.com/john/doc/LICENSE.shtml * * This file is part of John the Ripper password cracker, * Copyright (c) 2003,2006,2008,2010,2011,2015 by Solar Designer * * ...with a trivial change in the jumbo patch, by Alain Espinosa. * * Redistribution and use in source and binary forms, with or without * modification, are permitted. * * There's ABSOLUTELY NO WARRANTY, express or implied. */ /* * Architecture specific parameters for x86-64. */ #ifndef _ARCH_H #define _ARCH_H #if (defined(__ARM_NEON) && !defined(__ARM_NEON__)) || defined(__aarch64) \ || defined(__aarch64__) #define __ARM_NEON__ 1 #endif #if (defined(__ARM_NEON__) && !defined(__ARM_NEON)) || defined(__aarch64) \ || defined(__aarch64__) #define __ARM_NEON 1 #endif #ifdef __ARM_NEON__ #define SHA_BUF_SIZ 16 #define SIMD_COEF_32 4 #define SIMD_COEF_64 2 #ifndef SIMD_PARA_SHA1 #define SIMD_PARA_SHA1 1 #endif #ifndef SIMD_PARA_SHA256 #define SIMD_PARA_SHA256 0 #endif #ifndef SIMD_PARA_SHA512 #define SIMD_PARA_SHA512 0 #endif #endif #if defined(JOHN_ALTIVEC) #define SHA_BUF_SIZ 16 #define SIMD_COEF_32 4 #define SIMD_COEF_64 2 #ifndef SIMD_PARA_SHA1 #define SIMD_PARA_SHA1 1 #endif #ifndef SIMD_PARA_SHA256 #define SIMD_PARA_SHA256 0 #endif #ifndef SIMD_PARA_SHA512 #define SIMD_PARA_SHA512 0 #endif #endif #if AC_BUILT #include "autoconfig.h" #else #if defined(__ILP32__) || defined(_WIN64) || defined(__LLP64__) \ || (defined(__SIZE_OF_LONG__) && __SIZEOF_LONG__ == 4) #define ARCH_WORD long long #else #define ARCH_WORD long #endif #define ARCH_SIZE 8 #define ARCH_BITS 64 #define ARCH_BITS_LOG 6 #define ARCH_BITS_STR "64" #define ARCH_LITTLE_ENDIAN 1 #define ARCH_INT_GT_32 0 #endif #define ARCH_ALLOWS_UNALIGNED 1 #define ARCH_INDEX(x) ((unsigned int) (unsigned char) (x)) #define CPU_DETECT 0 #ifdef __SSE2__ #define CPU_NAME "SSE2" #endif #if __SSSE3__ || JOHN_SSSE3 #undef CPU_DETECT #define CPU_DETECT 1 #define CPU_REQ 1 #define CPU_REQ_SSSE3 1 #undef CPU_NAME #define CPU_NAME "SSSE3" #if CPU_FALLBACK && !defined(CPU_FALLBACK_BINARY) #define CPU_FALLBACK_BINARY "john-non-ssse3" #define CPU_FALLBACK_BINARY_DEFAULT #endif #endif #if __SSE4_1__ || JOHN_SSE4_1 #undef CPU_DETECT #define CPU_DETECT 1 #define CPU_REQ 1 #define CPU_REQ_SSE4_1 1 #undef CPU_NAME #define CPU_NAME "SSE4.1" #if CPU_FALLBACK && !defined(CPU_FALLBACK_BINARY) #define CPU_FALLBACK_BINARY "john-non-sse4.1" #define CPU_FALLBACK_BINARY_DEFAULT #endif #endif #if __AVX512F__ || JOHN_AVX512F #undef CPU_DETECT #define CPU_DETECT 1 #define CPU_REQ 1 #define CPU_REQ_AVX512F 1 #undef CPU_NAME #define CPU_NAME "AVX512F" #if CPU_FALLBACK && !defined(CPU_FALLBACK_BINARY) #define CPU_FALLBACK_BINARY "john-non-avx512f" #define CPU_FALLBACK_BINARY_DEFAULT #endif #endif #if __AVX512BW__ || JOHN_AVX512BW #undef CPU_DETECT #define CPU_DETECT 1 #define CPU_REQ 1 #define CPU_REQ_AVX512BW 1 #undef CPU_NAME #define CPU_NAME "AVX512BW" #if CPU_FALLBACK && !defined(CPU_FALLBACK_BINARY) #define CPU_FALLBACK_BINARY "john-non-avx512bw" #define CPU_FALLBACK_BINARY_DEFAULT #endif #endif #ifdef __XOP__ #define JOHN_XOP 1 #endif #if defined(__AVX__) || defined(JOHN_XOP) || defined(JOHN_AVX2) #define JOHN_AVX 1 #endif #define DES_ASM 0 #define DES_128K 0 #define DES_X2 0 #define DES_MASK 1 #define DES_SCALE 1 #define DES_EXTB 1 #define DES_COPY 0 #define DES_BS 1 #if !defined(__SSE2__) #define DES_BS_VECTOR 0 #define DES_BS_ALGORITHM_NAME "DES 64/64" #elif defined(JOHN_AVX) && (defined(__GNUC__) || defined(_OPENMP)) /* * Require gcc for AVX/XOP because DES_bs_all is aligned in a gcc-specific way, * except in OpenMP-enabled builds, where it's aligned by different means. */ #undef CPU_DETECT #define CPU_DETECT 1 #define CPU_REQ 1 #define CPU_REQ_AVX 1 #undef CPU_NAME #define CPU_NAME "AVX" #if CPU_FALLBACK && !defined(CPU_FALLBACK_BINARY) #define CPU_FALLBACK_BINARY "john-non-avx" #define CPU_FALLBACK_BINARY_DEFAULT #endif #define DES_BS_ASM 0 #if 0 /* 512-bit as 2x256 */ #define DES_BS_VECTOR 8 #if defined(JOHN_XOP) && defined(__GNUC__) /* Require gcc for 256-bit XOP because of __builtin_ia32_vpcmov_v8sf256() */ #undef DES_BS #define DES_BS 3 #define DES_BS_ALGORITHM_NAME "DES 256/256 X2 XOP-16" #else #define DES_BS_ALGORITHM_NAME "DES 256/256 X2 AVX-16" #endif #elif 0 /* 384-bit as 256+128 */ #define DES_BS_VECTOR_SIZE 8 #define DES_BS_VECTOR 6 #if defined(JOHN_XOP) && defined(__GNUC__) /* Require gcc for 256-bit XOP because of __builtin_ia32_vpcmov_v8sf256() */ #undef DES_BS #define DES_BS 3 #define DES_BS_ALGORITHM_NAME "DES 256/256 XOP-16 + 128/128 XOP-16" #else #define DES_BS_ALGORITHM_NAME "DES 256/256 AVX-16 + 128/128 AVX-16" #endif #elif 0 /* 384-bit as 256+64+64 */ #define DES_BS_NO_AVX128 #define DES_BS_VECTOR_SIZE 8 #define DES_BS_VECTOR 6 #define DES_BS_ALGORITHM_NAME "DES 256/256 AVX-16 + 64/64 MMX + 64/64" #elif 0 /* 320-bit as 256+64 MMX */ #define DES_BS_VECTOR_SIZE 8 #define DES_BS_VECTOR 5 #define DES_BS_ALGORITHM_NAME "DES 256/256 AVX-16 + 64/64 MMX" #elif 0 /* 320-bit as 256+64 */ #define DES_BS_NO_MMX #define DES_BS_VECTOR_SIZE 8 #define DES_BS_VECTOR 5 #define DES_BS_ALGORITHM_NAME "DES 256/256 AVX-16 + 64/64" #elif __AVX2__ || JOHN_AVX2 /* 256-bit as 1x256 */ #define DES_BS_VECTOR 4 #undef CPU_NAME #define CPU_NAME "AVX2" #define CPU_DETECT 1 #define CPU_REQ 1 #define CPU_REQ_AVX2 1 #if CPU_FALLBACK && !defined(CPU_FALLBACK_BINARY) #define CPU_FALLBACK_BINARY "john-non-avx2" #define CPU_FALLBACK_BINARY_DEFAULT #endif #define DES_BS_ALGORITHM_NAME "DES 256/256 AVX2-16" #elif 0 /* 256-bit as 2x128 */ #define DES_BS_NO_AVX256 #define DES_BS_VECTOR 4 #ifdef JOHN_XOP #undef DES_BS #define DES_BS 3 #define DES_BS_ALGORITHM_NAME "DES 128/128 X2 XOP-16" #else #define DES_BS_ALGORITHM_NAME "DES 128/128 X2 AVX-16" #endif #else /* 128-bit */ #define DES_BS_VECTOR 2 #ifdef JOHN_XOP #undef DES_BS #define DES_BS 3 #define DES_BS_ALGORITHM_NAME "DES 128/128 XOP-16" #else #define DES_BS_ALGORITHM_NAME "DES 128/128 AVX-16" #endif #endif #elif (defined(__SSE2__) && defined(_OPENMP)) #define DES_BS_ASM 0 #if 1 #define DES_BS_VECTOR 2 #define DES_BS_ALGORITHM_NAME "DES 128/128 SSE2-16" #elif 0 #define DES_BS_VECTOR 3 #define DES_BS_VECTOR_SIZE 4 #define DES_BS_ALGORITHM_NAME "DES 128/128 SSE2-16 + 64/64 MMX" #elif 0 #define DES_BS_NO_MMX #define DES_BS_VECTOR 3 #define DES_BS_VECTOR_SIZE 4 #define DES_BS_ALGORITHM_NAME "DES 128/128 SSE2-16 + 64/64" #elif 0 #define DES_BS_NO_MMX #define DES_BS_VECTOR 4 #define DES_BS_ALGORITHM_NAME "DES 128/128 X2 SSE2-16" #else #define DES_BS_VECTOR 4 #define DES_BS_ALGORITHM_NAME "DES 128/128 SSE2-16 + 64/64 MMX + 64/64" #endif #else #define DES_BS_ASM 1 #define DES_BS_VECTOR 2 #define DES_BS_ALGORITHM_NAME "DES 128/128 SSE2-16" #endif #define DES_BS_EXPAND 1 #if CPU_DETECT && DES_BS == 3 #define CPU_REQ_XOP 1 #undef CPU_NAME #define CPU_NAME "XOP" #ifdef CPU_FALLBACK_BINARY_DEFAULT #undef CPU_FALLBACK_BINARY #define CPU_FALLBACK_BINARY "john-non-xop" #endif #endif #define MD5_ASM 0 #define MD5_X2 1 #define MD5_IMM 1 #ifdef __GNUC__ #define GCC_VERSION \ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) #endif #ifdef __SSE2__ #if __AVX512F__ #define SIMD_COEF_32 16 #define SIMD_COEF_64 8 #elif __AVX2__ #define SIMD_COEF_32 8 #define SIMD_COEF_64 4 #elif __SSE2__ #define SIMD_COEF_32 4 #define SIMD_COEF_64 2 #endif #ifndef SIMD_PARA_SHA1 #if defined(__INTEL_COMPILER) #define SIMD_PARA_SHA1 1 #elif defined(__clang__) #define SIMD_PARA_SHA1 1 #elif defined(__llvm__) #define SIMD_PARA_SHA1 1 #elif defined(__GNUC__) && GCC_VERSION < 40504 // 4.5.4 #define SIMD_PARA_SHA1 1 #elif !defined(__AVX__) && defined(__GNUC__) && GCC_VERSION > 40700 // 4.7.0 #define SIMD_PARA_SHA1 1 #else #define SIMD_PARA_SHA1 1 #endif #endif #if 0 #ifndef SIMD_PARA_SHA256 #if __XOP__ #define SIMD_PARA_SHA256 2 #else #define SIMD_PARA_SHA256 1 #endif #endif #ifndef SIMD_PARA_SHA512 #define SIMD_PARA_SHA512 1 #endif #endif #ifndef SHA1_SSE_PARA #if defined(__INTEL_COMPILER) || defined(USING_ICC_S_FILE) #define SHA1_SSE_PARA 1 //#define SHA1_N_STR "4x" #elif defined(__clang__) #define SHA1_SSE_PARA 2 //#define SHA1_N_STR "8x" #elif defined(__llvm__) #define SHA_BUF_SIZ 80 #define SHA1_SSE_PARA 2 //#define SHA1_N_STR "8x" #elif defined(__GNUC__) && GCC_VERSION < 40504 // 4.5.4 #define SHA1_SSE_PARA 1 //#define SHA1_N_STR "4x" #elif !defined(JOHN_AVX) && defined(__GNUC__) && GCC_VERSION > 40700 // 4.7.0 #define SHA1_SSE_PARA 1 //#define SHA1_N_STR "4x" #else #define SHA1_SSE_PARA 2 //#define SHA1_N_STR "8x" #endif #endif #define STR_VALUE(arg) #arg #define PARA_TO_N(n) STR_VALUE(n) "x" #define PARA_TO_MxN(m, n) STR_VALUE(m) "x" STR_VALUE(n) #if SIMD_PARA_SHA1 > 1 #define SHA1_N_STR PARA_TO_MxN(SIMD_COEF_32, SIMD_PARA_SHA1) #else #define SHA1_N_STR PARA_TO_N(SIMD_COEF_32) #endif #if SIMD_PARA_SHA256 > 1 #define SHA256_N_STR PARA_TO_MxN(SIMD_COEF_32, SIMD_PARA_SHA256) #else #define SHA256_N_STR PARA_TO_N(SIMD_COEF_32) #endif #if SIMD_PARA_SHA512 > 1 #define SHA512_N_STR PARA_TO_MxN(SIMD_COEF_64, SIMD_PARA_SHA512) #else #define SHA512_N_STR PARA_TO_N(SIMD_COEF_64) #endif #define SHA_BUF_SIZ 16 #define NT_X86_64 #ifndef SIMD_CORE #define MMX_TYPE " SSE2" #define MMX_COEF 4 #define MMX_COEF_SHA256 4 #define MMX_COEF_SHA512 2 #endif #endif /* __SSE2__ */ #define BF_ASM 0 #define BF_SCALE 1 /* * 3x (as opposed to 2x) interleaving provides substantial speedup on Core 2 * CPUs, as well as slight speedup on some other CPUs. Unfortunately, it * results in lower cumulative performance with multiple concurrent threads or * processes on some newer SMT-capable CPUs. While this has nothing to do with * AVX per se, building for AVX implies we do not intend to run on a Core 2 * (which has at most SSE4.1), so checking for AVX here provides an easy way to * avoid this performance regression in AVX-enabled builds. In multi-binary * packages with runtime fallbacks, the AVX-enabled binary would invoke a * non-AVX fallback binary from its john.c if run e.g. on a Core 2. We could * check for SSE4.2 rather than AVX here, as SSE4.2 was introduced along with * SMT-capable Nehalem microarchitecture CPUs, but apparently those CPUs did * not yet exhibit the performance regression with 3x interleaving. Besides, * some newer CPUs capable of SSE4.2 but not AVX happen to lack SMT, so will * likely benefit from the 3x interleaving with no adverse effects for the * multi-threaded case. * * In Jumbo, we may get BF_X2 from autoconf (after testing ht cpuid flag). */ #ifndef BF_X2 #if __AVX__ && HAVE_HT && _OPENMP #define BF_X2 1 #else #define BF_X2 3 #endif #endif #endif
C/C++
aircrack-ng/include/aircrack-ng/ce-wpa/crypto_engine.h
/* * Copyright (C) 2018-2022 Joseph Benden <joe@benden.us> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef AIRCRACK_NG_CRYPTO_ENGINE_H #define AIRCRACK_NG_CRYPTO_ENGINE_H #include <string.h> #include <stdint.h> #include <stddef.h> #include <aircrack-ng/defs.h> #define MAX_THREADS 256 #if defined(_MSC_VER) // Microsoft #define EXPORT __declspec(dllexport) #define IMPORT __declspec(dllimport) #elif defined(__GNUC__) || defined(__llvm__) || defined(__clang__) \ || defined(__INTEL_COMPILER) #define EXPORT __attribute__((visibility("default"))) #define IMPORT #else // do nothing and hope for the best? #define EXPORT #define IMPORT #pragma warning Unknown dynamic link import / export semantics. #endif #ifdef __cplusplus extern "C" { #endif #define ESSID_LENGTH 32 /* The spec. says 32 maximum. */ #define PLAINTEXT_LENGTH 63 /* We can do 64 but spec. says 63 */ #define PMK_LEN 32 #define PMK_LEN_MAX 64 #define MIN_KEYS_PER_CRYPT 1 #if defined(JOHN_AVX512F) #define MAX_KEYS_PER_CRYPT 16 #elif defined(JOHN_AVX2) #define MAX_KEYS_PER_CRYPT 8 #else #define MAX_KEYS_PER_CRYPT 4 #endif #if defined(AVX512F_FOUND) #if defined(__INTEL_COMPILER) #define MAX_KEYS_PER_CRYPT_SUPPORTED 32 #else #define MAX_KEYS_PER_CRYPT_SUPPORTED 16 #endif #else #if defined(__INTEL_COMPILER) #define MAX_KEYS_PER_CRYPT_SUPPORTED 16 #else #define MAX_KEYS_PER_CRYPT_SUPPORTED 8 #endif #endif typedef struct { uint8_t v[PLAINTEXT_LENGTH + 1]; uint32_t length; } wpapsk_password; typedef struct { union { uint32_t v[8]; uint8_t c[32]; } data; } wpapsk_hash; #ifndef CACHELINE_SIZE #define CACHELINE_SIZE 64 // CPU L1 cache-line size, in bytes. #endif #define CACHELINE_PADDED_FIELD(T, name, length, cacheline_size) \ T name[(length)]; \ uint8_t name##_padding[(cacheline_size) \ - ((length * sizeof(T)) % (cacheline_size))] #pragma pack(push, 1) /// Per-thread data needed by the crypto cracking engine. struct ac_crypto_engine_perthread { /// Holds the pair-wise master key. CACHELINE_PADDED_FIELD(wpapsk_hash, pmk, MAX_KEYS_PER_CRYPT_SUPPORTED, CACHELINE_SIZE); /// Holds a 64-byte buffer for HMAC SHA1 ipad/opad, plus an extra 20-byte /// buffer for a SHA1 digest. CACHELINE_PADDED_FIELD(uint8_t, hash1, (64 + 20) * MAX_KEYS_PER_CRYPT_SUPPORTED, CACHELINE_SIZE); #ifndef AVX512F_FOUND #define CRYPT_PADDING CACHELINE_SIZE / 2 #else #define CRYPT_PADDING CACHELINE_SIZE #endif /// Holds a 20-byte buffer for a SHA1 digest. Half cache-line size is to /// compact with the next. CACHELINE_PADDED_FIELD(uint8_t, crypt1, 20 * MAX_KEYS_PER_CRYPT_SUPPORTED, CRYPT_PADDING); /// Holds a 20-byte buffer for a SHA1 digest. Half cache-line size is to /// compact with the previous. CACHELINE_PADDED_FIELD(uint8_t, crypt2, 20 * MAX_KEYS_PER_CRYPT_SUPPORTED, CRYPT_PADDING); #undef CRYPT_PADDING /// Holds a 20-byte buffer for a SHA1 digest. Double cache-line size is to /// space the next field further out. CACHELINE_PADDED_FIELD(uint8_t, ptk, 20 * MAX_KEYS_PER_CRYPT_SUPPORTED, CACHELINE_SIZE * 2); /// Holds a 100-byte buffer for pair-wise key expansion. CACHELINE_PADDED_FIELD(uint8_t, pke, 100 * MAX_KEYS_PER_CRYPT_SUPPORTED, CACHELINE_SIZE); }; #pragma pack(pop) COMPILE_TIME_ASSERT((offsetof(struct ac_crypto_engine_perthread, pmk)) == 0); COMPILE_TIME_ASSERT((offsetof(struct ac_crypto_engine_perthread, hash1) % CACHELINE_SIZE) == 0); COMPILE_TIME_ASSERT((offsetof(struct ac_crypto_engine_perthread, crypt1) % CACHELINE_SIZE) == 0); COMPILE_TIME_ASSERT((offsetof(struct ac_crypto_engine_perthread, crypt2) % (CACHELINE_SIZE / 2)) == 0); COMPILE_TIME_ASSERT((offsetof(struct ac_crypto_engine_perthread, ptk) % CACHELINE_SIZE) == 0); COMPILE_TIME_ASSERT((offsetof(struct ac_crypto_engine_perthread, pke) % CACHELINE_SIZE) == 0); struct ac_crypto_engine { uint8_t ** essid; uint32_t essid_length; struct ac_crypto_engine_perthread * thread_data[MAX_THREADS]; }; typedef struct ac_crypto_engine ac_crypto_engine_t; /// The compiled-in features required to correctly execute on host. IMPORT int ac_crypto_engine_supported_features(void); /// global init. this could initialize threadid 1, but... IMPORT int ac_crypto_engine_init(ac_crypto_engine_t * engine); IMPORT void ac_crypto_engine_destroy(ac_crypto_engine_t * engine); IMPORT void ac_crypto_engine_set_essid(ac_crypto_engine_t * engine, const uint8_t * essid); IMPORT uint8_t * ac_crypto_engine_get_pmk(ac_crypto_engine_t * engine, int threadid, int index); IMPORT uint8_t * ac_crypto_engine_get_ptk(ac_crypto_engine_t * engine, int threadid, int index); IMPORT void ac_crypto_engine_calc_pke(ac_crypto_engine_t * engine, const uint8_t bssid[6], const uint8_t stmac[6], const uint8_t anonce[32], const uint8_t snonce[32], int threadid); IMPORT void ac_crypto_engine_set_pmkid_salt(ac_crypto_engine_t * engine, const uint8_t bssid[6], const uint8_t stmac[6], int threadid); /// per-thread-in-use init. separate to allow (possible) NUMA-local allocation. IMPORT int ac_crypto_engine_thread_init(ac_crypto_engine_t * engine, int threadid); IMPORT void ac_crypto_engine_thread_destroy(ac_crypto_engine_t * engine, int threadid); /// acquire the width of simd we're compiled for. IMPORT int ac_crypto_engine_simd_width(void); IMPORT void ac_crypto_engine_calc_pmk( ac_crypto_engine_t * engine, const wpapsk_password key[MAX_KEYS_PER_CRYPT_SUPPORTED], int nparallel, int threadid); IMPORT void ac_crypto_engine_calc_ptk(ac_crypto_engine_t * engine, const uint8_t keyver, int vectorIdx, int threadid); IMPORT void ac_crypto_engine_calc_mic(ac_crypto_engine_t * engine, const uint8_t eapol[256], uint32_t eapol_size, uint8_t mic[MAX_KEYS_PER_CRYPT_SUPPORTED] [20], uint8_t keyver, int vectorIdx, int threadid); IMPORT int ac_crypto_engine_wpa_crack( ac_crypto_engine_t * engine, const wpapsk_password key[MAX_KEYS_PER_CRYPT_SUPPORTED], const uint8_t eapol[256], uint32_t eapol_size, uint8_t mic[MAX_KEYS_PER_CRYPT_SUPPORTED][20], uint8_t keyver, const uint8_t cmpmic[20], int nparallel, int threadid); IMPORT int ac_crypto_engine_wpa_pmkid_crack( ac_crypto_engine_t * engine, const wpapsk_password key[MAX_KEYS_PER_CRYPT_SUPPORTED], const uint8_t pmkid[32], int nparallel, int threadid); // Quick Utilities. /// Calculate one pairwise master key, from the \a essid and \a key. IMPORT void ac_crypto_engine_calc_one_pmk(const uint8_t * key, const uint8_t * essid, uint32_t essid_length, uint8_t pmk[static PMK_LEN]); #ifdef __cplusplus } #endif #endif // AIRCRACK_NG_CRYPTO_ENGINE_H
C/C++
aircrack-ng/include/aircrack-ng/ce-wpa/jcommon.h
/* * Based on John the Ripper and modified to integrate with aircrack * * John the Ripper copyright and license. * * John the Ripper password cracker, * Copyright (c) 1996-2013 by Solar Designer. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * As a special exception to the GNU General Public License terms, * permission is hereby granted to link the code of this program, with or * without modification, with any version of the OpenSSL library and/or any * version of unRAR, and to distribute such linked combinations. You must * obey the GNU GPL in all respects for all of the code used other than * OpenSSL and unRAR. If you modify this program, you may extend this * exception to your version of the program, but you are not obligated to * do so. (In other words, you may release your derived work under pure * GNU GPL version 2 or later as published by the FSF.) * * (This exception from the GNU GPL is not required for the core tree of * John the Ripper, but arguably it is required for -jumbo.) * * Relaxed terms for certain components. * * In addition or alternatively to the license above, many components are * available to you under more relaxed terms (most commonly under cut-down * BSD license) as specified in the corresponding source files. * * For more information on John the Ripper licensing please visit: * * http://www.openwall.com/john/doc/LICENSE.shtml * * This file is part of John the Ripper password cracker, * Copyright (c) 1996-99,2005,2009,2011,2013 by Solar Designer * * Redistribution and use in source and binary forms, with or without * modification, are permitted. * * There's ABSOLUTELY NO WARRANTY, express or implied. */ /* * Things common to many ciphertext formats. */ #ifndef _JCOMMON_H #define _JCOMMON_H #include <aircrack-ng/ce-wpa/arch.h> #include <aircrack-ng/ce-wpa/memory.h> #if ARCH_INT_GT_32 typedef unsigned short ARCH_WORD_32; typedef unsigned int ARCH_WORD_64; #else typedef unsigned int ARCH_WORD_32; typedef unsigned long long ARCH_WORD_64; #endif /* ONLY use this to check alignments of even power of 2 (2, 4, 8, 16, etc) byte counts (CNT). The cast to void* MUST be done, due to C spec. http://stackoverflow.com/a/1898487 */ #define is_aligned(PTR, CNT) \ ((((ARCH_WORD)(const void *) (PTR)) & (CNT - 1)) == 0) #ifdef __GNUC__ #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) \ || defined(__INTEL_COMPILER) #define MAYBE_INLINE __attribute__((always_inline)) inline #elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) #define MAYBE_INLINE __attribute__((always_inline)) #else #define MAYBE_INLINE __inline__ #endif #elif __STDC_VERSION__ >= 199901L #define MAYBE_INLINE inline #else #define MAYBE_INLINE #endif #if ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 2) #define CC_CACHE_ALIGN __attribute__((aligned(MEM_ALIGN_CACHE))) #else #define CC_CACHE_ALIGN /* nothing */ #endif /* * This "shift" is the number of bytes that may be inserted between arrays the * size of which would be a multiple of cache line size (some power of two) and * that might be accessed simultaneously. The purpose of the shift is to avoid * cache bank conflicts with such accesses, actually allowing them to proceed * simultaneously. This number should be a multiple of the machine's word size * but smaller than cache line size. */ #define CACHE_BANK_SHIFT ARCH_SIZE /* * ASCII <-> binary conversion tables. */ // extern const char itoa64[64]; /* crypt(3) base64 - not MIME Base64! */ extern char atoi64[0x100]; extern const char itoa16[16]; extern char atoi16[0x100]; extern const char itoa16u[16]; // uppercase /* * Initializes the tables. */ extern void common_init(void); #endif
C/C++
aircrack-ng/include/aircrack-ng/ce-wpa/johnswap.h
/* * Based on John the Ripper and modified to integrate with aircrack * * John the Ripper copyright and license. * * John the Ripper password cracker, * Copyright (c) 1996-2013 by Solar Designer. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * As a special exception to the GNU General Public License terms, * permission is hereby granted to link the code of this program, with or * without modification, with any version of the OpenSSL library and/or any * version of unRAR, and to distribute such linked combinations. You must * obey the GNU GPL in all respects for all of the code used other than * OpenSSL and unRAR. If you modify this program, you may extend this * exception to your version of the program, but you are not obligated to * do so. (In other words, you may release your derived work under pure * GNU GPL version 2 or later as published by the FSF.) * * (This exception from the GNU GPL is not required for the core tree of * John the Ripper, but arguably it is required for -jumbo.) * * Relaxed terms for certain components. * * In addition or alternatively to the license above, many components are * available to you under more relaxed terms (most commonly under cut-down * BSD license) as specified in the corresponding source files. * * For more information on John the Ripper licensing please visit: * * http://www.openwall.com/john/doc/LICENSE.shtml * */ #if !defined __JOHN_SWAP_H__ #define __JOHN_SWAP_H__ /* reqired for the john_bswap_32 ARCH_WORD_32 declaration */ #include <aircrack-ng/ce-wpa/jcommon.h> /* if x86 compatible cpu */ #if defined(i386) || defined(__i386__) || defined(__i486__) \ || defined(__i586__) || defined(__i686__) || defined(__pentium__) \ || defined(__pentiumpro__) || defined(__pentium4__) || defined(__nocona__) \ || defined(prescott) || defined(__core2__) || defined(__k6__) \ || defined(__k8__) || defined(__athlon__) || defined(__amd64) \ || defined(__amd64__) || defined(__x86_64) || defined(__x86_64__) \ || defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) \ || defined(_M_X64) /* detect if x86-64 instruction set is supported */ #if defined(_LP64) || defined(__LP64__) || defined(__x86_64) \ || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64) #undef CPU_X64 #define CPU_X64 1 #else #undef CPU_IA32 #define CPU_IA32 1 #endif #undef CPU_INTEL_LE #define CPU_INTEL_LE 1 #endif #if defined __GNUC__ \ && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || (__GNUC__ > 4)) #define JOHNSWAP(x) __builtin_bswap32((x)) #define JOHNSWAP64(x) __builtin_bswap64((x)) #elif defined(__linux__) #include <byteswap.h> #define JOHNSWAP(x) bswap_32((x)) #define JOHNSWAP64(x) bswap_64((x)) #elif (_MSC_VER > 1300) \ && (_M_IX86 >= 400 || defined(CPU_IA32) || defined(CPU_X64)) /* MS VC */ #define JOHNSWAP(x) _byteswap_ulong((x)) #define JOHNSWAP64(x) _byteswap_uint64(((unsigned __int64) x)) #elif !defined(__STRICT_ANSI__) #define JOHNSWAP(x) john_bswap_32((x)) #define JOHNSWAP64(x) john_bswap_64((x)) #define ROTATE_LEFT(x, n) \ (x) = (((x) << (n)) | ((ARCH_WORD_32)(x) >> (32 - (n)))) #define ROTATE_LEFT64(x, n) \ (x) = (((x) << (n)) | ((unsigned long long) (x) >> (64 - (n)))) #if defined(__GNUC__) && defined(CPU_IA32) && !defined(__i386__) /* for intel x86 CPU */ static inline ARCH_WORD_32 __attribute__((const)) john_bswap_32(ARCH_WORD_32 val) { register ARCH_WORD_32 res; __asm("bswap\t%0" : "=r"(res) : "0"(val)); return res; } #else /* Note, the name bswap_32 clashed with a less efficient bswap_32 in gcc 3.4. */ /* Thus, we now call it john_bswap_32 to take 'ownership' */ static inline ARCH_WORD_32 john_bswap_32(ARCH_WORD_32 x) { /* Since this is an inline function, we do not have to worry about */ /* multiple reference of x. Even though we are called from a macro */ /* this inline hides problems even with usage like n=SWAP(*cp++); */ ROTATE_LEFT(x, 16); return ((x & 0x00FF00FF) << 8) | ((x >> 8) & 0x00FF00FF); } #endif static inline unsigned long long john_bswap_64(unsigned long long x) { #if ARCH_BITS == 32 union { unsigned long long ll; ARCH_WORD_32 l[2]; } w, r; w.ll = x; r.l[0] = john_bswap_32(w.l[1]); r.l[1] = john_bswap_32(w.l[0]); return r.ll; #else // Someone should write a 'proper' 64 bit bswap, for 64 bit arch // for now, I am using the '32 bit' version I wrote above. union { unsigned long long ll; ARCH_WORD_32 l[2]; } w, r; w.ll = x; r.l[0] = john_bswap_32(w.l[1]); r.l[1] = john_bswap_32(w.l[0]); return r.ll; #endif } #endif #endif // __JOHN_SWAP_H__
C/C++
aircrack-ng/include/aircrack-ng/ce-wpa/memory.h
/* * Based on John the Ripper and modified to integrate with aircrack * * John the Ripper copyright and license. * * John the Ripper password cracker, * Copyright (c) 1996-2013 by Solar Designer. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * As a special exception to the GNU General Public License terms, * permission is hereby granted to link the code of this program, with or * without modification, with any version of the OpenSSL library and/or any * version of unRAR, and to distribute such linked combinations. You must * obey the GNU GPL in all respects for all of the code used other than * OpenSSL and unRAR. If you modify this program, you may extend this * exception to your version of the program, but you are not obligated to * do so. (In other words, you may release your derived work under pure * GNU GPL version 2 or later as published by the FSF.) * * (This exception from the GNU GPL is not required for the core tree of * John the Ripper, but arguably it is required for -jumbo.) * * Relaxed terms for certain components. * * In addition or alternatively to the license above, many components are * available to you under more relaxed terms (most commonly under cut-down * BSD license) as specified in the corresponding source files. * * For more information on John the Ripper licensing please visit: * * http://www.openwall.com/john/doc/LICENSE.shtml * * This file is part of John the Ripper password cracker, * Copyright (c) 1996-98,2003,2010-2012 by Solar Designer * * Redistribution and use in source and binary forms, with or without * modification, are permitted. * * There's ABSOLUTELY NO WARRANTY, express or implied. */ /* * Memory allocation routines. */ #ifndef _MEMORY_H #define _MEMORY_H #include <stdio.h> #include <stdlib.h> #include <string.h> #include <aircrack-ng/ce-wpa/arch.h> #if __AVX512F__ #define SIMD_COEF_32 16 #define SIMD_COEF_64 8 #elif __AVX2__ #define SIMD_COEF_32 8 #define SIMD_COEF_64 4 #elif __SSE2__ #define SIMD_COEF_32 4 #define SIMD_COEF_64 2 #endif /* * Standard alignments for mem_alloc_tiny(). */ #define MEM_ALIGN_NONE 1 #define MEM_ALIGN_WORD ARCH_SIZE /* * These are hopefully suitable guesses. They are right for only a subset of * the architectures/CPUs we support, yet our use of them does not require that * they be entirely correct. */ #ifdef _MSC_VER #define MEM_ALIGN_CACHE 64 #else #define MEM_ALIGN_CACHE (ARCH_SIZE * 8) #endif #define MEM_ALIGN_PAGE 0x1000 /* * SIMD buffers need to be aligned to register size */ #if SIMD_COEF_32 #ifdef _MSC_VER #define MEM_ALIGN_SIMD 16 #else #define MEM_ALIGN_SIMD (SIMD_COEF_32 * 4) #endif #else #define MEM_ALIGN_SIMD (16) #endif /* * Block size used by mem_alloc_tiny(). */ #define MEM_ALLOC_SIZE 0x10000 /* * Use mem_alloc() instead of allocating a new block in mem_alloc_tiny() * if more than MEM_ALLOC_MAX_WASTE bytes would be lost. * This shouldn't be set too small, or mem_alloc_tiny() will keep calling * mem_alloc() for many allocations in a row, which might end up wasting even * more memory to malloc() overhead. */ #define MEM_ALLOC_MAX_WASTE 0xff /* * Memory saving level, setting this high enough disables alignments (if the * architecture allows). */ extern unsigned int mem_saving_level; /* * Allocates size bytes and returns a pointer to the allocated memory. * If an error occurs, the function does not return. */ extern void * mem_alloc_func(size_t size); /* * this version same as mem_alloc, but initialized the memory * to NULL bytes, like CALLOC(3) function does */ extern void * mem_calloc_func(size_t count, size_t size); #define mem_alloc(a) mem_alloc_func(a) #define mem_calloc(a, b) mem_calloc_func(a, b) #define mem_alloc_tiny(a, b) mem_alloc_tiny_func(a, b) #define mem_calloc_tiny(a, b) mem_calloc_tiny_func(a, b) #define mem_alloc_copy(a, b, c) mem_alloc_copy_func(a, b, c) #define str_alloc_copy(a) str_alloc_copy_func(a) #define mem_alloc_align(a, b) mem_alloc_align_func(a, b) #define mem_calloc_align(a, b, c) mem_calloc_align_func(a, b, c) /* These allow alignment and are wrappers to system-specific functions */ void * mem_alloc_align_func(size_t size, size_t align); void * mem_calloc_align_func(size_t count, size_t size, size_t align); /* * Frees memory allocated with mem_alloc() and sets the pointer to NULL. * Does nothing if the pointer is already NULL. */ #undef MEM_FREE #ifdef _MSC_VER #define strdup(a) strdup_MSVC(a) char * strdup_MSVC(const char * str); #define MEM_FREE(ptr) \ { \ if ((ptr)) \ { \ _aligned_free((ptr)); \ (ptr) = NULL; \ } \ } #else #define MEM_FREE(ptr) \ { \ if ((ptr)) \ { \ free((ptr)); \ (ptr) = NULL; \ } \ } #endif /* * Similar to the above function, except the memory can't be freed. * This one is used to reduce the overhead. */ extern void * mem_alloc_tiny_func(size_t size, size_t align); /* * this version same as mem_alloc_tiny, but initialized the memory * to NULL bytes, like CALLOC(3) function does */ extern void * mem_calloc_tiny_func(size_t size, size_t align); /* * Uses mem_alloc_tiny() to allocate the memory, and copies src in there. */ extern void * mem_alloc_copy_func(void * src, size_t size, size_t align); /* * Similar to the above function, but for ASCIIZ strings. */ extern char * str_alloc_copy_func(char * src); /* * This will 'cleanup' the memory allocated by mem_alloc_tiny(). All * of that memory was 'blindly' allocated, and not freed up during * the run of john. Now, it is 'cleaned' up. */ extern void cleanup_tiny_memory(void); void dump_text(void * in, int len); void dump_stuff(void * x, unsigned int size); void dump_stuff_msg(const void * msg, void * x, unsigned int size); void dump_stuff_noeol(void * x, unsigned int size); void dump_stuff_msg_sepline(const void * msg, void * x, unsigned int size); void dump_stuff_be(void * x, unsigned int size); void dump_stuff_be_msg(const void * msg, void * x, unsigned int size); void dump_stuff_be_noeol(void * x, unsigned int size); void dump_stuff_be_msg_sepline(const void * msg, void * x, unsigned int size); #if defined(SIMD_COEF_32) || defined(NT_X86_64) || defined(SIMD_PARA_MD5) \ || defined(SIMD_PARA_MD4) || defined(SIMD_PARA_SHA1) void dump_stuff_mmx(void * x, unsigned int size, unsigned int index); void dump_stuff_mmx_noeol(void * x, unsigned int size, unsigned int index); void dump_stuff_mmx_msg(const void * msg, void * buf, unsigned int size, unsigned int index); void dump_stuff_mmx_msg_sepline(const void * msg, void * buf, unsigned int size, unsigned int index); // for flat input, we do want to see SHA512 without byte swapping. void dump_stuff_mmx64(void * buf, unsigned int size, unsigned int index); void dump_stuff_mmx64_msg(const void * msg, void * buf, unsigned int size, unsigned int index); void dump_out_mmx(void * x, unsigned int size, unsigned int index); void dump_out_mmx_noeol(void * x, unsigned int size, unsigned int index); void dump_out_mmx_msg(const void * msg, void * buf, unsigned int size, unsigned int index); void dump_out_mmx_msg_sepline(const void * msg, void * buf, unsigned int size, unsigned int index); void dump_stuff_shammx(void * x, unsigned int size, unsigned int index); void dump_stuff_shammx_msg(const void * msg, void * buf, unsigned int size, unsigned int index); void dump_out_shammx(void * x, unsigned int size, unsigned int index); void dump_out_shammx_msg(const void * msg, void * buf, unsigned int size, unsigned int index); void dump_stuff_shammx64(void * x, unsigned int size, unsigned int index); void dump_stuff_shammx64_msg(const void * msg, void * buf, unsigned int size, unsigned int index); void dump_out_shammx64(void * x, unsigned int size, unsigned int index); void dump_out_shammx64_msg(const void * msg, void * buf, unsigned int size, unsigned int index); #endif #if defined(SIMD_PARA_MD5) // these functions help debug arrays of contiguous MD5 prepared PARA buffers. // Seen in sunmd5 at the current time. void dump_stuff_mpara_mmx(void * x, unsigned int size, unsigned int index); void dump_stuff_mpara_mmx_noeol(void * x, unsigned int size, unsigned int index); void dump_stuff_mpara_mmx_msg(const void * msg, void * buf, unsigned int size, unsigned int index); void dump_stuff_mpara_mmx_msg_sepline(const void * msg, void * buf, unsigned int size, unsigned int index); // a 'getter' to help debugging. Returns a flat buffer, vs printing it out. void getbuf_stuff_mpara_mmx(unsigned char * oBuf, void * buf, unsigned int size, unsigned int index); #endif /* * here, a stack buffer that is at least align-1 bytes LARGER than required, can * be * properly aligned to 'align' bytes. So: char tmpbuf[256+15], * *aligned_buf=mem_align(tmpbuf,16); * will give you a stack buffer, aligned to 16 bytes. There are bugs in some * compilers which cause * JTR_ALIGN(x) to fail properly (such as a bug in bitcoin OMP mode for linux32) * Switched to a define macro for performance. */ #define mem_align(a, b) \ (void *) (((char *) (a)) \ + (((b) -1) - (((size_t)((char *) (a)) - 1) & ((b) -1)))) /* * 32-bit endian-swap a memory buffer in place. Size is in octets (so should * be a multiple of 4). From now on, this function may be used on any arch. */ void alter_endianity(void * x, unsigned int size); /* 32-bit endian-swap a memory buffer in place. Count is in 32-bit words */ void alter_endianity_w(void * x, unsigned int count); /* 64-bit endian-swap a memory buffer in place. Count is in 64-bit words */ void alter_endianity_w64(void * x, unsigned int count); #if ARCH_ALLOWS_UNALIGNED // we can inline these, to always use JOHNSWAP/JOHNSWAP64 // NOTE, more portable to use #defines to inline, than the MAYBE_INLINE within // header files. #if (ARCH_LITTLE_ENDIAN == 0) #define alter_endianity_to_BE(a, b) #define alter_endianity_to_BE64(a, b) #define alter_endianity_to_LE(ptr, word32_cnt) \ do \ { \ int i; \ for (i = 0; i < word32_cnt; i++) \ ((ARCH_WORD_32 *) ptr)[i] = JOHNSWAP(((ARCH_WORD_32 *) ptr)[i]); \ } while (0) #define alter_endianity_to_LE64(ptr, word64_cnt) \ do \ { \ int i; \ for (i = 0; i < word64_cnt; i++) \ ((ARCH_WORD_64 *) ptr)[i] = JOHNSWAP64(((ARCH_WORD_64 *) ptr)[i]); \ } while (0) #else #define alter_endianity_to_LE(a, b) #define alter_endianity_to_LE64(a, b) #define alter_endianity_to_BE(ptr, word32_cnt) \ do \ { \ int i; \ for (i = 0; i < word32_cnt; i++) \ ((ARCH_WORD_32 *) ptr)[i] = JOHNSWAP(((ARCH_WORD_32 *) ptr)[i]); \ } while (0) #define alter_endianity_to_BE64(ptr, word64_cnt) \ do \ { \ int i; \ for (i = 0; i < word64_cnt; i++) \ ((ARCH_WORD_64 *) ptr)[i] = JOHNSWAP64(((ARCH_WORD_64 *) ptr)[i]); \ } while (0) #endif #else #if (ARCH_LITTLE_ENDIAN == 0) #define alter_endianity_to_BE(a, b) #define alter_endianity_to_LE(a, b) \ do \ { \ alter_endianity_w(a, b); \ } while (0) #define alter_endianity_to_BE64(a, b) #define alter_endianity_to_LE64(a, b) \ do \ { \ alter_endianity_w64(a, b); \ } while (0) #else #define alter_endianity_to_BE(a, b) \ do \ { \ alter_endianity_w(a, b); \ } while (0) #define alter_endianity_to_LE(a, b) #define alter_endianity_to_BE64(a, b) \ do \ { \ alter_endianity_w64(a, b); \ } while (0) #define alter_endianity_to_LE64(a, b) #endif #endif #endif
C/C++
aircrack-ng/include/aircrack-ng/ce-wpa/misc.h
/* * Based on John the Ripper and modified to integrate with aircrack * * John the Ripper copyright and license. * * John the Ripper password cracker, * Copyright (c) 1996-2013 by Solar Designer. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * As a special exception to the GNU General Public License terms, * permission is hereby granted to link the code of this program, with or * without modification, with any version of the OpenSSL library and/or any * version of unRAR, and to distribute such linked combinations. You must * obey the GNU GPL in all respects for all of the code used other than * OpenSSL and unRAR. If you modify this program, you may extend this * exception to your version of the program, but you are not obligated to * do so. (In other words, you may release your derived work under pure * GNU GPL version 2 or later as published by the FSF.) * * (This exception from the GNU GPL is not required for the core tree of * John the Ripper, but arguably it is required for -jumbo.) * * Relaxed terms for certain components. * * In addition or alternatively to the license above, many components are * available to you under more relaxed terms (most commonly under cut-down * BSD license) as specified in the corresponding source files. * * For more information on John the Ripper licensing please visit: * * http://www.openwall.com/john/doc/LICENSE.shtml * * This file is part of John the Ripper password cracker, * Copyright (c) 1996-99,2003 by Solar Designer * * ...with changes in the jumbo patch, by JimF and magnum. * * Redistribution and use in source and binary forms, with or without * modification, are permitted. * * There's ABSOLUTELY NO WARRANTY, express or implied. */ /* * Miscellaneous routines. */ #ifndef _MISC_H #define _MISC_H #include <stdio.h> #if (__MINGW32__ && !__MINGW64__) || _MSC_VER // Later versions of MSVC can handle %lld but some older // ones can only handle %I64d. Easiest to simply use // %I64d then all versions of MSVC will handle it just fine #define LLu "%I64u" #define LLd "%I64d" #define LLx "%I64x" #define Zu "%u" #define Zd "%d" #else #define LLu "%llu" #define LLd "%lld" #define LLx "%llx" #define Zu "%zu" #define Zd "%zd" #endif #if !AC_BUILT #include <string.h> #ifndef _MSC_VER #include <strings.h> #endif #else #include "autoconfig.h" #if STRING_WITH_STRINGS #include <string.h> #include <strings.h> #elif HAVE_STRING_H #include <string.h> #elif HAVE_STRINGS_H #include <strings.h> #endif #endif /* * Exit on error. Logs the event, closes john.pot and the log file, and * terminates the process with non-zero exit status. */ extern void real_error(char * file, int line) #ifdef __GNUC__ __attribute__((__noreturn__)); #else ; #endif #define error(...) real_error(__FILE__, __LINE__) /* * Exit on error with message. Will call real_error to do * the final exiting, after printing error message. */ extern void real_error_msg(char * file, int line, char * format, ...) #ifdef __GNUC__ __attribute__((__noreturn__)) __attribute__((format(printf, 3, 4))); #else ; #endif #define error_msg(...) perror(__VA_ARGS__) /* * Similar to perror(), but supports formatted output, and calls error(). */ extern void real_pexit(char * file, int line, char * format, ...) #ifdef __GNUC__ __attribute__((__noreturn__)) __attribute__((format(printf, 3, 4))); #else ; #endif #define pexit(...) \ { \ perror(__VA_ARGS__); \ exit(1); \ } /* * Attempts to write all the supplied data. Returns the number of bytes * written, or -1 on error. */ extern int write_loop(int fd, const char * buffer, int count); /* * Similar to fgets(), but doesn't leave the newline character in the buffer, * and skips to the end of long lines. Handles both Unix and DOS style text * files correctly. */ extern char * fgetl(char * s, int size, FILE * stream); /* * Similar to strncpy(), but terminates with only one NUL if there's room * instead of padding to the supplied size like strncpy() does. */ extern char * strnfcpy(char * dst, const char * src, int size); /* * Similar to the above, but always NUL terminates the string. */ extern char * strnzcpy(char * dst, const char * src, int size); /* * Similar to the strnzcpy, but returns the length of the string. */ extern int strnzcpyn(char * dst, const char * src, int size); /* * Similar to strncat(), but total buffer size is supplied, and always NUL * terminates the string. */ extern char * strnzcat(char * dst, const char * src, int size); /* * Similar to atoi(), but properly handles unsigned int. Do not use * atoi() for unsigned data if the data can EVER be over MAX_INT. */ extern unsigned atou(const char * src); /* * Similar to strtok(), but properly handles adjacent delmiters as * empty strings. strtok() in the CRTL merges adjacent delimiters * and sort of 'skips' them. This one also returns 'empty' tokens * for any leading or trailing delims. strtok() strips those off * also. */ char * strtokm(char * s1, const char * delimit); #ifndef __has_feature #define __has_feature(x) 0 #endif #if /* is ASAN enabled? */ \ __has_feature(address_sanitizer) /* Clang */ \ || defined(__SANITIZE_ADDRESS__) /* GCC 4.8.x */ #define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS \ __attribute__((no_address_safety_analysis)) __attribute__((noinline)) #define WITH_ASAN #else #define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS #endif #endif
C/C++
aircrack-ng/include/aircrack-ng/ce-wpa/pseudo_intrinsics.h
/* * Based on John the Ripper and modified to integrate with aircrack * * John the Ripper copyright and license. * * John the Ripper password cracker, * Copyright (c) 1996-2013 by Solar Designer. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * As a special exception to the GNU General Public License terms, * permission is hereby granted to link the code of this program, with or * without modification, with any version of the OpenSSL library and/or any * version of unRAR, and to distribute such linked combinations. You must * obey the GNU GPL in all respects for all of the code used other than * OpenSSL and unRAR. If you modify this program, you may extend this * exception to your version of the program, but you are not obligated to * do so. (In other words, you may release your derived work under pure * GNU GPL version 2 or later as published by the FSF.) * * (This exception from the GNU GPL is not required for the core tree of * John the Ripper, but arguably it is required for -jumbo.) * * Relaxed terms for certain components. * * In addition or alternatively to the license above, many components are * available to you under more relaxed terms (most commonly under cut-down * BSD license) as specified in the corresponding source files. * * For more information on John the Ripper licensing please visit: * * http://www.openwall.com/john/doc/LICENSE.shtml * * Minimalistic pseudo-instrinsics for width-agnostic x86 SIMD code. * * This software is Copyright (c) 2015 magnum, * Copyright (c) 2015 JimF, * Copyright (c) 2015 Lei Zhang, * and it is hereby released to the general public under the following terms: * Redistribution and use in source and binary forms, with or without * modification, are permitted. * * Synopsis: * * SSE2: __m128i a = _mm_add_epi32(b, c); * AVX2: __m256i a = _mm256_add_epi32(b, c); * AVX512: __m512i a = _mm512_add_epi32(b, c); * -> Pseudo: vtype a = vadd_epi32(b, c); * * SSE2: __m128i a = _mm_load_si128(p); * AVX2: __m256i a = _mm256_load_si256(p); * AVX512: __m512i a = _mm512_load_si512(p); * -> Pseudo: vtype a = vload(p); * * intrinsics are emulated where the target does not support them. */ #ifndef _SSE_PSEUDO_H #define _SSE_PSEUDO_H #include <stdint.h> #include <aircrack-ng/ce-wpa/arch.h> #if SIMD_COEF_32 #include <aircrack-ng/ce-wpa/aligned.h> #include <aircrack-ng/ce-wpa/jcommon.h> /* for is_aligned() */ /*************************** NEON (ARM) *******************************/ #ifdef __ARM_NEON__ #include <arm_neon.h> typedef uint8x16_t vtype8; typedef uint32x4_t vtype; /* the default one */ typedef uint64x2_t vtype64; #define vadd_epi32 vaddq_u32 #define vadd_epi64(x, y) (vtype) vaddq_u64((vtype64)(x), (vtype64)(y)) #define vand vandq_u32 #define vandnot(x, y) vbicq_u32(y, x) #define vcmov(x, y, z) vbslq_u32(z, x, y) #define vload(m) vld1q_u32((uint32_t *) (m)) #define vloadu vloadu_emu #define VLOADU_EMULATED 1 #define vor vorrq_u32 #define vorn vornq_u32 #define vroti_epi32(x, i) \ (i > 0 ? vsliq_n_u32(vshrq_n_u32(x, (32 - ((i) &31)) & 31), x, (i) &31) \ : vsriq_n_u32(vshlq_n_u32(x, (32 + ((i) &31)) & 31), x, -(i) &31)) #define vroti_epi64(x, i) \ (i > 0 ? (vtype) vsliq_n_u64( \ vshrq_n_u64((vtype64)(x), 64 - (i)), (vtype64)(x), i) \ : (vtype) vsriq_n_u64( \ vshlq_n_u64((vtype64)(x), 64 + (i)), (vtype64)(x), -(i))) #define vroti16_epi32 vroti_epi32 #define vset1_epi32(x) vdupq_n_u32(x) #define vset1_epi64(x) (vtype) vdupq_n_u64(x) #define vset_epi32(x3, x2, x1, x0) \ vcombine_u32(vcreate_u32(((uint64_t)(x1) << 32) | (x0)), \ vcreate_u32(((uint64_t)(x3) << 32) | (x2))) #define vset_epi64(x1, x0) \ (vtype) vcombine_u64(vcreate_u64(x0), vcreate_u64(x1)) #define vsetzero() vset1_epi32(0) #define vslli_epi32(x, i) vshlq_n_u32(x, i) #define vslli_epi64(x, i) (vtype) vshlq_n_u64((vtype64)(x), i) #define vsrli_epi32(x, i) vshrq_n_u32(x, i) #define vsrli_epi64(x, i) (vtype) vshrq_n_u64((vtype64)(x), i) #define vstore(m, x) vst1q_u32((uint32_t *) (m), x) #define vstoreu vstoreu_emu #define VSTOREU_EMULATED 1 #define vunpackhi_epi32(x, y) (vzipq_u32(x, y)).val[1] #define vunpackhi_epi64(x, y) \ vset_epi64(vgetq_lane_u64((vtype64)(y), 1), vgetq_lane_u64((vtype64)(x), 1)) #define vunpacklo_epi32(x, y) (vzipq_u32(x, y)).val[0] #define vunpacklo_epi64(x, y) \ vset_epi64(vgetq_lane_u64((vtype64)(y), 0), vgetq_lane_u64((vtype64)(x), 0)) #define vxor veorq_u32 static inline int vanyeq_epi32(vtype x, vtype y) { vtype z = vceqq_u32(x, y); return vgetq_lane_u32(z, 0) || vgetq_lane_u32(z, 1) || vgetq_lane_u32(z, 2) || vgetq_lane_u32(z, 3); } #define vswap32(x) (x = (vtype) vrev32q_u8((vtype8) x)) #define vswap64(x) (x = (vtype) vrev64q_u8((vtype8) x)) #define GATHER64(x, y, z) \ { \ x = vset_epi64(y[1][z], y[0][z]); \ } /*************************** AltiVec (Power) **************************/ #elif __ALTIVEC__ #include <altivec.h> #if defined(__clang__) #pragma clang diagnostic ignored "-Wpedantic" #elif defined(__GNUC__) #pragma GCC diagnostic ignored "-Wpedantic" #endif typedef vector unsigned int vtype32; typedef vector unsigned long vtype64; typedef union { vtype32 v32; vtype64 v64; uint32_t s32[SIMD_COEF_32]; uint64_t s64[SIMD_COEF_64]; } vtype; #define vadd_epi32(x, y) (vtype) vec_add((x).v32, (y).v32) #define vadd_epi64(x, y) (vtype) vec_add((x).v64, (y).v64) #define vand(x, y) (vtype) vec_and((x).v32, (y).v32) #define vandnot(x, y) (vtype) vec_andc((y).v32, (x).v32) #define vcmov(x, y, z) (vtype) vec_sel((y).v32, (x).v32, (z).v32) #define vload(m) (vtype)(vtype32) vec_ld(0, (uint32_t *) (m)) #define vloadu vloadu_emu #define VLOADU_EMULATED 1 #define vor(x, y) (vtype) vec_or((x).v32, (y).v32) #define vroti_epi32(x, i) (vtype) vec_rl((x).v32, (vset1_epi32(i)).v32) #define vroti_epi64(x, i) (vtype) vec_rl((x).v64, (vset1_epi64(i)).v64) #define vroti16_epi32 vroti_epi32 #define vset1_epi32(x) vset_epi32(x, x, x, x) #define vset1_epi64(x) vset_epi64(x, x) #define vset_epi32(x3, x2, x1, x0) \ (vtype)(vtype32) { x0, x1, x2, x3 } #define vset_epi64(x1, x0) \ (vtype)(vtype64) { x0, x1 } #define vsetzero() vset1_epi32(0) #define vslli_epi32(x, i) (vtype) vec_sl((x).v32, (vset1_epi32(i)).v32) #define vslli_epi64(x, i) (vtype) vec_sl((x).v64, (vset1_epi64(i)).v64) #define vsrli_epi32(x, i) (vtype) vec_sr((x).v32, (vset1_epi32(i)).v32) #define vsrli_epi64(x, i) (vtype) vec_sr((x).v64, (vset1_epi64(i)).v64) #define vstore(m, x) vec_st((x).v32, 0, (uint32_t *) (m)) #define vstoreu vstoreu_emu #define VSTOREU_EMULATED 1 #define vunpackhi_epi32(x, y) (vtype) vec_mergel((x).v32, (y).v32) #define vunpackhi_epi64(x, y) \ (vtype)(vtype64) vec_mergel((vector long) (x).v64, (vector long) (y).v64) #define vunpacklo_epi32(x, y) (vtype) vec_mergeh((x).v32, (y).v32) #define vunpacklo_epi64(x, y) \ (vtype)(vtype64) vec_mergeh((vector long) (x).v64, (vector long) (y).v64) #define vxor(x, y) (vtype) vec_xor((x).v32, (y).v32) #define vanyeq_epi32(x, y) vec_any_eq((x).v32, (y).v32) #define vswap32 vswap32_emu #define vswap64 vswap64_emu #define GATHER64(x, y, z) \ { \ x = vset_epi64(y[1][z], y[0][z]); \ } /*************************** AVX512 and MIC ***************************/ #elif __AVX512F__ || __MIC__ #include <immintrin.h> typedef __m512i vtype; #define vadd_epi32 _mm512_add_epi32 #define vadd_epi64 _mm512_add_epi64 #define vand _mm512_and_si512 #define vandnot _mm512_andnot_si512 #define vcmov vcmov_emu #define VCMOV_EMULATED 1 /* * NOTE: AVX2 has it as (base, index, scale) while MIC and AVX512 are * different. */ #define vgather_epi32(b, i, s) _mm512_i32gather_epi32(i, (void *) (b), s) #define vgather_epi64(b, i, s) _mm512_i64gather_epi64(i, (void *) (b), s) #define vload(x) _mm512_load_si512((void *) (x)) #define vloadu(x) _mm512_loadu_si512((void *) (x)) #define vor _mm512_or_si512 #define vroti_epi32 vroti_epi32_emu #define vroti_epi64 vroti_epi64_emu #define vroti16_epi32 vroti_epi32 #define vscatter_epi32(b, i, v, s) _mm512_i32scatter_epi32((void *) b, i, v, s) #define vscatter_epi64(b, i, v, s) _mm512_i64scatter_epi64((void *) b, i, v, s) #define vset1_epi8 _mm512_set1_epi8 #define vset1_epi32 _mm512_set1_epi32 #define vset1_epi64 _mm512_set1_epi64 #define vset_epi32 _mm512_set_epi32 #define vset_epi64 _mm512_set_epi64 #define vsetzero _mm512_setzero_si512 #define vshuffle_epi32 _mm512_shuffle_epi32 #define vslli_epi32 _mm512_slli_epi32 #define vslli_epi64 _mm512_slli_epi64 #define vsrli_epi32 _mm512_srli_epi32 #define vsrli_epi64 _mm512_srli_epi64 #define vstore(x, y) _mm512_store_si512((void *) (x), y) #define vstoreu(x, y) _mm512_storeu_si512((void *) (x), y) #define vunpackhi_epi32 _mm512_unpackhi_epi32 #define vunpackhi_epi64 _mm512_unpackhi_epi64 #define vunpacklo_epi32 _mm512_unpacklo_epi32 #define vunpacklo_epi64 _mm512_unpacklo_epi64 #define vxor _mm512_xor_si512 #define vanyeq_epi32(x, y) _mm512_cmp_epi32_mask(x, y, _MM_CMPINT_EQ) #define GATHER_4x(x, y, z) \ { \ vtype indices = vset_epi32(15 << 6, \ 14 << 6, \ 13 << 6, \ 12 << 6, \ 11 << 6, \ 10 << 6, \ 9 << 6, \ 8 << 6, \ 7 << 6, \ 6 << 6, \ 5 << 6, \ 4 << 6, \ 3 << 6, \ 2 << 6, \ 1 << 6, \ 0 << 6); \ x = vgather_epi32(&y[z], indices, sizeof(y[z])); \ } #define GATHER_2x(x, y, z) \ { \ vtype indices = vset_epi32(15 << 5, \ 14 << 5, \ 13 << 5, \ 12 << 5, \ 11 << 5, \ 10 << 5, \ 9 << 5, \ 8 << 5, \ 7 << 5, \ 6 << 5, \ 5 << 5, \ 4 << 5, \ 3 << 5, \ 2 << 5, \ 1 << 5, \ 0 << 5); \ x = vgather_epi32(&y[z], indices, sizeof(y[z])); \ } #define GATHER(x, y, z) \ { \ vtype indices = vset_epi32(15 << 4, \ 14 << 4, \ 13 << 4, \ 12 << 4, \ 11 << 4, \ 10 << 4, \ 9 << 4, \ 8 << 4, \ 7 << 4, \ 6 << 4, \ 5 << 4, \ 4 << 4, \ 3 << 4, \ 2 << 4, \ 1 << 4, \ 0 << 4); \ x = vgather_epi32(&y[z], indices, sizeof(y[z])); \ } #define GATHER64(x, y, z) \ { \ uint64_t stride = sizeof(*y); \ vtype indices = vset_epi64(7 * stride, \ 6 * stride, \ 5 * stride, \ 4 * stride, \ 3 * stride, \ 2 * stride, \ 1 * stride, \ 0); \ x = vgather_epi64(&y[0][z], indices, 1); \ } #if __AVX512F__ #undef vcmov #undef VCMOV_EMULATED #define vcmov(x, y, z) vternarylogic(x, y, z, 0xE4) #define vternarylogic _mm512_ternarylogic_epi32 #endif #if __AVX512BW__ #define vcmpeq_epi8_mask (uint64_t) _mm512_cmpeq_epi8_mask #define vshuffle_epi8 _mm512_shuffle_epi8 #define vshufflehi_epi16 _mm512_shufflehi_epi16 #define vshufflelo_epi16 _mm512_shufflelo_epi16 #define vslli_epi16 _mm512_slli_epi16 #define vsrli_epi16 _mm512_srli_epi16 #define vswap32(n) \ n = vshuffle_epi8(n, \ vset_epi32(0x3c3d3e3f, \ 0x38393a3b, \ 0x34353637, \ 0x30313233, \ 0x2c2d2e2f, \ 0x28292a2b, \ 0x24252627, \ 0x20212223, \ 0x1c1d1e1f, \ 0x18191a1b, \ 0x14151617, \ 0x10111213, \ 0x0c0d0e0f, \ 0x08090a0b, \ 0x04050607, \ 0x00010203)) #define vswap64(n) \ n = vshuffle_epi8(n, \ vset_epi64(0x38393a3b3c3d3e3fULL, \ 0x3031323334353637ULL, \ 0x28292a2b2c2d2e2fULL, \ 0x2021222324252627ULL, \ 0x18191a1b1c1d1e1fULL, \ 0x1011121314151617ULL, \ 0x08090a0b0c0d0e0fULL, \ 0x0001020304050607ULL)) #else /* workarounds without AVX512BW */ #define vswap32 vswap32_emu #define vswap64(x) (x = vshuffle_epi32(x, _MM_SHUFFLE(2, 3, 0, 1)), vswap32(x)) #endif /* __AVX512BW__ */ /* MIC lacks some intrinsics in AVX512F, thus needing emulation. */ #if __MIC__ #define _mm512_set1_epi8(x) \ _mm512_set1_epi32((x) | (x) << 8 | (x) << 16 | (x) << 24) static inline __m512i _mm512_loadu_si512(void const * addr) { __m512i indices = _mm512_set_epi64(7, 6, 5, 4, 3, 2, 1, 0); return is_aligned(addr, 64) ? _mm512_load_si512(addr) : _mm512_i64gather_epi64(indices, addr, 8); } static inline void _mm512_storeu_si512(void * addr, vtype d) { __m512i indices = _mm512_set_epi64(7, 6, 5, 4, 3, 2, 1, 0); if (is_aligned(addr, 64)) _mm512_store_si512(addr, d); else _mm512_i64scatter_epi64(addr, indices, d, 8); } #endif /* __MIC__ */ /******************************** AVX2 ********************************/ #elif __AVX2__ #include <immintrin.h> typedef __m256i vtype; #define vadd_epi32 _mm256_add_epi32 #define vadd_epi64 _mm256_add_epi64 #define vand _mm256_and_si256 #define vandnot _mm256_andnot_si256 #define vcmov vcmov_emu #define VCMOV_EMULATED 1 #define vcmpeq_epi8_mask(a, b) _mm256_movemask_epi8(_mm256_cmpeq_epi8(a, b)) #define vcmpeq_epi32 _mm256_cmpeq_epi32 #define vcvtsi32 _mm256_cvtsi32_si256 #define vgather_epi32(b, i, s) _mm256_i32gather_epi32((void *) (b), i, s) #define vgather_epi64(b, i, s) _mm256_i64gather_epi64((void *) (b), i, s) #define vinsert_epi32 _mm256_insert_epi32 #define vload(x) _mm256_load_si256((void *) (x)) #define vloadu(x) _mm256_loadu_si256((void *) (x)) #define vmovemask_epi8 _mm256_movemask_epi8 #define vor _mm256_or_si256 #define vpermute2x128 _mm256_permute2x128_si256 #define vpermute4x64_epi64 _mm256_permute4x64_epi64 #define vroti_epi32 vroti_epi32_emu #define vroti_epi64 vroti_epi64_emu #define vroti16_epi32 vroti_epi32 #define vset1_epi8 _mm256_set1_epi8 #define vset1_epi32 _mm256_set1_epi32 #define vset1_epi64 _mm256_set1_epi64x #define vset_epi32 _mm256_set_epi32 #define vset_epi64 _mm256_set_epi64x #define vsetzero _mm256_setzero_si256 #define vshuffle_epi8 _mm256_shuffle_epi8 #define vshuffle_epi32 _mm256_shuffle_epi32 #define vshufflehi_epi16 _mm256_shufflehi_epi16 #define vshufflelo_epi16 _mm256_shufflelo_epi16 #define vslli_epi16 _mm256_slli_epi16 #define vslli_epi32 _mm256_slli_epi32 #define vslli_epi64 _mm256_slli_epi64 #define vsrli_epi16 _mm256_srli_epi16 #define vsrli_epi32 _mm256_srli_epi32 #define vsrli_epi64 _mm256_srli_epi64 #define vstore(x, y) _mm256_store_si256((void *) (x), y) #define vstoreu(x, y) _mm256_storeu_si256((void *) (x), y) #define vunpackhi_epi32 _mm256_unpackhi_epi32 #define vunpackhi_epi64 _mm256_unpackhi_epi64 #define vunpacklo_epi32 _mm256_unpacklo_epi32 #define vunpacklo_epi64 _mm256_unpacklo_epi64 #define vxor _mm256_xor_si256 #define vanyeq_epi32(x, y) vmovemask_epi8(vcmpeq_epi32(x, y)) #define swap_endian_mask \ _mm256_set_epi32(0x1c1d1e1f, \ 0x18191a1b, \ 0x14151617, \ 0x10111213, \ 0x0c0d0e0f, \ 0x08090a0b, \ 0x04050607, \ 0x00010203) #define swap_endian64_mask \ vset_epi64(0x18191a1b1c1d1e1fULL, \ 0x1011121314151617ULL, \ 0x08090a0b0c0d0e0fULL, \ 0x0001020304050607ULL) #define vswap32(n) (n = vshuffle_epi8(n, swap_endian_mask)) #define vswap64(n) (n = vshuffle_epi8(n, swap_endian64_mask)) #define GATHER_4x(x, y, z) \ { \ vtype indices = vset_epi32( \ 7 << 6, 6 << 6, 5 << 6, 4 << 6, 3 << 6, 2 << 6, 1 << 6, 0 << 6); \ x = vgather_epi32(&y[z], indices, sizeof(y[z])); \ } #define GATHER_2x(x, y, z) \ { \ vtype indices = vset_epi32( \ 7 << 5, 6 << 5, 5 << 5, 4 << 5, 3 << 5, 2 << 5, 1 << 5, 0 << 5); \ x = vgather_epi32(&y[z], indices, sizeof(y[z])); \ } #define GATHER(x, y, z) \ { \ vtype indices = vset_epi32( \ 7 << 4, 6 << 4, 5 << 4, 4 << 4, 3 << 4, 2 << 4, 1 << 4, 0 << 4); \ x = vgather_epi32(&y[z], indices, sizeof(y[z])); \ } #define GATHER64(x, y, z) \ { \ uint64_t stride = sizeof(*y); \ vtype indices = vset_epi64(3 * stride, 2 * stride, 1 * stride, 0); \ x = vgather_epi64(&y[0][z], indices, 1); \ } /************************* SSE2/3/4/AVX/XOP ***************************/ #elif __SSE2__ #if __XOP__ #include <x86intrin.h> #elif __AVX__ #include <immintrin.h> #elif __SSE4_1__ #include <smmintrin.h> #elif __SSSE3__ #include <tmmintrin.h> #endif #include <emmintrin.h> typedef __m128i vtype; #define vadd_epi32 _mm_add_epi32 #define vadd_epi64 _mm_add_epi64 #define vand _mm_and_si128 #define vandnot _mm_andnot_si128 #if __XOP__ #define vcmov _mm_cmov_si128 #else #define vcmov vcmov_emu #define VCMOV_EMULATED 1 #endif #define vcmpeq_epi8_mask(a, b) _mm_movemask_epi8(_mm_cmpeq_epi8(a, b)) #define vcmpeq_epi32 _mm_cmpeq_epi32 #if __SSE4_1__ #define vcvtsi32 _mm_cvtsi32_si128 #endif #define vinsert_epi32 _mm_insert_epi32 #define vload(x) _mm_load_si128((const vtype *) (x)) #define vloadu(x) _mm_loadu_si128((const vtype *) (x)) #define vmovemask_epi8 _mm_movemask_epi8 #define vor _mm_or_si128 #define vpermute4x64_epi64 _mm_permute4x64_epi64 #define vpermute2x128 _mm_permute2x128_si128 #if __XOP__ #define vroti_epi32 _mm_roti_epi32 #define vroti16_epi32 _mm_roti_epi32 #define vroti_epi64 _mm_roti_epi64 #else #define vroti_epi32 vroti_epi32_emu #define vroti_epi64 vroti_epi64_emu /* Specialized ROTL16 for SSE4.1 and lower (eg. MD5) */ #if __SSSE3__ #define vroti16_epi32(a, s) \ vshuffle_epi8((a), \ vset_epi32(0x0d0c0f0e, 0x09080b0a, 0x05040706, 0x01000302)) #elif __SSE2__ #define vroti16_epi32(a, s) vshufflelo_epi16(vshufflehi_epi16((a), 0xb1), 0xb1) #else #define vroti16_epi32 vroti_epi32 #endif /* __SSSE3__ */ #endif /* __XOP__ */ #define vset_epi32 _mm_set_epi32 #define vset1_epi8 _mm_set1_epi8 #define vset1_epi32 _mm_set1_epi32 #ifndef _MSC_VER #define vset1_epi64 _mm_set1_epi64x #define vset_epi64 _mm_set_epi64x #else #define vset1_epi64 _mm_set1_epi64 #define vset_epi64 _mm_set_epi64 #endif #define vsetzero _mm_setzero_si128 #if __SSSE3__ #define vshuffle_epi8 _mm_shuffle_epi8 #endif #define vshuffle_epi32 _mm_shuffle_epi32 #define vshufflehi_epi16 _mm_shufflehi_epi16 #define vshufflelo_epi16 _mm_shufflelo_epi16 #define vslli_epi16 _mm_slli_epi16 #define vslli_epi32 _mm_slli_epi32 #define vslli_epi64 _mm_slli_epi64 #define vsrli_epi16 _mm_srli_epi16 #define vsrli_epi32 _mm_srli_epi32 #define vsrli_epi64 _mm_srli_epi64 #define vstore(x, y) _mm_store_si128((vtype *) (x), y) #define vstoreu(x, y) _mm_storeu_si128((vtype *) (x), y) #define vunpackhi_epi32 _mm_unpackhi_epi32 #define vunpackhi_epi64 _mm_unpackhi_epi64 #define vunpacklo_epi32 _mm_unpacklo_epi32 #define vunpacklo_epi64 _mm_unpacklo_epi64 #define vxor _mm_xor_si128 #define vanyeq_epi32(x, y) vmovemask_epi8(vcmpeq_epi32(x, y)) #if __SSSE3__ #define swap_endian_mask \ vset_epi32(0x0c0d0e0f, 0x08090a0b, 0x04050607, 0x00010203) #define vswap32(n) (n = vshuffle_epi8(n, swap_endian_mask)) #define swap_endian64_mask \ vset_epi64(0x08090a0b0c0d0e0fULL, 0x0001020304050607ULL) #define vswap64(n) (n = vshuffle_epi8(n, swap_endian64_mask)) #else /* Just basic SSE2 */ #define vswap32(n) \ (n = vxor(vsrli_epi16(vroti16_epi32(n, 16), 8), \ vslli_epi16(vroti16_epi32(n, 16), 8))) #define vswap64(n) \ (n = vshufflehi_epi16(vshufflelo_epi16(n, 0xb1), 0xb1), \ n = vxor(vslli_epi16(n, 8), vsrli_epi16(n, 8)), \ n = vshuffle_epi32(n, 0xb1)) #endif /* __SSSE3__ */ #if __SSE4_1__ #define GATHER_4x(x, y, z) \ { \ x = vcvtsi32(y[z]); \ x = vinsert_epi32(x, y[z + (1 << 6)], 1); \ x = vinsert_epi32(x, y[z + (2 << 6)], 2); \ x = vinsert_epi32(x, y[z + (3 << 6)], 3); \ } #define GATHER_2x(x, y, z) \ { \ x = vcvtsi32(y[z]); \ x = vinsert_epi32(x, y[z + (1 << 5)], 1); \ x = vinsert_epi32(x, y[z + (2 << 5)], 2); \ x = vinsert_epi32(x, y[z + (3 << 5)], 3); \ } #define GATHER(x, y, z) \ { \ x = vcvtsi32(y[z]); \ x = vinsert_epi32(x, y[z + (1 << 4)], 1); \ x = vinsert_epi32(x, y[z + (2 << 4)], 2); \ x = vinsert_epi32(x, y[z + (3 << 4)], 3); \ } #endif /* __SSE4_1__ */ #define GATHER64(x, y, z) \ { \ x = vset_epi64(y[1][z], y[0][z]); \ } #if _MSC_VER && !_M_X64 /* * These are slow, but the F'n 32 bit compiler will not build these intrinsics. * Only the 64-bit (Win64) MSVC compiler has these as intrinsics. These slow * ones let me debug, and develop this code, and work, but use CPU */ #define _mm_set_epi64 __mm_set_epi64 #define _mm_set1_epi64 __mm_set1_epi64 _inline __m128i _mm_set_epi64(long long a, long long b) { __m128i x; x.m128i_i64[0] = b; x.m128i_i64[1] = a; return x; } _inline __m128i _mm_set1_epi64(long long a) { __m128i x; x.m128i_i64[0] = x.m128i_i64[1] = a; return x; } #define vset1_epi64x(x) vset_epi64x(x, x) #define vset_epi64x(x1, x0) \ (vtype)(vtype64) { x0, x1 } #endif #endif /* __SIMD__ elif __SIMD__ elif __SIMD__ */ /************************* COMMON STUFF BELOW *************************/ #ifdef _MSC_VER #define MEM_ALIGN_SIMD 16 #define INLINE _inline #else #define MEM_ALIGN_SIMD (SIMD_COEF_32 * 4) #define INLINE inline #endif #if VLOADU_EMULATED static INLINE vtype vloadu_emu(const void * addr) { if (is_aligned(addr, MEM_ALIGN_SIMD)) return vload(addr); else { JTR_ALIGN(MEM_ALIGN_SIMD) char buf[sizeof(vtype)]; return vload(memcpy(buf, addr, sizeof(vtype))); } } #endif #if VSTOREU_EMULATED static INLINE void vstoreu_emu(void * addr, vtype v) { if (is_aligned(addr, MEM_ALIGN_SIMD)) vstore(addr, v); else { JTR_ALIGN(MEM_ALIGN_SIMD) char buf[sizeof(vtype)]; vstore(buf, v); memcpy(addr, buf, sizeof(vtype)); } } #endif #define vswap32_emu(x) \ (x = vxor(vsrli_epi32(x, 24), \ vxor(vslli_epi32(vsrli_epi32(vslli_epi32(x, 8), 24), 8), \ vxor(vsrli_epi32(vslli_epi32(vsrli_epi32(x, 8), 24), 8), \ vslli_epi32(x, 24))))) #define vswap64_emu(x) \ (x = vxor(vsrli_epi64(x, 32), vslli_epi64(x, 32)), vswap32_emu(x)) #if VCMOV_EMULATED #if VANDNOT_EMULATED /* currently never */ #define vcmov_emu(x, y, z) vxor(y, vand(z, vxor(x, y))) #else #define vcmov_emu(x, y, z) vxor(vand(z, x), vandnot(z, y)) #endif #endif #if __SSE3__ || __MIC__ #define vslli_epi64a(a, s) vslli_epi64(a, s) #else /* Optimization for really old CPUs for << 1 (for vroti -1) (eg. SHA512) */ #define vslli_epi64a(a, s) \ ((s) == 1 ? vadd_epi64((a), (a)) : vslli_epi64((a), (s))) #endif /* __SSE3__ || __MIC__ */ /* * vroti must handle both ROTL and ROTR. If s < 0, then ROTR. Note that * the ternary will normally be optimized away! */ #define vroti_epi32_emu(a, s) \ ((s) < 0 ? vxor(vsrli_epi32((a), ~(s) + 1), vslli_epi32((a), 32 + (s))) \ : vxor(vslli_epi32((a), (s)), vsrli_epi32((a), 32 - (s)))) #define vroti_epi64_emu(a, s) \ ((s) < 0 ? vxor(vsrli_epi64((a), ~(s) + 1), vslli_epi64a((a), 64 + (s))) \ : vxor(vslli_epi64a((a), (s)), vsrli_epi64((a), 64 - (s)))) #endif /* SIMD_COEF_32 */ #endif /* _SSE_PSEUDO_H */
C/C++
aircrack-ng/include/aircrack-ng/ce-wpa/simd-intrinsics-load-flags.h
/* * Based on John the Ripper and modified to integrate with aircrack * * John the Ripper copyright and license. * * John the Ripper password cracker, * Copyright (c) 1996-2013 by Solar Designer. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * As a special exception to the GNU General Public License terms, * permission is hereby granted to link the code of this program, with or * without modification, with any version of the OpenSSL library and/or any * version of unRAR, and to distribute such linked combinations. You must * obey the GNU GPL in all respects for all of the code used other than * OpenSSL and unRAR. If you modify this program, you may extend this * exception to your version of the program, but you are not obligated to * do so. (In other words, you may release your derived work under pure * GNU GPL version 2 or later as published by the FSF.) * * (This exception from the GNU GPL is not required for the core tree of * John the Ripper, but arguably it is required for -jumbo.) * * Relaxed terms for certain components. * * In addition or alternatively to the license above, many components are * available to you under more relaxed terms (most commonly under cut-down * BSD license) as specified in the corresponding source files. * * For more information on John the Ripper licensing please visit: * * http://www.openwall.com/john/doc/LICENSE.shtml * * This software is * Copyright (c) 2011-2015 JimF, * Copyright (c) 2011-2015 magnum, * and it is hereby released to the general public under the following terms: * Redistribution and use in source and binary forms, with or without * modification, are permitted. */ #ifndef __SSE_INTRINS_LOAD_FLAGS__ #define __SSE_INTRINS_LOAD_FLAGS__ /*************************************************************** * WARNING!!!! any changes to these numbers requires a new * build of simd-intrinsics-32.S and simd-intrinsics-64.S ***************************************************************/ /* * SSEi_MIXED_IN * Input is a ready-to-use array of 16xCOEF ints that are properly SIMD * interleaved, cleaned, appended with 0x80 and has a proper a length word. * The data will be copied to stack workspace. * * SSEi_FLAT_IN * Input is an array of 64xCOEF (128xCOEF_64 for 64 bit crypts) byte 'flat' * values, the hash function has to shuffle it. But 0x80 and length must be * in place. * * SSEi_CSTRING_IN * Input will be just as for OpenSSL: A normal char[COEF][64] array where * each string ends in NULL, with no 0x80 or length prepared. The intrinsics * function needs to take care of that as well as cleaning (after NULL), * shuffling and possibly do endian swapping if applicable. * * SSEi_FLAT_OUT * Output will be just as from OpenSSL. Swapped if applicable, not interleaved. * This should only be used for "final" crypt (and only for slow formats). * * SSEi_RELOAD * No init; state from last crypt is held in output buffer. * * SSEi_RELOAD_INP_FMT * No init; state from last crypt is held in output buffer. However, it is in * 'INPUT' format. This is a no-op unless PARA > 1. * * SSEi_OUTPUT_AS_INP_FMT * Write final output using 'INPUT' format. Will not matter unless PARA > 1 * * SSEi_REVERSE_STEPS * Reverse some steps, at minimum the "a = a + init". Only valid if not doing * reload, and if format does corresponding things in binary() et. al. * * SSEi_2BUF_INPUT * Input array is 2x in size, for a possible max input of 64+55 (119) bytes. * * SSEi_2BUF_INPUT_FIRST_BLK * Input array 2x in size. This is the first block, so we must rotate element * 14/15 if in flat mode. * * SSEi_4BUF_INPUT * Input array is 4x in size (This is seen in the dynamic type, for sha256. We * have 256 byte input buffers there). * * SSEi_4BUF_INPUT_FIRST_BLK * Input array 4x in size. This is the first block, so we must rotate element * 14/15 if in flat mode. * * SSEi_FLAT_RELOAD_SWAPLAST * Can be an issue for flat mode, and reload (i.e. multi buffers.) The last * limb should NEVER have this flag set. This also only 'affects' the SHA1 * and SHA256 formats. Similar to SSEi_4BUF_INPUT_FIRST_BLK, but simply says * we will have more buffers coming after this one. * * SSEi_CRYPT_SHA224 use SHA224 IV. * SSEi_CRYPT_SHA384 use SHA384 IV. * These are specific to SHA2 hashes. Reusing the same bit, since only 1 will * be used (i.e. it is not valid to do SSE_CRYPT_SHA224|SSE_CRYPT_SHA224) * * WARNING, SHA224 requires a FULL SHA256 width output buffer, and SHA384 * requires a full SHA512 width output buffer. This is to allow proper * reloading and doing multi-limb crypts. */ typedef enum { SSEi_MIXED_IN = 0x0, SSEi_FLAT_IN = 0x1, /* SSEi_CSTRING_IN = 0x2, NOT IMPLEMENTED YET*/ SSEi_FLAT_OUT = 0x4, SSEi_RELOAD = 0x8, SSEi_RELOAD_INP_FMT = 0x10 | SSEi_RELOAD, SSEi_OUTPUT_AS_INP_FMT = 0x20, SSEi_REVERSE_STEPS = 0x40, SSEi_2BUF_INPUT = 0x80, SSEi_2BUF_INPUT_FIRST_BLK = 0x100 | SSEi_2BUF_INPUT, SSEi_4BUF_INPUT = 0x200, SSEi_4BUF_INPUT_FIRST_BLK = 0x400 | SSEi_4BUF_INPUT, SSEi_FLAT_RELOAD_SWAPLAST = 0x800, SSEi_CRYPT_SHA224 = 0x1000, SSEi_CRYPT_SHA384 = 0x1000, SSEi_OUTPUT_AS_2BUF_INP_FMT = 0x2000 | SSEi_OUTPUT_AS_INP_FMT } SSEi_FLAGS; #endif /* __SSE_INTRINS_LOAD_FLAGS__ */
C/C++
aircrack-ng/include/aircrack-ng/ce-wpa/simd-intrinsics.h
/* * Based on John the Ripper and modified to integrate with aircrack * * John the Ripper copyright and license. * * John the Ripper password cracker, * Copyright (c) 1996-2013 by Solar Designer. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * As a special exception to the GNU General Public License terms, * permission is hereby granted to link the code of this program, with or * without modification, with any version of the OpenSSL library and/or any * version of unRAR, and to distribute such linked combinations. You must * obey the GNU GPL in all respects for all of the code used other than * OpenSSL and unRAR. If you modify this program, you may extend this * exception to your version of the program, but you are not obligated to * do so. (In other words, you may release your derived work under pure * GNU GPL version 2 or later as published by the FSF.) * * (This exception from the GNU GPL is not required for the core tree of * John the Ripper, but arguably it is required for -jumbo.) * * Relaxed terms for certain components. * * In addition or alternatively to the license above, many components are * available to you under more relaxed terms (most commonly under cut-down * BSD license) as specified in the corresponding source files. * * For more information on John the Ripper licensing please visit: * * http://www.openwall.com/john/doc/LICENSE.shtml * * This software is Copyright (c) 2010 bartavelle, <bartavelle at bandecon.com>, * and it is hereby released to the general public under the following terms: * Redistribution and use in source and binary forms, with or without * modification, are permitted. * * Some modifications, Jim Fougeron, 2013. Licensing rights listed in * accompanying simd-intrinsics.c file. */ #if !defined(__JTR_SSE_INTRINSICS_H__) #define __JTR_SSE_INTRINSICS_H__ #if (SIMD_COEF_32 && SIMD_COEF_32 == 2) || !SIMD_COEF_32 #undef SIMD_TYPE #define SIMD_TYPE "" #undef SIMD_COEF_32 #endif #include <aircrack-ng/ce-wpa/jcommon.h> #include <aircrack-ng/ce-wpa/pseudo_intrinsics.h> #include <aircrack-ng/ce-wpa/simd-intrinsics-load-flags.h> #include <aircrack-ng/ce-wpa/aligned.h> #ifndef _EMMINTRIN_H_INCLUDED #define __m128i void #endif #define vtype void #define STRINGIZE2(s) #s #define STRINGIZE(s) STRINGIZE2(s) #if __ALTIVEC__ #undef SIMD_TYPE #define SIMD_TYPE "AltiVec" #elif __ARM_NEON__ #undef SIMD_TYPE #define SIMD_TYPE "NEON" #elif __MIC__ #undef SIMD_TYPE #define SIMD_TYPE "MIC" #elif __AVX512F__ #undef SIMD_TYPE #define SIMD_TYPE "AVX512F" #elif __AVX2__ #undef SIMD_TYPE #define SIMD_TYPE "AVX2" #elif __XOP__ #undef SIMD_TYPE #define SIMD_TYPE "XOP" #elif __AVX__ #undef SIMD_TYPE #define SIMD_TYPE "AVX" #elif __SSE4_1__ #undef SIMD_TYPE #define SIMD_TYPE "SSE4.1" #elif __SSSE3__ #undef SIMD_TYPE #define SIMD_TYPE "SSSE3" #elif __SSE2__ #undef SIMD_TYPE #define SIMD_TYPE "SSE2" #elif SIMD_COEF_32 #undef SIMD_TYPE #define SIMD_TYPE "MMX" // not really supported #endif #if SIMD_COEF_32 == 16 #define BITS "512/512" #elif SIMD_COEF_32 == 8 #define BITS "256/256" #elif SIMD_COEF_32 == 4 #define BITS "128/128" #elif SIMD_COEF_32 == 2 #define BITS "64/64" #endif #ifdef SIMD_PARA_MD5 void md5cryptsse(unsigned char * buf, unsigned char * salt, char * out, unsigned int md5_type); void SIMDmd5body(vtype * data, ARCH_WORD_32 * out, ARCH_WORD_32 * reload_state, unsigned SSEi_flags); void md5_reverse(uint32_t * hash); void md5_unreverse(uint32_t * hash); #define MD5_ALGORITHM_NAME BITS " " SIMD_TYPE " " MD5_N_STR #else #define MD5_ALGORITHM_NAME "32/" ARCH_BITS_STR #endif #ifdef SIMD_PARA_MD4 // void SIMDmd4body(__m128i* data, unsigned int *out, int init); void SIMDmd4body(vtype * data, ARCH_WORD_32 * out, ARCH_WORD_32 * reload_state, unsigned SSEi_flags); void md4_reverse(uint32_t * hash); void md4_unreverse(uint32_t * hash); #define MD4_ALGORITHM_NAME BITS " " SIMD_TYPE " " MD4_N_STR #else #define MD4_ALGORITHM_NAME "32/" ARCH_BITS_STR #endif #ifdef SIMD_PARA_SHA1 void SIMDSHA1body(vtype * data, ARCH_WORD_32 * out, ARCH_WORD_32 * reload_state, unsigned SSEi_flags); void sha1_reverse(uint32_t * hash); void sha1_unreverse(uint32_t * hash); #define SHA1_ALGORITHM_NAME BITS " " SIMD_TYPE " " SHA1_N_STR #else #define SHA1_ALGORITHM_NAME "32/" ARCH_BITS_STR #endif // we use the 'outter' SIMD_COEF_32 wrapper, as the flag for SHA256/SHA512. // FIX_ME!! #if SIMD_COEF_32 > 1 #ifdef SIMD_COEF_32 #define SHA256_ALGORITHM_NAME BITS " " SIMD_TYPE " " SHA256_N_STR void SIMDSHA256body(vtype * data, ARCH_WORD_32 * out, ARCH_WORD_32 * reload_state, unsigned SSEi_flags); void sha224_reverse(uint32_t * hash); void sha224_unreverse(uint32_t * hash); void sha256_reverse(uint32_t * hash); void sha256_unreverse(void); #endif #ifdef SIMD_COEF_64 #define SHA512_ALGORITHM_NAME BITS " " SIMD_TYPE " " SHA512_N_STR void SIMDSHA512body(vtype * data, ARCH_WORD_64 * out, ARCH_WORD_64 * reload_state, unsigned SSEi_flags); void sha384_reverse(ARCH_WORD_64 * hash); void sha384_unreverse(ARCH_WORD_64 * hash); void sha512_reverse(ARCH_WORD_64 * hash); void sha512_unreverse(void); #endif #else #if ARCH_BITS >= 64 #define SHA256_ALGORITHM_NAME "64/" ARCH_BITS_STR " " SHA2_LIB #define SHA512_ALGORITHM_NAME "64/" ARCH_BITS_STR " " SHA2_LIB #else #define SHA256_ALGORITHM_NAME "32/" ARCH_BITS_STR " " SHA2_LIB #define SHA512_ALGORITHM_NAME "32/" ARCH_BITS_STR " " SHA2_LIB #endif #endif #undef vtype /* void */ #endif // __JTR_SSE_INTRINSICS_H__
C/C++
aircrack-ng/include/aircrack-ng/ce-wpa/wpapsk.h
/* * Based on John the Ripper and modified to integrate with aircrack * * John the Ripper copyright and license. * * John the Ripper password cracker, * Copyright (c) 1996-2013 by Solar Designer. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * As a special exception to the GNU General Public License terms, * permission is hereby granted to link the code of this program, with or * without modification, with any version of the OpenSSL library and/or any * version of unRAR, and to distribute such linked combinations. You must * obey the GNU GPL in all respects for all of the code used other than * OpenSSL and unRAR. If you modify this program, you may extend this * exception to your version of the program, but you are not obligated to * do so. (In other words, you may release your derived work under pure * GNU GPL version 2 or later as published by the FSF.) * * (This exception from the GNU GPL is not required for the core tree of * John the Ripper, but arguably it is required for -jumbo.) * * Relaxed terms for certain components. * * In addition or alternatively to the license above, many components are * available to you under more relaxed terms (most commonly under cut-down * BSD license) as specified in the corresponding source files. * * For more information on John the Ripper licensing please visit: * * http://www.openwall.com/john/doc/LICENSE.shtml * * This software is Copyright (c) 2012 Lukas Odzioba <lukas dot odzioba at gmail * dot com> * and Copyright (c) 2012-2014 magnum * and it is hereby released to the general public under the following terms: * Redistribution and use in source and binary forms, with or without * modification, are permitted. * * hccap format was introduced by oclHashcat-plus, and it is described here: * http://hashcat.net/wiki/hccap * Code is based on Aircrack-ng source */ #ifndef _WPAPSK_H #define _WPAPSK_H #include <assert.h> #include <string.h> #include <stdint.h> #include <aircrack-ng/crypto/crypto.h> #include <aircrack-ng/ce-wpa/arch.h> #include <aircrack-ng/ce-wpa/jcommon.h> #include <aircrack-ng/ce-wpa/johnswap.h> #include <aircrack-ng/ce-wpa/crypto_engine.h> #ifdef __cplusplus extern "C" { #endif void init_atoi(void); int init_wpapsk(ac_crypto_engine_t * engine, const wpapsk_password key[MAX_KEYS_PER_CRYPT_SUPPORTED], int nparallel, int threadid); #ifdef __cplusplus } #endif #endif /* _WPAPSK_H */
C/C++
aircrack-ng/include/aircrack-ng/cowpatty/cowpatty.h
/* * coWPAtty hash DB file format structures and helper functions * * Copyright (C) 2018-2022 Thomas d'Otreppe <tdotreppe@aircrack-ng.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef _COWPATTY_H_ #define _COWPATTY_H_ #include <stdint.h> #define MAX_PASSPHRASE_LENGTH 63 #define GENPMKMAGIC 0x43575041 struct hashdb_head { uint32_t magic; uint8_t reserved1[3]; uint8_t ssidlen; uint8_t ssid[32]; }; struct hashdb_rec { uint8_t rec_size; char * word; uint8_t pmk[32]; } __attribute__((packed)); struct cowpatty_file { char ssid[33]; FILE * fp; char error[256 - sizeof(FILE *) - 33]; }; void close_free_cowpatty_hashdb(struct cowpatty_file * cf); struct cowpatty_file * open_cowpatty_hashdb(const char * filename, const char * mode); struct hashdb_rec * read_next_cowpatty_record(struct cowpatty_file * cf); #endif // _COWPATTY_H_
C/C++
aircrack-ng/include/aircrack-ng/cpu/cpuset.h
/* * Copyright (C) 2018-2022 Joseph Benden <joe@benden.us> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef AIRCRACK_UTIL_CPUSET_H #define AIRCRACK_UTIL_CPUSET_H #include <sys/types.h> #ifdef __cplusplus extern "C" { #endif struct ac_cpuset; typedef struct ac_cpuset ac_cpuset_t; /// Allocate a new cpuset module handle. ac_cpuset_t * ac_cpuset_new(void); /// Deallocate a cpuset module handle. void ac_cpuset_free(ac_cpuset_t * cset); /// Initialize the cpuset module handle. void ac_cpuset_init(ac_cpuset_t * cset); /// Destroy the cpuset module handle. void ac_cpuset_destroy(ac_cpuset_t * cset); /// Distribute \a count threads over all available CPUs. void ac_cpuset_distribute(ac_cpuset_t * cset, size_t count); /// Bind \a tid to the CPU stored at the \a idx index position. void ac_cpuset_bind_thread_at(ac_cpuset_t * cset, pthread_t tid, size_t idx); #ifdef __cplusplus } #endif #endif
C/C++
aircrack-ng/include/aircrack-ng/cpu/simd_cpuid.h
/* * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef AIRCRACK_NG_CPUID_H #define AIRCRACK_NG_CPUID_H #ifdef __cplusplus extern "C" { #endif struct _cpuinfo { int simdsize; /* SIMD size */ char * flags; /* Feature Flags */ char * model; /* CPU Model */ int cores; /* Real CPU cores */ int coreperid; /* Max cores per id */ int htt; /* Hyper-Threading */ int maxlogic; /* Max addressible lCPU */ int hv; /* Hypervisor detected */ int cpufreq_cur; /* CPUfreq Current */ int cpufreq_max; /* CPUfreq Maximum */ float coretemp; /* CPU Temperature */ char * cputemppath; /* Linux CPU Sensor Path */ }; /** * Retrieve the number of 32-bit integers able to be packed into a single * vector register. * * This value is dependent on the running machine, and may not reflect what * the source code is able to process. PROGRAMMER BEWARE! * * @return int Number of 32-bit integers able to pack in one vector register. */ extern int cpuid_simdsize(int); /// Populates the \a cpuinfo with detected information about the running /// machine. extern int cpuid_getinfo(void); /// Structure containing information about the running machine. The /// function \a cpuid_getinfo must be called first! extern struct _cpuinfo cpuinfo; #ifdef __cplusplus }; #endif #endif // AIRCRACK_NG_CPUID_H
C/C++
aircrack-ng/include/aircrack-ng/cpu/trampoline.h
/* * Copyright (C) 2018-2022 Joseph Benden <joe@benden.us> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifndef AIRCRACK_NG_TRAMPOLINE_H #define AIRCRACK_NG_TRAMPOLINE_H #ifdef __cplusplus extern "C" { #endif #define SIMD_SUPPORTS_NONE (1 << 0) #define SIMD_SUPPORTS_MMX (1 << 1) #define SIMD_SUPPORTS_SSE2 (1 << 2) #define SIMD_SUPPORTS_AVX (1 << 3) #define SIMD_SUPPORTS_AVX2 (1 << 4) #define SIMD_SUPPORTS_NEON (1 << 5) #define SIMD_SUPPORTS_ASIMD (1 << 6) #define SIMD_SUPPORTS_ALTIVEC (1 << 7) #define SIMD_SUPPORTS_POWER8 (1 << 8) #define SIMD_SUPPORTS_AVX512F (1 << 9) void simd_init(void); int simd_get_supported_features(void); void simd_destroy(void); #ifdef __cplusplus }; #endif #endif
C/C++
aircrack-ng/include/aircrack-ng/crypto/aes.h
// clang-format off /** * \file aes.h * * \brief The Advanced Encryption Standard * * \ingroup * \cond ****************************************************************************** * * Portions Copyright (c) 2003-2016, Jouni Malinen <j@w1.fi> * SPDX-License-Identifier: BSD-3-CLAUSE * ****************************************************************************** * \endcond */ #ifndef LIB_CRYPTO_AES_H #define LIB_CRYPTO_AES_H #ifdef HAVE_CONFIG_H # include <config.h> #endif #include <stddef.h> // {s,ss}ize_t #include <stdint.h> // [u]int[8,16,32,64]_t #ifndef API_IMPORT # define API_IMPORT #endif #ifdef GCRYPT_WITH_AES # include <gcrypt.h> # define Cipher_AES_CTX gcry_cipher_hd_t #endif #ifdef OPENSSL_WITH_AES # include <openssl/evp.h> # define Cipher_AES_CTX EVP_CIPHER_CTX #endif #if !defined(GCRYPT_WITH_AES) && !defined(OPENSSL_WITH_AES) // # error "Missing an implementation of AES-128-CBC encryption." #define Cipher_AES_CTX void #endif /** * \brief AES encryption initialization function * * \param[in] key_len length of the key, in bytes * \param[in] key the secret key */ API_IMPORT Cipher_AES_CTX * Cipher_AES_Encrypt_Init(size_t key_len, const uint8_t key[static key_len]); /** * \brief AES encryption function * * \param[in] ctx AES context * \param[in] plain buffer holding the input data * \param[out] crypt buffer for the output data * * \return 0 if successful */ API_IMPORT int Cipher_AES_Encrypt(Cipher_AES_CTX *ctx, const uint8_t *plain, uint8_t *crypt); /** * \brief AES context destruction and resource clean-up * * \param[in] ctx AES context */ API_IMPORT void Cipher_AES_Encrypt_Deinit(Cipher_AES_CTX *ctx); #endif /* LIB_CRYPTO_AES_H */ // clang-format on
C/C++
aircrack-ng/include/aircrack-ng/crypto/arcfour.h
// clang-format off /** * \file arcfour.h * * \brief The ARCFOUR stream cipher * * \warning ARC4 is considered a weak cipher and its use constitutes a * security risk. We recommend considering stronger ciphers instead. * * \ingroup * \cond ****************************************************************************** * * Portitions are Copyright The Mbed TLS Contributors * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ****************************************************************************** * \endcond */ #ifndef LIB_CRYPTO_ARCFOUR_H #define LIB_CRYPTO_ARCFOUR_H #ifdef HAVE_CONFIG_H # include <config.h> #endif #include <stddef.h> // {s,ss}ize_t #include <stdint.h> // [u]int[8,16,32,64]_t #ifndef API_IMPORT # define API_IMPORT #endif #ifdef GCRYPT_WITH_ARCFOUR # define Cipher_RC4_KEY gcry_cipher_hd_t # define DEFINE_ARCFOUR_API 1 #endif #ifdef OPENSSL_WITH_ARCFOUR # if OPENSSL_VERSION_NUMBER < 0x30000000L # define Cipher_RC4_KEY RC4_KEY # define Cipher_RC4_set_key RC4_set_key # define Cipher_RC4 RC4 # else # define Cipher_RC4_KEY EVP_CIPHER_CTX # define DEFINE_ARCFOUR_API 1 # endif #endif #if !defined(GCRYPT_WITH_ARCFOUR) && !defined(OPENSSL_WITH_ARCFOUR) # define DEFINE_ARCFOUR_API 1 # define DEFINE_ARCFOUR_CONTEXT 1 #endif #ifdef DEFINE_ARCFOUR_CONTEXT /** * \brief ARC4 context structure * * \warning ARC4 is considered a weak cipher and its use constitutes a * security risk. We recommend considering stronger ciphers instead. * */ typedef struct Cipher_RC4_KEY { int x; /*!< permutation index */ int y; /*!< permutation index */ uint8_t m[256]; /*!< permutation table */ } Cipher_RC4_KEY; #endif #ifdef DEFINE_ARCFOUR_API /** * \brief ARC4 key schedule * * \param[in] ctx ARC4 context to be setup * \param[in] keylen length of the key, in bytes * \param[in] key the secret key * * \warning ARC4 is considered a weak cipher and its use constitutes * a security risk. We recommend considering stronger * ciphers instead. */ API_IMPORT void Cipher_RC4_set_key( Cipher_RC4_KEY *ctx, size_t keylen, const uint8_t key[static keylen] ); /** * \brief ARC4 cipher function * * \param[in] ctx ARC4 context * \param[in] length length of the input data * \param[in] input buffer holding the input data * \param[out] output buffer for the output data * * \return 0 if successful * * \warning ARC4 is considered a weak cipher and its use constitutes * a security risk. We recommend considering stronger * ciphers instead. */ API_IMPORT int Cipher_RC4( Cipher_RC4_KEY *ctx, size_t length, const uint8_t input[static length], uint8_t output[static length] ); #endif #endif /* LIB_CRYPTO_ARCFOUR_H */ // clang-format on
C/C++
aircrack-ng/include/aircrack-ng/crypto/crctable.h
#ifndef _CRCTABLE_H #define _CRCTABLE_H const unsigned long int crc_tbl[256] = {0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D}; const unsigned char crc_chop_tbl[256][4] = {{0x26, 0x70, 0x6A, 0x0F}, {0x67, 0x76, 0x1B, 0xD4}, {0xE5, 0x7A, 0xF9, 0x62}, {0xA4, 0x7C, 0x88, 0xB9}, {0xA0, 0x65, 0x4C, 0xD4}, {0xE1, 0x63, 0x3D, 0x0F}, {0x63, 0x6F, 0xDF, 0xB9}, {0x22, 0x69, 0xAE, 0x62}, {0x6B, 0x5D, 0x57, 0x62}, {0x2A, 0x5B, 0x26, 0xB9}, {0xA8, 0x57, 0xC4, 0x0F}, {0xE9, 0x51, 0xB5, 0xD4}, {0xED, 0x48, 0x71, 0xB9}, {0xAC, 0x4E, 0x00, 0x62}, {0x2E, 0x42, 0xE2, 0xD4}, {0x6F, 0x44, 0x93, 0x0F}, {0xBC, 0x2A, 0x10, 0xD5}, {0xFD, 0x2C, 0x61, 0x0E}, {0x7F, 0x20, 0x83, 0xB8}, {0x3E, 0x26, 0xF2, 0x63}, {0x3A, 0x3F, 0x36, 0x0E}, {0x7B, 0x39, 0x47, 0xD5}, {0xF9, 0x35, 0xA5, 0x63}, {0xB8, 0x33, 0xD4, 0xB8}, {0xF1, 0x07, 0x2D, 0xB8}, {0xB0, 0x01, 0x5C, 0x63}, {0x32, 0x0D, 0xBE, 0xD5}, {0x73, 0x0B, 0xCF, 0x0E}, {0x77, 0x12, 0x0B, 0x63}, {0x36, 0x14, 0x7A, 0xB8}, {0xB4, 0x18, 0x98, 0x0E}, {0xF5, 0x1E, 0xE9, 0xD5}, {0x53, 0xC3, 0xEF, 0x60}, {0x12, 0xC5, 0x9E, 0xBB}, {0x90, 0xC9, 0x7C, 0x0D}, {0xD1, 0xCF, 0x0D, 0xD6}, {0xD5, 0xD6, 0xC9, 0xBB}, {0x94, 0xD0, 0xB8, 0x60}, {0x16, 0xDC, 0x5A, 0xD6}, {0x57, 0xDA, 0x2B, 0x0D}, {0x1E, 0xEE, 0xD2, 0x0D}, {0x5F, 0xE8, 0xA3, 0xD6}, {0xDD, 0xE4, 0x41, 0x60}, {0x9C, 0xE2, 0x30, 0xBB}, {0x98, 0xFB, 0xF4, 0xD6}, {0xD9, 0xFD, 0x85, 0x0D}, {0x5B, 0xF1, 0x67, 0xBB}, {0x1A, 0xF7, 0x16, 0x60}, {0xC9, 0x99, 0x95, 0xBA}, {0x88, 0x9F, 0xE4, 0x61}, {0x0A, 0x93, 0x06, 0xD7}, {0x4B, 0x95, 0x77, 0x0C}, {0x4F, 0x8C, 0xB3, 0x61}, {0x0E, 0x8A, 0xC2, 0xBA}, {0x8C, 0x86, 0x20, 0x0C}, {0xCD, 0x80, 0x51, 0xD7}, {0x84, 0xB4, 0xA8, 0xD7}, {0xC5, 0xB2, 0xD9, 0x0C}, {0x47, 0xBE, 0x3B, 0xBA}, {0x06, 0xB8, 0x4A, 0x61}, {0x02, 0xA1, 0x8E, 0x0C}, {0x43, 0xA7, 0xFF, 0xD7}, {0xC1, 0xAB, 0x1D, 0x61}, {0x80, 0xAD, 0x6C, 0xBA}, {0xCC, 0x16, 0x61, 0xD0}, {0x8D, 0x10, 0x10, 0x0B}, {0x0F, 0x1C, 0xF2, 0xBD}, {0x4E, 0x1A, 0x83, 0x66}, {0x4A, 0x03, 0x47, 0x0B}, {0x0B, 0x05, 0x36, 0xD0}, {0x89, 0x09, 0xD4, 0x66}, {0xC8, 0x0F, 0xA5, 0xBD}, {0x81, 0x3B, 0x5C, 0xBD}, {0xC0, 0x3D, 0x2D, 0x66}, {0x42, 0x31, 0xCF, 0xD0}, {0x03, 0x37, 0xBE, 0x0B}, {0x07, 0x2E, 0x7A, 0x66}, {0x46, 0x28, 0x0B, 0xBD}, {0xC4, 0x24, 0xE9, 0x0B}, {0x85, 0x22, 0x98, 0xD0}, {0x56, 0x4C, 0x1B, 0x0A}, {0x17, 0x4A, 0x6A, 0xD1}, {0x95, 0x46, 0x88, 0x67}, {0xD4, 0x40, 0xF9, 0xBC}, {0xD0, 0x59, 0x3D, 0xD1}, {0x91, 0x5F, 0x4C, 0x0A}, {0x13, 0x53, 0xAE, 0xBC}, {0x52, 0x55, 0xDF, 0x67}, {0x1B, 0x61, 0x26, 0x67}, {0x5A, 0x67, 0x57, 0xBC}, {0xD8, 0x6B, 0xB5, 0x0A}, {0x99, 0x6D, 0xC4, 0xD1}, {0x9D, 0x74, 0x00, 0xBC}, {0xDC, 0x72, 0x71, 0x67}, {0x5E, 0x7E, 0x93, 0xD1}, {0x1F, 0x78, 0xE2, 0x0A}, {0xB9, 0xA5, 0xE4, 0xBF}, {0xF8, 0xA3, 0x95, 0x64}, {0x7A, 0xAF, 0x77, 0xD2}, {0x3B, 0xA9, 0x06, 0x09}, {0x3F, 0xB0, 0xC2, 0x64}, {0x7E, 0xB6, 0xB3, 0xBF}, {0xFC, 0xBA, 0x51, 0x09}, {0xBD, 0xBC, 0x20, 0xD2}, {0xF4, 0x88, 0xD9, 0xD2}, {0xB5, 0x8E, 0xA8, 0x09}, {0x37, 0x82, 0x4A, 0xBF}, {0x76, 0x84, 0x3B, 0x64}, {0x72, 0x9D, 0xFF, 0x09}, {0x33, 0x9B, 0x8E, 0xD2}, {0xB1, 0x97, 0x6C, 0x64}, {0xF0, 0x91, 0x1D, 0xBF}, {0x23, 0xFF, 0x9E, 0x65}, {0x62, 0xF9, 0xEF, 0xBE}, {0xE0, 0xF5, 0x0D, 0x08}, {0xA1, 0xF3, 0x7C, 0xD3}, {0xA5, 0xEA, 0xB8, 0xBE}, {0xE4, 0xEC, 0xC9, 0x65}, {0x66, 0xE0, 0x2B, 0xD3}, {0x27, 0xE6, 0x5A, 0x08}, {0x6E, 0xD2, 0xA3, 0x08}, {0x2F, 0xD4, 0xD2, 0xD3}, {0xAD, 0xD8, 0x30, 0x65}, {0xEC, 0xDE, 0x41, 0xBE}, {0xE8, 0xC7, 0x85, 0xD3}, {0xA9, 0xC1, 0xF4, 0x08}, {0x2B, 0xCD, 0x16, 0xBE}, {0x6A, 0xCB, 0x67, 0x65}, {0xB3, 0xBB, 0x0D, 0x6A}, {0xF2, 0xBD, 0x7C, 0xB1}, {0x70, 0xB1, 0x9E, 0x07}, {0x31, 0xB7, 0xEF, 0xDC}, {0x35, 0xAE, 0x2B, 0xB1}, {0x74, 0xA8, 0x5A, 0x6A}, {0xF6, 0xA4, 0xB8, 0xDC}, {0xB7, 0xA2, 0xC9, 0x07}, {0xFE, 0x96, 0x30, 0x07}, {0xBF, 0x90, 0x41, 0xDC}, {0x3D, 0x9C, 0xA3, 0x6A}, {0x7C, 0x9A, 0xD2, 0xB1}, {0x78, 0x83, 0x16, 0xDC}, {0x39, 0x85, 0x67, 0x07}, {0xBB, 0x89, 0x85, 0xB1}, {0xFA, 0x8F, 0xF4, 0x6A}, {0x29, 0xE1, 0x77, 0xB0}, {0x68, 0xE7, 0x06, 0x6B}, {0xEA, 0xEB, 0xE4, 0xDD}, {0xAB, 0xED, 0x95, 0x06}, {0xAF, 0xF4, 0x51, 0x6B}, {0xEE, 0xF2, 0x20, 0xB0}, {0x6C, 0xFE, 0xC2, 0x06}, {0x2D, 0xF8, 0xB3, 0xDD}, {0x64, 0xCC, 0x4A, 0xDD}, {0x25, 0xCA, 0x3B, 0x06}, {0xA7, 0xC6, 0xD9, 0xB0}, {0xE6, 0xC0, 0xA8, 0x6B}, {0xE2, 0xD9, 0x6C, 0x06}, {0xA3, 0xDF, 0x1D, 0xDD}, {0x21, 0xD3, 0xFF, 0x6B}, {0x60, 0xD5, 0x8E, 0xB0}, {0xC6, 0x08, 0x88, 0x05}, {0x87, 0x0E, 0xF9, 0xDE}, {0x05, 0x02, 0x1B, 0x68}, {0x44, 0x04, 0x6A, 0xB3}, {0x40, 0x1D, 0xAE, 0xDE}, {0x01, 0x1B, 0xDF, 0x05}, {0x83, 0x17, 0x3D, 0xB3}, {0xC2, 0x11, 0x4C, 0x68}, {0x8B, 0x25, 0xB5, 0x68}, {0xCA, 0x23, 0xC4, 0xB3}, {0x48, 0x2F, 0x26, 0x05}, {0x09, 0x29, 0x57, 0xDE}, {0x0D, 0x30, 0x93, 0xB3}, {0x4C, 0x36, 0xE2, 0x68}, {0xCE, 0x3A, 0x00, 0xDE}, {0x8F, 0x3C, 0x71, 0x05}, {0x5C, 0x52, 0xF2, 0xDF}, {0x1D, 0x54, 0x83, 0x04}, {0x9F, 0x58, 0x61, 0xB2}, {0xDE, 0x5E, 0x10, 0x69}, {0xDA, 0x47, 0xD4, 0x04}, {0x9B, 0x41, 0xA5, 0xDF}, {0x19, 0x4D, 0x47, 0x69}, {0x58, 0x4B, 0x36, 0xB2}, {0x11, 0x7F, 0xCF, 0xB2}, {0x50, 0x79, 0xBE, 0x69}, {0xD2, 0x75, 0x5C, 0xDF}, {0x93, 0x73, 0x2D, 0x04}, {0x97, 0x6A, 0xE9, 0x69}, {0xD6, 0x6C, 0x98, 0xB2}, {0x54, 0x60, 0x7A, 0x04}, {0x15, 0x66, 0x0B, 0xDF}, {0x59, 0xDD, 0x06, 0xB5}, {0x18, 0xDB, 0x77, 0x6E}, {0x9A, 0xD7, 0x95, 0xD8}, {0xDB, 0xD1, 0xE4, 0x03}, {0xDF, 0xC8, 0x20, 0x6E}, {0x9E, 0xCE, 0x51, 0xB5}, {0x1C, 0xC2, 0xB3, 0x03}, {0x5D, 0xC4, 0xC2, 0xD8}, {0x14, 0xF0, 0x3B, 0xD8}, {0x55, 0xF6, 0x4A, 0x03}, {0xD7, 0xFA, 0xA8, 0xB5}, {0x96, 0xFC, 0xD9, 0x6E}, {0x92, 0xE5, 0x1D, 0x03}, {0xD3, 0xE3, 0x6C, 0xD8}, {0x51, 0xEF, 0x8E, 0x6E}, {0x10, 0xE9, 0xFF, 0xB5}, {0xC3, 0x87, 0x7C, 0x6F}, {0x82, 0x81, 0x0D, 0xB4}, {0x00, 0x8D, 0xEF, 0x02}, {0x41, 0x8B, 0x9E, 0xD9}, {0x45, 0x92, 0x5A, 0xB4}, {0x04, 0x94, 0x2B, 0x6F}, {0x86, 0x98, 0xC9, 0xD9}, {0xC7, 0x9E, 0xB8, 0x02}, {0x8E, 0xAA, 0x41, 0x02}, {0xCF, 0xAC, 0x30, 0xD9}, {0x4D, 0xA0, 0xD2, 0x6F}, {0x0C, 0xA6, 0xA3, 0xB4}, {0x08, 0xBF, 0x67, 0xD9}, {0x49, 0xB9, 0x16, 0x02}, {0xCB, 0xB5, 0xF4, 0xB4}, {0x8A, 0xB3, 0x85, 0x6F}, {0x2C, 0x6E, 0x83, 0xDA}, {0x6D, 0x68, 0xF2, 0x01}, {0xEF, 0x64, 0x10, 0xB7}, {0xAE, 0x62, 0x61, 0x6C}, {0xAA, 0x7B, 0xA5, 0x01}, {0xEB, 0x7D, 0xD4, 0xDA}, {0x69, 0x71, 0x36, 0x6C}, {0x28, 0x77, 0x47, 0xB7}, {0x61, 0x43, 0xBE, 0xB7}, {0x20, 0x45, 0xCF, 0x6C}, {0xA2, 0x49, 0x2D, 0xDA}, {0xE3, 0x4F, 0x5C, 0x01}, {0xE7, 0x56, 0x98, 0x6C}, {0xA6, 0x50, 0xE9, 0xB7}, {0x24, 0x5C, 0x0B, 0x01}, {0x65, 0x5A, 0x7A, 0xDA}, {0xB6, 0x34, 0xF9, 0x00}, {0xF7, 0x32, 0x88, 0xDB}, {0x75, 0x3E, 0x6A, 0x6D}, {0x34, 0x38, 0x1B, 0xB6}, {0x30, 0x21, 0xDF, 0xDB}, {0x71, 0x27, 0xAE, 0x00}, {0xF3, 0x2B, 0x4C, 0xB6}, {0xB2, 0x2D, 0x3D, 0x6D}, {0xFB, 0x19, 0xC4, 0x6D}, {0xBA, 0x1F, 0xB5, 0xB6}, {0x38, 0x13, 0x57, 0x00}, {0x79, 0x15, 0x26, 0xDB}, {0x7D, 0x0C, 0xE2, 0xB6}, {0x3C, 0x0A, 0x93, 0x6D}, {0xBE, 0x06, 0x71, 0xDB}, {0xFF, 0x00, 0x00, 0x00}}; #endif /* crctable.h */
C/C++
aircrack-ng/include/aircrack-ng/crypto/crypto.h
/* * MD5, SHA-1, RC4 and AES implementations * * Copyright (C) 2001-2004 Christophe Devine * Copyright (C) 2017-2022 Joseph Benden <joe@benden.us> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef _CRYPTO_H #define _CRYPTO_H #include <limits.h> #include <errno.h> #ifdef USE_GCRYPT #include <gcrypt.h> #endif #ifndef USE_GCRYPT #include <openssl/hmac.h> #if defined(OPENSSL_WITH_SHA1) || defined(OPENSSL_WITH_SHA256) #include <openssl/sha.h> #endif #ifdef OPENSSL_WITH_ARCFOUR #include <openssl/rc4.h> #endif #ifdef OPENSSL_WITH_MD5 #include <openssl/md5.h> #endif #include <openssl/aes.h> #if HAVE_OPENSSL_CMAC_H #include <openssl/cmac.h> #endif #include <openssl/evp.h> #include <openssl/err.h> #endif #include <aircrack-ng/defs.h> #include <aircrack-ng/crypto/aes.h> #include <aircrack-ng/crypto/arcfour.h> #include <aircrack-ng/crypto/mac.h> #include <aircrack-ng/crypto/md5.h> #include <aircrack-ng/crypto/sha1.h> #include <aircrack-ng/crypto/sha256.h> #define PMK_LEN 32 #define PMK_LEN_MAX 64 #ifndef ETH_ALEN #define ETH_ALEN 6 #endif #define CRYPT_NONE 0 #define CRYPT_WEP 1 #define CRYPT_WPA 2 #define S_LLC_SNAP "\xAA\xAA\x03\x00\x00\x00" #define S_LLC_SNAP_ARP (S_LLC_SNAP "\x08\x06") #define S_LLC_SNAP_WLCCP "\xAA\xAA\x03\x00\x40\x96\x00\x00" #define S_LLC_SNAP_IP (S_LLC_SNAP "\x08\x00") #define S_LLC_SNAP_SPANTREE "\x42\x42\x03\x00\x00\x00\x00\x00" #define S_LLC_SNAP_CDP "\xAA\xAA\x03\x00\x00\x0C\x20" #define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */ #define TYPE_ARP 0 #define TYPE_IP 1 #define NULL_MAC (unsigned char *) "\x00\x00\x00\x00\x00\x00" #define BROADCAST (unsigned char *) "\xFF\xFF\xFF\xFF\xFF\xFF" #define SPANTREE (unsigned char *) "\x01\x80\xC2\x00\x00\x00" #define CDP_VTP (unsigned char *) "\x01\x00\x0C\xCC\xCC\xCC" #define IEEE80211_FC0_SUBTYPE_MASK 0xf0 #define IEEE80211_FC0_SUBTYPE_SHIFT 4 /* for TYPE_DATA (bit combination) */ #define IEEE80211_FC0_SUBTYPE_QOS 0x80 #define IEEE80211_FC0_SUBTYPE_QOS_NULL 0xc0 #define GET_SUBTYPE(fc) \ (((fc) &IEEE80211_FC0_SUBTYPE_MASK) >> IEEE80211_FC0_SUBTYPE_SHIFT) \ << IEEE80211_FC0_SUBTYPE_SHIFT #define ROL32(A, n) (((A) << (n)) | (((A) >> (32 - (n))) & ((1UL << (n)) - 1))) #define ROR32(A, n) ROL32((A), 32 - (n)) struct WPA_ST_info { struct WPA_ST_info * next; /* next supplicant */ unsigned char stmac[6]; /* supplicant MAC */ unsigned char bssid[6]; /* authenticator MAC */ unsigned char snonce[32]; /* supplicant nonce */ unsigned char anonce[32]; /* authenticator nonce */ unsigned char keymic[20]; /* eapol frame MIC */ unsigned char eapol[256]; /* eapol frame contents */ unsigned char ptk[80]; /* pairwise transcient key */ unsigned eapol_size; /* eapol frame size */ unsigned long t_crc; /* last ToDS frame CRC */ unsigned long f_crc; /* last FromDS frame CRC */ int keyver, valid_ptk; unsigned char pn[6]; /* Packet Number (WPA-CCMP) */ }; struct Michael { unsigned long key0; unsigned long key1; unsigned long left; unsigned long right; unsigned long nBytesInM; unsigned long message; unsigned char mic[8]; }; /* Used for own RC4 implementation */ struct rc4_state { int x, y, m[256]; }; struct AP_info; void calc_pmk(const uint8_t * key, const uint8_t * essid, uint8_t pmk[static PMK_LEN]); int decrypt_wep(unsigned char * data, int len, unsigned char * key, int keylen); int encrypt_wep(unsigned char * data, int len, unsigned char * key, int keylen); int check_crc_buf(const unsigned char * buf, int len); int calc_crc_buf(const unsigned char * buf, int len); void calc_mic(struct AP_info * ap, unsigned char pmk[static 32], unsigned char ptk[static 80], unsigned char mic[static 20]); int known_clear( void * clear, int * clen, int * weight, unsigned char * wh, size_t len); int add_crc32(unsigned char * data, int length); int add_crc32_plain(unsigned char * data, int length); int is_ipv6(void * wh); int is_dhcp_discover(void * wh, size_t len); int is_qos_arp_tkip(void * wh, int len); int calc_tkip_ppk(unsigned char * h80211, int caplen, unsigned char TK1[static 16], unsigned char key[static 16]); void encrypt_tkip(unsigned char * h80211, int caplen, unsigned char PTK[static 80]); int decrypt_tkip(unsigned char * h80211, int caplen, unsigned char TK1[static 16]); int encrypt_ccmp(unsigned char * h80211, int caplen, unsigned char TK1[static 16], unsigned char PN[static 6]); int decrypt_ccmp(unsigned char * h80211, int caplen, unsigned char TK1[static 16]); int calc_ptk(struct WPA_ST_info * wpa, unsigned char pmk[static 32]); int calc_tkip_mic(unsigned char * packet, int length, unsigned char ptk[static 80], unsigned char value[static 8]); int michael_test(unsigned char key[static 8], unsigned char * message, int length, unsigned char out[static 8]); int calc_tkip_mic_key(unsigned char * packet, int length, unsigned char key[static 8]); extern const unsigned long int crc_tbl[256]; extern const unsigned char crc_chop_tbl[256][4]; static inline void add_icv(unsigned char * input, int len, int offset) { REQUIRE(input != NULL); REQUIRE(len > 0 && len < (INT_MAX - 4)); REQUIRE(offset >= 0 && offset <= len); unsigned long crc = 0xFFFFFFFF; for (int n = offset; n < len; n++) crc = crc_tbl[(crc ^ input[n]) & 0xFF] ^ (crc >> 8); crc = ~crc; input[len] = (uint8_t)((crc) &0xFF); input[len + 1] = (uint8_t)((crc >> 8) & 0xFF); input[len + 2] = (uint8_t)((crc >> 16) & 0xFF); input[len + 3] = (uint8_t)((crc >> 24) & 0xFF); } static inline int eapol_handshake_step(const unsigned char * eapol, const int len) { REQUIRE(eapol != NULL); const int eapol_size = 4 + 1 + 2 + 2 + 8 + 32 + 16 + 8 + 8 + 16 + 2; if (len < eapol_size) return (0); /* not pairwise */ if ((eapol[6] & 0x08) == 0) return (0); /* 1: has no mic */ if ((eapol[5] & 1) == 0) return (1); /* 3: has ack */ if ((eapol[6] & 0x80) != 0) return (3); if (*((uint16_t *) &eapol[eapol_size - 2]) == 0) return (4); return (2); } /// Initialize the system cryptography librar(ies). API_IMPORT void ac_crypto_init(void); #endif /* crypto.h */
C/C++
aircrack-ng/include/aircrack-ng/crypto/mac.h
// clang-format off /** * \file mac.h * * \brief Message Authentication Code algorithms * * \ingroup * \cond ****************************************************************************** * * SPDX-License-Identifier: BSD-3-CLAUSE * ****************************************************************************** * \endcond */ #ifndef LIB_CRYPTO_MAC_H #define LIB_CRYPTO_MAC_H #ifdef HAVE_CONFIG_H # include <config.h> #endif #include <stddef.h> // size_t #include <stdint.h> // [u]int[8,16,32,64]_t #ifndef API_IMPORT # define API_IMPORT #endif #ifdef GCRYPT_WITH_CMAC # define Cipher_AES_CTX gcry_cipher_hd_t #endif #ifdef OPENSSL_WITH_CMAC # define MAC_OMAC_CTX CMAC_CTX #endif #if !defined(GCRYPT_WITH_CMAC) && !defined(OPENSSL_WITH_CMAC) // # warning "Missing an implementation of the CMAC algorithm." #endif #define CMAC_AES_128_MAC_LEN 16 /** * \brief One-Key CBC MAC (OMAC1) hash with AES. * * This is a mode for using block cipher (AES in this case) for authentication. * OMAC1 was standardized with the name CMAC by NIST in a Special Publication * (SP) 800-38B. * * \param[in] key_len length of the key in bytes * \param[in] key buffer holding the key data * \param[in] count number of elements in both addrs and lengths arrays * \param[in] addr array holding pointers to buffers holding data * \param[in] len array holding lengths of the buffers holding data * \param[out] mac MAC (128-bits, i.e. 16 bytes) checksum result * * \return 0 if successful */ API_IMPORT int MAC_OMAC1_AES_Vector(size_t key_len, const uint8_t key[static key_len], size_t count, const uint8_t *addr[], const size_t *len, uint8_t *mac); #endif /* LIB_CRYPTO_MAC_H */ // clang-format on
C/C++
aircrack-ng/include/aircrack-ng/crypto/md5.h
// clang-format off /** * \file md5.h * * \brief The MD5 message digest algorithm (hash function) * * \warning MD5 is considered a weak digest and its use constitutes a * security risk. We recommend considering stronger digests instead. * * \author Joseph Benden <joe@benden.us> * * \license Apache-2.0 * * \ingroup * \cond ****************************************************************************** * * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ****************************************************************************** * \endcond */ #ifndef LIB_CRYPTO_MD5_H #define LIB_CRYPTO_MD5_H #ifdef HAVE_CONFIG_H # include <config.h> #endif #ifdef GCRYPT_WITH_MD5 # define Digest_MD5_CTX gcry_md_hd_t # define DEFINE_MD5_API 1 #endif #ifdef OPENSSL_WITH_MD5 # define Digest_MD5_CTX EVP_MD_CTX # define DEFINE_MD5_API 1 #endif #if !defined(GCRYPT_WITH_MD5) && !defined(OPENSSL_WITH_MD5) # define DEFINE_MD5_API 1 # define DEFINE_MD5_CONTEXT 1 #endif #define DIGEST_MD5_MAC_LEN 16 #define DIGEST_MD5_BLK_LEN 64 #ifdef DEFINE_MD5_CONTEXT /** * \brief MD5 context structure * * \warning MD5 is considered a weak digest and its use constitutes a * security risk. We recommend considering stronger digests instead. */ typedef struct Digest_MD5_CTX { uint32_t total[2]; /*!< The number of bytes processed */ uint32_t state[4]; /*!< The intermediate digest state */ uint8_t buffer[DIGEST_MD5_BLK_LEN]; /*!< The data block being processed */ } Digest_MD5_CTX; #endif #ifdef DEFINE_MD5_API /** * \brief MD5 context allocation * * \return 0 if unsuccessful, else a pointer to an allocated * MD5 context. * * \warning MD5 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. */ API_IMPORT Digest_MD5_CTX * Digest_MD5_Create( void ); /** * \brief MD5 context deallocation * * \param[in] ctx context to be destroyed * * \warning MD5 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. */ API_IMPORT void Digest_MD5_Destroy( Digest_MD5_CTX *ctx ); /** * \brief MD5 context setup * * \param[in] ctx context to be initialized * * \return 0 if successful * * \warning MD5 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. */ API_IMPORT int Digest_MD5_Init( Digest_MD5_CTX *ctx ); /** * \brief MD5 process buffer * * \param[in] ctx MD5 context * \param[in] input buffer holding the data * \param[in] ilen length of the input data * * \return 0 if successful * * \warning MD5 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. */ API_IMPORT int Digest_MD5_Update( Digest_MD5_CTX *ctx, const uint8_t *input, size_t ilen ); /** * \brief MD5 final digest * * \param[in] ctx MD5 context * \param[out] output MD5 checksum result * * \return 0 if successful * * \warning MD5 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. */ API_IMPORT int Digest_MD5_Finish( Digest_MD5_CTX *ctx, uint8_t output[static DIGEST_MD5_MAC_LEN] ); /** * \brief MD5 process data block (internal use only) * * \param[in] ctx MD5 context * \param[in] data buffer holding one block of data * * \return 0 if successful * * \warning MD5 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. */ API_IMPORT int Digest_Internal_MD5_Process( Digest_MD5_CTX *ctx, const uint8_t data[static DIGEST_MD5_BLK_LEN] ); /** * \brief Output = MD5( input buffer ) * * \param[in] input buffer holding the data * \param[in] ilen length of the input data * \param[out] output MD5 checksum result * * \return 0 if successful * * \warning MD5 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. */ API_IMPORT int Digest_MD5( const uint8_t *input, size_t ilen, uint8_t output[static DIGEST_MD5_MAC_LEN] ); #endif /** * \brief Output = MD5( for all elements' data buffer ) * * \param[in] count number of elements in both addrs and lengths arrays * \param[in] addrs array holding pointers to buffers holding data * \param[in] lengths array holding lengths of the buffers holding data * \param[out] output MD5 checksum result * * \return 0 if successful * * \warning MD5 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. */ API_IMPORT int Digest_MD5_Vector( size_t count, const uint8_t *addrs[static count], const size_t lengths[static count], uint8_t output[static DIGEST_MD5_MAC_LEN] ); /** * \brief Output = HMAC-MD5(vector of buffer data) (See: RFC 2104) * * \param[in] key_len length of the key in bytes * \param[in] key buffer holding the key data * \param[in] count number of elements in both addrs and lengths arrays * \param[in] addr array holding pointers to buffers holding data * \param[in] len array holding lengths of the buffers holding data * \param[out] mac MD5 checksum result * * \return 0 if successful * * \warning MD5 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. */ API_IMPORT int MAC_HMAC_MD5_Vector( size_t key_len, const uint8_t key[static key_len], size_t num_elem, const uint8_t *addr[], const size_t *len, uint8_t mac[static DIGEST_MD5_MAC_LEN] ); /** * \brief Output = HMAC-MD5(buffer data) (See: RFC 2104) * * \param[in] key_len length of the key in bytes * \param[in] key buffer holding the key data * \param[in] data_len length of the buffers holding data * \param[in] data buffer holding data * \param[out] output MD5 checksum result * * \return 0 if successful * * \warning MD5 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. */ API_IMPORT int MAC_HMAC_MD5( size_t key_len, const uint8_t key[static key_len], size_t data_len, const uint8_t data[static data_len], uint8_t output[static DIGEST_MD5_MAC_LEN] ); #endif /* LIB_CRYPTO_MD5_H */ // clang-format on
C/C++
aircrack-ng/include/aircrack-ng/crypto/sha1-git.h
/* * sha1-git.h * * This code is based on the GIT SHA1 Implementation. * * Copyright (C) 2009 Linus Torvalds <torvalds@linux-foundation.org> * Copyright (C) 2009 Nicolas Pitre <nico@cam.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * */ /* * SHA1 routine optimized to do word accesses rather than byte accesses, * and to avoid unnecessary copies into the context array. * * This was initially based on the Mozilla SHA1 implementation, although * none of the original Mozilla code remains. */ typedef struct { unsigned long long size; unsigned int h0, h1, h2, h3, h4; unsigned int W[16]; } blk_SHA_CTX; void blk_SHA1_Init(blk_SHA_CTX * ctx); void blk_SHA1_Update(blk_SHA_CTX * ctx, const void * dataIn, unsigned long len); void blk_SHA1_Final(unsigned char hashout[20], blk_SHA_CTX * ctx); #define git_SHA_CTX blk_SHA_CTX #define git_SHA1_Init blk_SHA1_Init #define git_SHA1_Update blk_SHA1_Update #define git_SHA1_Final blk_SHA1_Final
C/C++
aircrack-ng/include/aircrack-ng/crypto/sha1.h
// clang-format off /** * \file sha1.h * * \brief The SHA-1 cryptographic hash functions * * The Secure Hash Algorithm 1 (SHA-1) cryptographic hash function is defined * in <em>FIPS 180-4: Secure Hash Standard (SHS)</em>. * * \warning SHA-1 is considered a weak message digest and its use constitutes * a security risk. We recommend considering stronger message * digests instead. * * \author Joseph Benden <joe@benden.us> * * \license Apache-2.0 * * \ingroup * \cond ****************************************************************************** * * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ****************************************************************************** * \endcond */ #ifndef LIB_CRYPTO_SHA1_H #define LIB_CRYPTO_SHA1_H #ifdef HAVE_CONFIG_H # include <config.h> #endif // {{{ wpapsk.c SHA-1 support #include "sha1-git.h" #define wpapsk_SHA1_CTX blk_SHA_CTX #define wpapsk_SHA1_Init blk_SHA1_Init #define wpapsk_SHA1_Update blk_SHA1_Update #define wpapsk_SHA1_Final blk_SHA1_Final #define wpapsk_SHA1_Clone(d,s) do { memmove(d, s, sizeof(blk_SHA_CTX)); } while(0) // }}} #ifdef GCRYPT_WITH_SHA1 # define Digest_SHA1_CTX gcry_md_hd_t # define DEFINE_SHA1_API 1 #endif #ifdef OPENSSL_WITH_SHA1 # define Digest_SHA1_CTX EVP_MD_CTX # define DEFINE_SHA1_API 1 #endif #if !defined(GCRYPT_WITH_SHA1) && !defined(OPENSSL_WITH_SHA1) # define DEFINE_SHA1_API 1 # define DEFINE_SHA1_CONTEXT 1 #endif #define DIGEST_SHA1_MAC_LEN 20 #define DIGEST_SHA1_BLK_LEN 64 #ifdef DEFINE_SHA1_CONTEXT /** * \brief SHA-1 context structure * * \warning SHA-1 is considered a weak message digest and its use constitutes * a security risk. We recommend considering stronger message * digests instead. */ typedef struct Digest_SHA1_CTX { uint32_t total[2]; /*!< The number of bytes processed */ uint32_t state[5]; /*!< The intermediate digest state */ uint8_t buffer[DIGEST_SHA1_BLK_LEN]; /*!< The data block being processed */ } Digest_SHA1_CTX; #endif #ifdef DEFINE_SHA1_API /** * \brief SHA-1 context allocation * * \return 0 if unsuccessful, else a pointer to an allocated * SHA-1 context. * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ Digest_SHA1_CTX * Digest_SHA1_Create( void ); /** * \brief SHA-1 context destruction * * \param[in] ctx context to be destroyed * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. */ void Digest_SHA1_Destroy( Digest_SHA1_CTX *ctx ); /** * \brief SHA-1 context bit cloning * * \param[in,out] dst destination context for copy * \param[in] src source context for copy * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. */ void Digest_SHA1_Clone( Digest_SHA1_CTX **dst, const Digest_SHA1_CTX *src ); /** * \brief SHA-1 context setup * * \param[in] ctx context to be initialized * * \return 0 if successful * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. */ int Digest_SHA1_Init( Digest_SHA1_CTX *ctx ); /** * \brief SHA-1 process buffer * * \param[in] ctx SHA-1 context * \param[in] input buffer holding the data * \param[in] iLen length of the input data * * \return 0 if successful * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. */ int Digest_SHA1_Update( Digest_SHA1_CTX *ctx, const uint8_t *input, size_t iLen ); /** * \brief SHA-1 final digest * * \param[in] ctx SHA-1 context * \param[out] output SHA-1 checksum result * * \return 0 if successful * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. */ int Digest_SHA1_Finish( Digest_SHA1_CTX *ctx, uint8_t output[static DIGEST_SHA1_MAC_LEN] ); /** * \brief SHA-1 process data block (internal use only) * * \param[in] ctx SHA-1 context * \param[in] data buffer holding one block of data * * \return 0 if successful * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. */ int Digest_Internal_SHA1_Process( Digest_SHA1_CTX *ctx, const uint8_t data[static DIGEST_SHA1_BLK_LEN] ); /** * \brief Output = SHA-1( input buffer ) * * \param[in] input buffer holding the data * \param[in] iLen length of the input data * \param[out] output SHA-1 checksum result * * \return 0 if successful * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. */ int Digest_SHA1( const uint8_t *input, size_t iLen, uint8_t output[static DIGEST_SHA1_MAC_LEN] ); #endif /** * \brief Output = SHA-1( for all elements' data buffer ) * * \param[in] count number of elements in both addrs and lengths arrays * \param[in] addrs array holding pointers to buffers holding data * \param[in] lengths array holding lengths of the buffers holding data * \param[out] output SHA-1 checksum result * * \return 0 if successful * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. */ API_IMPORT int Digest_SHA1_Vector( size_t count, const uint8_t *addrs[static count], const size_t lengths[static count], uint8_t output[static DIGEST_SHA1_MAC_LEN] ); /** * \brief Output = HMAC-SHA-1(vector of buffer data) (See: RFC 2104) * * \param[in] key_len length of the key in bytes * \param[in] key buffer holding the key data * \param[in] count number of elements in both addrs and lengths arrays * \param[in] addr array holding pointers to buffers holding data * \param[in] len array holding lengths of the buffers holding data * \param[out] mac SHA-1 checksum result * * \return 0 if successful * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. */ API_IMPORT int MAC_HMAC_SHA1_Vector( size_t key_len, const uint8_t key[static key_len], size_t num_elem, const uint8_t *addr[], const size_t *len, uint8_t mac[static DIGEST_SHA1_MAC_LEN] ); /** * \brief Output = HMAC-SHA-1(buffer data) (See: RFC 2104) * * \param[in] key_len length of the key in bytes * \param[in] key buffer holding the key data * \param[in] data_len length of the buffers holding data * \param[in] data buffer holding data * \param[out] output SHA-1 checksum result * * \return 0 if successful * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. */ API_IMPORT int MAC_HMAC_SHA1( size_t key_len, const uint8_t key[static key_len], size_t data_len, const uint8_t data[static data_len], uint8_t output[static DIGEST_SHA1_MAC_LEN] ); /** * \brief SHA1-based key derivation function (PBKDF2) for IEEE 802.11i * * This function is used to derive PSK for WPA-PSK. For this protocol, * iterations is set to 4096 and buf_len to 32. This function is described in * IEEE Std 802.11-2004, Clause H.4. The main construction is from PKCS#5 v2.0. * * \param[in] passphrase ASCII passphrase * \param[in] ssid Station Set IDentifier * \param[in] ssid_len length of the buffer holding the SSID, in bytes * \param[in] iterations The number of iterations to run * \param[out] buf buffer holding the generated key * \param[in] buf_len length of the buffer in bytes * * \return 0 if successful * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. */ API_IMPORT int KDF_PBKDF2_SHA1( const uint8_t *passphrase, const uint8_t *ssid, size_t ssid_len, size_t iterations, uint8_t *buf, size_t buflen ); /** * \brief SHA1-based Pseudo-Random Function (PRF) (IEEE 802.11i, 8.5.1.1) * * This function is used to derive new, cryptographically separate keys from a * given key (e.g., PMK in IEEE 802.11i). * * \param[in] key Key for PRF * \param[in] key_len Length of the key in bytes * \param[in] label A unique label for each purpose of the PRF * \param[in] data Extra data to bind into the key * \param[in] data_len Length of the data * \param[out] buf Buffer for the generated pseudo-random key * \param[in] buf_len Number of bytes of key to generate * * \return 0 if successful * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. */ API_EXPORT int SHA1_PRF( const uint8_t *key, size_t key_len, const uint8_t *label, const uint8_t *data, size_t data_len, uint8_t *buf, size_t buf_len ); #endif /* LIB_CRYPTO_SHA1_H */ // clang-format on
C/C++
aircrack-ng/include/aircrack-ng/crypto/sha256.h
// clang-format off /** * \file sha256.h * * \brief The SHA-256 cryptographic hash function and PRF (IEEE 802.11r) * * The Secure Hash Algorithm 2 (256-bit) cryptographic hash function is * defined in <em>FIPS 180-4: Secure Hash Standard (SHS)</em>. * * \ingroup * \cond ****************************************************************************** * * Portions Copyright (c) 2003-2016, Jouni Malinen <j@w1.fi> * SPDX-License-Identifier: BSD-3-CLAUSE * ****************************************************************************** * \endcond */ #ifndef LIB_CRYPTO_SHA256_H #define LIB_CRYPTO_SHA256_H #include <stddef.h> // size_t #include <stdint.h> // [u]int[8,16,32,64]_t #ifndef API_IMPORT # define API_IMPORT #endif #ifdef GCRYPT_WITH_SHA256 # define Digest_SHA256_CTX gcry_md_hd_t # define DEFINE_SHA256_API 1 #endif #ifdef OPENSSL_WITH_SHA256 # define Digest_SHA256_CTX EVP_MD_CTX # define DEFINE_SHA256_API 1 #endif #if !defined(GCRYPT_WITH_SHA256) && !defined(OPENSSL_WITH_SHA256) # define DEFINE_SHA256_API 1 # define DEFINE_SHA256_CONTEXT 1 // # error "Must have a working SHA-2-256 algorithm implemented." # define Digest_SHA256_CTX void #endif #define DIGEST_SHA256_MAC_LEN 32 #define DIGEST_SHA256_BLK_LEN 64 #ifdef DEFINE_SHA256_API /** * \brief SHA-2-256 context allocation * * \return 0 if unsuccessful, else a pointer to an allocated * SHA-2-256 context. */ API_IMPORT Digest_SHA256_CTX * Digest_SHA256_Create( void ); /** * \brief SHA-2-256 context deallocation * * \param[in] ctx context to be destroyed */ API_IMPORT void Digest_SHA256_Destroy( Digest_SHA256_CTX *ctx ); /** * \brief SHA-2-256 context bit cloning * * \param[in,out] dst destination context for copy * \param[in] src source context for copy */ API_IMPORT void Digest_SHA256_Clone( Digest_SHA256_CTX **dst, const Digest_SHA256_CTX *src ); /** * \brief SHA-2-256 context setup * * \param[in] ctx context to be initialized * * \return 0 if successful */ API_IMPORT int Digest_SHA256_Init( Digest_SHA256_CTX *ctx ); /** * \brief SHA-2-256 process buffer * * \param[in] ctx SHA-2-256 context * \param[in] input buffer holding the data * \param[in] ilen length of the input data * * \return 0 if successful */ API_IMPORT int Digest_SHA256_Update( Digest_SHA256_CTX *ctx, const uint8_t *input, size_t ilen ); /** * \brief SHA-2-256 final digest * * \param[in] ctx SHA-2-256 context * \param[out] output SHA-2-256 checksum result * * \return 0 if successful */ API_IMPORT int Digest_SHA256_Finish( Digest_SHA256_CTX *ctx, uint8_t output[static DIGEST_SHA256_MAC_LEN] ); /** * \brief Output = SHA-2-256( input buffer ) * * \param[in] input buffer holding the data * \param[in] ilen length of the input data * \param[out] output SHA-2-256 checksum result * * \return 0 if successful */ API_IMPORT int Digest_SHA256( const uint8_t *input, size_t ilen, uint8_t output[static DIGEST_SHA256_MAC_LEN] ); #endif /** * \brief Output = SHA-2-256( for all elements' data buffer ) * * \param[in] count number of elements in both addrs and lengths arrays * \param[in] addrs array holding pointers to buffers holding data * \param[in] lengths array holding lengths of the buffers holding data * \param[out] output SHA-2-256 checksum result * * \return 0 if successful */ API_IMPORT int Digest_SHA256_Vector( size_t count, const uint8_t *addrs[static count], const size_t lengths[static count], uint8_t output[static DIGEST_SHA256_MAC_LEN] ); /** * \brief Output = HMAC-SHA-2-256(vector of buffer data) * * \param[in] key_len length of the key in bytes * \param[in] key buffer holding the key data * \param[in] count number of elements in both addrs and lengths arrays * \param[in] addr array holding pointers to buffers holding data * \param[in] len array holding lengths of the buffers holding data * \param[out] mac SHA-2-256 checksum result * * \return 0 if successful */ API_IMPORT int MAC_HMAC_SHA256_Vector( size_t key_len, const uint8_t key[static key_len], size_t num_elem, const uint8_t *addr[], const size_t *len, uint8_t mac[static DIGEST_SHA256_MAC_LEN] ); /** * \brief Output = HMAC-SHA-2-256(buffer data) * * \param[in] key_len length of the key in bytes * \param[in] key buffer holding the key data * \param[in] data_len length of the buffers holding data * \param[in] data buffer holding data * \param[out] output SHA-2-256 checksum result * * \return 0 if successful */ API_IMPORT int MAC_HMAC_SHA256( size_t key_len, const uint8_t key[static key_len], size_t data_len, const uint8_t data[static data_len], uint8_t output[static DIGEST_SHA256_MAC_LEN] ); /** * \brief IEEE Std 802.11-2012, 11.6.1.7.2 Key Derivation Function * * This function is used to derive new, cryptographically separate keys from a * given key. If the requested buf_len is not divisible by eight, the least * significant 1-7 bits of the last octet in the output are not part of the * requested output. * * \param[in] key Key for KDF * \param[in] key_len Length of the key in bytes * \param[in] label A unique label for each purpose of the PRF * \param[in] data Extra data to bind into the key * \param[in] data_len Length of the data * \param[out] buf Buffer for the generated pseudo-random key * \param[in] buf_len Number of bits of key to generate * * \return 0 if successful; otherwise, an error occurred. */ void Digest_SHA256_PRF_Bits( const uint8_t *key, size_t key_len, const uint8_t *label, const uint8_t *data, size_t data_len, uint8_t *buf, size_t buf_len_bits ); #endif /* LIB_CRYPTO_SHA256_H */ // clang-format on
C/C++
aircrack-ng/include/aircrack-ng/osdep/byteorder.h
/* * Compatibility header * * Copyright (C) 2009-2022 Thomas d'Otreppe <tdotreppe@aircrack-ng.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef _AIRCRACK_NG_BYTEORDER_H_ #define _AIRCRACK_NG_BYTEORDER_H_ #include <string.h> #define ___my_swab16(x) \ ((u_int16_t)((((u_int16_t)(x) & (u_int16_t) 0x00ffU) << 8u) \ | (((u_int16_t)(x) & (u_int16_t) 0xff00U) >> 8u))) #define ___my_swab32(x) \ ((u_int32_t)((((u_int32_t)(x) & (u_int32_t) 0x000000ffUL) << 24u) \ | (((u_int32_t)(x) & (u_int32_t) 0x0000ff00UL) << 8u) \ | (((u_int32_t)(x) & (u_int32_t) 0x00ff0000UL) >> 8u) \ | (((u_int32_t)(x) & (u_int32_t) 0xff000000UL) >> 24u))) #define ___my_swab64(x) \ ((u_int64_t)( \ (u_int64_t)(((u_int64_t)(x) & (u_int64_t) 0x00000000000000ffULL) \ << 56u) \ | (u_int64_t)(((u_int64_t)(x) & (u_int64_t) 0x000000000000ff00ULL) \ << 40u) \ | (u_int64_t)(((u_int64_t)(x) & (u_int64_t) 0x0000000000ff0000ULL) \ << 24u) \ | (u_int64_t)(((u_int64_t)(x) & (u_int64_t) 0x00000000ff000000ULL) \ << 8u) \ | (u_int64_t)(((u_int64_t)(x) & (u_int64_t) 0x000000ff00000000ULL) \ >> 8u) \ | (u_int64_t)(((u_int64_t)(x) & (u_int64_t) 0x0000ff0000000000ULL) \ >> 24u) \ | (u_int64_t)(((u_int64_t)(x) & (u_int64_t) 0x00ff000000000000ULL) \ >> 40u) \ | (u_int64_t)(((u_int64_t)(x) & (u_int64_t) 0xff00000000000000ULL) \ >> 56u))) /* * Linux */ #if defined(linux) || defined(Linux) || defined(__linux__) || defined(__linux) \ || defined(__gnu_linux__) #include <endian.h> #include <unistd.h> #include <stdint.h> #ifndef __int8_t_defined typedef uint64_t u_int64_t; //-V677 typedef uint32_t u_int32_t; //-V677 typedef uint16_t u_int16_t; //-V677 typedef uint8_t u_int8_t; //-V677 #endif #if defined(__UCLIBC__) #include <asm/byteorder.h> #define AIRCRACK_NG_BYTE_ORDER_DEFINED #endif #endif /* * Android/termux */ #if defined(__ANDROID__) #include <asm/byteorder.h> #include <unistd.h> #define AIRCRACK_NG_BYTE_ORDER_DEFINED #endif /* * Cygwin */ #if defined(__CYGWIN32__) || defined(CYGWIN) #include <asm/byteorder.h> #include <unistd.h> #define __be64_to_cpu(x) ___my_swab64(x) #define __be32_to_cpu(x) ___my_swab32(x) #define __be16_to_cpu(x) ___my_swab16(x) #define __cpu_to_be64(x) ___my_swab64(x) #define __cpu_to_be32(x) ___my_swab32(x) #define __cpu_to_be16(x) ___my_swab16(x) #define __le64_to_cpu(x) (x) #define __le32_to_cpu(x) (x) #define __le16_to_cpu(x) (x) #define __cpu_to_le64(x) (x) #define __cpu_to_le32(x) (x) #define __cpu_to_le16(x) (x) #define AIRCRACK_NG_BYTE_ORDER_DEFINED #endif /* * Windows (DDK) */ #if defined(__WIN__) #include <io.h> #define __be64_to_cpu(x) ___my_swab64(x) #define __be32_to_cpu(x) ___my_swab32(x) #define __be16_to_cpu(x) ___my_swab16(x) #define __cpu_to_be64(x) ___my_swab64(x) #define __cpu_to_be32(x) ___my_swab32(x) #define __cpu_to_be16(x) ___my_swab16(x) #define __le64_to_cpu(x) (x) #define __le32_to_cpu(x) (x) #define __le16_to_cpu(x) (x) #define __cpu_to_le64(x) (x) #define __cpu_to_le32(x) (x) #define __cpu_to_le16(x) (x) #define AIRCRACK_NG_BYTE_ORDER_DEFINED #endif /* * MAC (Darwin) */ #if defined(__APPLE_CC__) #if defined(__x86_64__) && defined(__APPLE__) #include <libkern/OSByteOrder.h> #define __swab64(x) (unsigned long long) OSSwapInt64((uint64_t) x) #define __swab32(x) (unsigned long) OSSwapInt32((uint32_t) x) #define __swab16(x) (unsigned short) OSSwapInt16((uint16_t) x) #define __be64_to_cpu(x) (unsigned long long) OSSwapBigToHostInt64((uint64_t) x) #define __be32_to_cpu(x) (unsigned long) OSSwapBigToHostInt32((uint32_t) x) #define __be16_to_cpu(x) (unsigned short) OSSwapBigToHostInt16((uint16_t) x) #define __le64_to_cpu(x) \ (unsigned long long) OSSwapLittleToHostInt64((uint64_t) x) #define __le32_to_cpu(x) (unsigned long) OSSwapLittleToHostInt32((uint32_t) x) #define __le16_to_cpu(x) (unsigned short) OSSwapLittleToHostInt16((uint16_t) x) #define __cpu_to_be64(x) (unsigned long long) OSSwapHostToBigInt64((uint64_t) x) #define __cpu_to_be32(x) (unsigned long) OSSwapHostToBigInt32((uint32_t) x) #define __cpu_to_be16(x) (unsigned short) OSSwapHostToBigInt16((uint16_t) x) #define __cpu_to_le64(x) \ (unsigned long long) OSSwapHostToLittleInt64((uint64_t) x) #define __cpu_to_le32(x) (unsigned long) OSSwapHostToLittleInt32((uint32_t) x) #define __cpu_to_le16(x) (unsigned short) OSSwapHostToLittleInt16((uint16_t) x) #else #include <architecture/byte_order.h> #define __swab64(x) NXSwapLongLong(x) #define __swab32(x) NXSwapLong(x) #define __swab16(x) NXSwapShort(x) #define __be64_to_cpu(x) NXSwapBigLongLongToHost(x) #define __be32_to_cpu(x) NXSwapBigLongToHost(x) #define __be16_to_cpu(x) NXSwapBigShortToHost(x) #define __le64_to_cpu(x) NXSwapLittleLongLongToHost(x) #define __le32_to_cpu(x) NXSwapLittleLongToHost(x) #define __le16_to_cpu(x) NXSwapLittleShortToHost(x) #define __cpu_to_be64(x) NXSwapHostLongLongToBig(x) #define __cpu_to_be32(x) NXSwapHostLongToBig(x) #define __cpu_to_be16(x) NXSwapHostShortToBig(x) #define __cpu_to_le64(x) NXSwapHostLongLongToLittle(x) #define __cpu_to_le32(x) NXSwapHostLongToLittle(x) #define __cpu_to_le16(x) NXSwapHostShortToLittle(x) #endif #define __LITTLE_ENDIAN 1234 #define __BIG_ENDIAN 4321 #define __PDP_ENDIAN 3412 #define __BYTE_ORDER __BIG_ENDIAN #define AIRCRACK_NG_BYTE_ORDER_DEFINED #endif /* * Solaris * ------- */ #if defined(__SVR4) && defined(__sun__) #include <sys/byteorder.h> #include <sys/types.h> #include <unistd.h> typedef uint64_t u_int64_t; typedef uint32_t u_int32_t; typedef uint16_t u_int16_t; typedef uint8_t u_int8_t; #if defined(__sparc__) #define __be64_to_cpu(x) (x) #define __be32_to_cpu(x) (x) #define __be16_to_cpu(x) (x) #define __cpu_to_be64(x) (x) #define __cpu_to_be32(x) (x) #define __cpu_to_be16(x) (x) #define __le64_to_cpu(x) ___my_swab64(x) #define __le32_to_cpu(x) ___my_swab32(x) #define __le16_to_cpu(x) ___my_swab16(x) #define __cpu_to_le64(x) ___my_swab64(x) #define __cpu_to_le32(x) ___my_swab32(x) #define __cpu_to_le16(x) ___my_swab16(x) #define AIRCRACK_NG_BYTE_ORDER_DEFINED #define BIG_ENDIAN 1 #define BYTE_ORDER BIG_ENDIAN #else #define AIRCRACK_NG_BYTE_ORDER 1 #define LITTLE_ENDIAN 1 #endif #endif /* * Custom stuff */ #if defined(__MACH__) && !defined(__APPLE_CC__) && !defined(__GNU__) #include <libkern/OSByteOrder.h> #define __cpu_to_be64(x) = OSSwapHostToBigInt64(x) #define __cpu_to_be32(x) = OSSwapHostToBigInt32(x) #define AIRCRACK_NG_BYTE_ORDER_DEFINED #endif // FreeBSD #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) \ || defined(__MidnightBSD__) || defined(__NetBSD__) #undef ushort #undef uint #include <sys/types.h> #endif // XXX: Is there anything to include on OpenBSD/NetBSD/DragonFlyBSD/...? // XXX: Mac: Check // http://www.opensource.apple.com/source/CF/CF-476.18/CFByteOrder.h // http://developer.apple.com/DOCUMENTATION/CoreFoundation/Reference/CFByteOrderUtils/Reference/reference.html // Write to apple to ask what should be used. #if defined(LITTLE_ENDIAN) #define AIRCRACK_NG_LITTLE_ENDIAN LITTLE_ENDIAN #elif defined(__LITTLE_ENDIAN) #define AIRCRACK_NG_LITTLE_ENDIAN __LITTLE_ENDIAN #elif defined(_LITTLE_ENDIAN) #define AIRCRACK_NG_LITTLE_ENDIAN _LITTLE_ENDIAN #endif #if defined(BIG_ENDIAN) #define AIRCRACK_NG_BIG_ENDIAN BIG_ENDIAN #elif defined(__BIG_ENDIAN) #define AIRCRACK_NG_BIG_ENDIAN __BIG_ENDIAN #elif defined(_BIG_ENDIAN) #define AIRCRACK_NG_BIG_ENDIAN _BIG_ENDIAN #endif #if !defined(AIRCRACK_NG_LITTLE_ENDIAN) && !defined(AIRCRACK_NG_BIG_ENDIAN) #error Impossible to determine endianness (Little or Big endian), please contact the author. #endif #if defined(BYTE_ORDER) #if (BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN) #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_LITTLE_ENDIAN #elif (BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN) #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_BIG_ENDIAN #endif #elif defined(__BYTE_ORDER) #if (__BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN) #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_LITTLE_ENDIAN #elif (__BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN) #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_BIG_ENDIAN #endif #elif defined(_BYTE_ORDER) #if (_BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN) #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_LITTLE_ENDIAN #elif (_BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN) #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_BIG_ENDIAN #endif #endif #ifndef AIRCRACK_NG_BYTE_ORDER #error Impossible to determine endianness (Little or Big endian), please contact the author. #endif #if (AIRCRACK_NG_BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN) #ifndef AIRCRACK_NG_BYTE_ORDER_DEFINED #define __be64_to_cpu(x) ___my_swab64(x) #define __be32_to_cpu(x) ___my_swab32(x) #define __be16_to_cpu(x) ___my_swab16(x) #define __cpu_to_be64(x) ___my_swab64(x) #define __cpu_to_be32(x) ___my_swab32(x) #define __cpu_to_be16(x) ___my_swab16(x) #define __le64_to_cpu(x) (x) #define __le32_to_cpu(x) (x) #define __le16_to_cpu(x) (x) #define __cpu_to_le64(x) (x) #define __cpu_to_le32(x) (x) #define __cpu_to_le16(x) (x) #endif #ifndef htobe16 #define htobe16 ___my_swab16 #endif #ifndef htobe32 #define htobe32 ___my_swab32 #endif #ifndef htobe64 #define htobe64 ___my_swab64 #endif #ifndef betoh16 #define betoh16 ___my_swab16 #endif #ifndef betoh32 #define betoh32 ___my_swab32 #endif #ifndef betoh64 #define betoh64 ___my_swab64 #endif #ifndef htole16 #define htole16(x) (x) #endif #ifndef htole32 #define htole32(x) (x) #endif #ifndef htole64 #define htole64(x) (x) #endif #ifndef letoh16 #define letoh16(x) (x) #endif #ifndef letoh32 #define letoh32(x) (x) #endif #ifndef letoh64 #define letoh64(x) (x) #endif #endif #if (AIRCRACK_NG_BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN) #ifndef AIRCRACK_NG_BYTE_ORDER_DEFINED #define __be64_to_cpu(x) (x) #define __be32_to_cpu(x) (x) #define __be16_to_cpu(x) (x) #define __cpu_to_be64(x) (x) #define __cpu_to_be32(x) (x) #define __cpu_to_be16(x) (x) #define __le64_to_cpu(x) ___my_swab64(x) #define __le32_to_cpu(x) ___my_swab32(x) #define __le16_to_cpu(x) ___my_swab16(x) #define __cpu_to_le64(x) ___my_swab64(x) #define __cpu_to_le32(x) ___my_swab32(x) #define __cpu_to_le16(x) ___my_swab16(x) #endif #ifndef htobe16 #define htobe16(x) (x) #endif #ifndef htobe32 #define htobe32(x) (x) #endif #ifndef htobe64 #define htobe64(x) (x) #endif #ifndef betoh16 #define betoh16(x) (x) #endif #ifndef betoh32 #define betoh32(x) (x) #endif #ifndef betoh64 #define betoh64(x) (x) #endif #ifndef htole16 #define htole16 ___my_swab16 #endif #ifndef htole32 #define htole32 ___my_swab32 #endif #ifndef htole64 #define htole64 ___my_swab64 #endif #ifndef letoh16 #define letoh16 ___my_swab16 #endif #ifndef letoh32 #define letoh32 ___my_swab32 #endif #ifndef letoh64 #define letoh64 ___my_swab64 #endif #endif // Common defines #define cpu_to_le64 __cpu_to_le64 #define le64_to_cpu __le64_to_cpu #define cpu_to_le32 __cpu_to_le32 #ifndef le32_to_cpu #define le32_to_cpu __le32_to_cpu #endif #define cpu_to_le16 __cpu_to_le16 #ifndef le16_to_cpu #define le16_to_cpu __le16_to_cpu #endif #define cpu_to_be64 __cpu_to_be64 #define be64_to_cpu __be64_to_cpu #define cpu_to_be32 __cpu_to_be32 #define be32_to_cpu __be32_to_cpu #define cpu_to_be16 __cpu_to_be16 #define be16_to_cpu __be16_to_cpu #ifndef le16toh #define le16toh le16_to_cpu #endif #ifndef be16toh #define be16toh be16_to_cpu #endif #ifndef le32toh #define le32toh le32_to_cpu #endif #ifndef be32toh #define be32toh be32_to_cpu #endif #ifndef htons #define htons cpu_to_be16 #endif #ifndef htonl #define htonl cpu_to_be32 #endif #ifndef ntohs #define ntohs be16_to_cpu #endif #ifndef ntohl #define ntohl be32_to_cpu #endif /* Loads and stores. These avoid undefined behavior due to unaligned memory * accesses, via memcpy. */ inline static uint16_t load16(uint8_t * b) { uint16_t x; memcpy(&x, b, 2); return x; } inline static uint32_t load32(uint8_t * b) { uint32_t x; memcpy(&x, b, 4); return x; } inline static uint64_t load64(uint8_t * b) { uint64_t x; memcpy(&x, b, 8); return x; } inline static void store16(uint8_t * b, uint16_t i) { memcpy(b, &i, 2); } inline static void store32(uint8_t * b, uint32_t i) { memcpy(b, &i, 4); } inline static void store64(uint8_t * b, uint64_t i) { memcpy(b, &i, 8); } #define load16_le(b) (__le16_to_cpu(load16(b))) #define store16_le(b, i) (store16(b, __cpu_to_le16(i))) #define load16_be(b) (__be16_to_cpu(load16(b))) #define store16_be(b, i) (store16(b, __cpu_to_be16(i))) #define load32_le(b) (__le32_to_cpu(load32(b))) #define store32_le(b, i) (store32(b, __cpu_to_le32(i))) #define load32_be(b) (__be32_to_cpu(load32(b))) #define store32_be(b, i) (store32(b, __cpu_to_be32(i))) #define load64_le(b) (__le64_to_cpu(load64(b))) #define store64_le(b, i) (store64(b, __cpu_to_le64(i))) #define load64_be(b) (__be64_to_cpu(load64(b))) #define store64_be(b, i) (store64(b, __cpu_to_be64(i))) #endif
C/C++
aircrack-ng/include/aircrack-ng/osdep/channel.h
/* * OS dependent APIs for Linux * * Copyright (C) 2018-2022 Thomas d'Otreppe <tdotreppe@aircrack-ng.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifndef OSDEP_CHANNELS_H #define OSDEP_CHANNELS_H #define CHANNEL_NO_HT 0 #define CHANNEL_HT20 20 #define CHANNEL_HT40_PLUS 39 #define CHANNEL_HT40_MINUS 41 #endif // OSDEP_CHANNELS_H
C/C++
aircrack-ng/include/aircrack-ng/osdep/common.h
/* * Copyright (c) 2010-2022 Thomas d'Otreppe <tdotreppe@aircrack-ng.org> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef _OSDEP_COMMON_H_ #define _OSDEP_COMMON_H_ #if defined(_MSC_VER) // Microsoft #define EXPORT __declspec(dllexport) #define IMPORT __declspec(dllimport) #elif defined(__GNUC__) || defined(__llvm__) || defined(__clang__) \ || defined(__INTEL_COMPILER) #define EXPORT __attribute__((visibility("default"))) #define IMPORT #else // do nothing and hope for the best? #define EXPORT #define IMPORT #pragma warning Unknown dynamic link import / export semantics. #endif IMPORT int getFrequencyFromChannel(int channel); IMPORT int getChannelFromFrequency(int frequency); /* // For later use, because aircrack-ng doesn't compile with MS compilers #if defined(WIN32) || defined(__WIN__) #define ftruncate(a, b) _chsize(a,b) #endif */ #define HIGHEST_CHANNEL 220 #define LOWEST_CHANNEL -16 #endif
C/C++
aircrack-ng/include/aircrack-ng/osdep/network.h
/* * Copyright (c) 2007, 2008, Andrea Bittau <a.bittau@cs.ucl.ac.uk> * * Networking structures. * */ #ifndef __AIRCRACK_NG_OSDEP_NETWORK_H__ #define __AIRCRACK_NG_OSDEP_NETWORK_H__ #include <inttypes.h> #include <sys/types.h> #include <aircrack-ng/osdep/osdep.h> enum { NET_RC = 1, NET_GET_CHAN, NET_SET_CHAN, NET_WRITE, NET_PACKET, /* 5 */ NET_GET_MAC, NET_MAC, NET_GET_MONITOR, NET_GET_RATE, NET_SET_RATE, }; #define HIGHEST_NET_COMMAND NET_SET_RATE struct net_hdr { uint8_t nh_type; uint32_t nh_len; uint8_t nh_data[]; } __packed; IMPORT struct wif * net_open(char * iface); IMPORT int net_send(int s, int command, void * arg, int len); IMPORT int net_read_exact(int s, void * arg, int len); IMPORT int net_get(int s, void * arg, int * len); #endif /* __AIRCRACK_NG_OSEDEP_NETWORK_H__ */
C/C++
aircrack-ng/include/aircrack-ng/osdep/osdep.h
/* * Copyright (c) 2007, 2008, Andrea Bittau <a.bittau@cs.ucl.ac.uk> * All OS dependent crap should go here. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef __AIRCRACK_NG_OSEDEP_H__ #define __AIRCRACK_NG_OSEDEP_H__ #include <netinet/in.h> #include <stdint.h> #include <time.h> #include <aircrack-ng/osdep/byteorder.h> #include <aircrack-ng/osdep/common.h> #include <aircrack-ng/osdep/packed.h> #if defined(__APPLE_CC__) && defined(_XCODE) #include <pcap/bpf.h> #undef LINKTYPE_RADIOTAP_HDR #define LINKTYPE_RADIOTAP_HDR DLT_IEEE802_11_RADIO #undef LINKTYPE_IEEE802_11 #define LINKTYPE_IEEE802_11 DLT_IEEE802_11 #undef LINKTYPE_PRISM_HEADER #define LINKTYPE_PRISM_HEADER DLT_PRISM_HEADER #undef LINKTYPE_ETHERNET #define LINKTYPE_ETHERNET DLT_ERF_ETH #undef LINKTYPE_PPI_HDR #define LINKTYPE_PPI_HDR DLT_PPI #undef TCPDUMP_MAGIC #define TCPDUMP_MAGIC 0xa1b2c3d4 #endif /* For all structures, when adding new fields, always append them to the end. * This way legacy binary code does not need to be recompiled. This is * particularly useful for DLLs. -sorbo */ struct tx_info { uint32_t ti_rate; }; struct rx_info { uint64_t ri_mactime; int32_t ri_power; int32_t ri_noise; uint32_t ri_channel; uint32_t ri_freq; uint32_t ri_rate; uint32_t ri_antenna; } __packed; /* Normal code should not access this directly. Only osdep. * This structure represents a single interface. It should be created with * wi_open and destroyed with wi_close. */ #define MAX_IFACE_NAME 64 struct wif { int (*wi_read)(struct wif * wi, struct timespec * ts, int * dlt, unsigned char * h80211, int len, struct rx_info * ri); int (*wi_write)(struct wif * wi, struct timespec * ts, int dlt, unsigned char * h80211, int len, struct tx_info * ti); int (*wi_set_ht_channel)(struct wif * wi, int chan, unsigned int htval); int (*wi_set_channel)(struct wif * wi, int chan); int (*wi_get_channel)(struct wif * wi); int (*wi_set_freq)(struct wif * wi, int freq); int (*wi_get_freq)(struct wif * wi); void (*wi_close)(struct wif * wi); int (*wi_fd)(struct wif * wi); int (*wi_get_mac)(struct wif * wi, unsigned char * mac); int (*wi_set_mac)(struct wif * wi, unsigned char * mac); int (*wi_set_rate)(struct wif * wi, int rate); int (*wi_get_rate)(struct wif * wi); int (*wi_set_mtu)(struct wif * wi, int mtu); int (*wi_get_mtu)(struct wif * wi); int (*wi_get_monitor)(struct wif * wi); void * wi_priv; char wi_interface[MAX_IFACE_NAME]; }; /* Routines to be used by client code */ IMPORT struct wif * wi_open(char * iface); IMPORT int wi_read(struct wif * wi, struct timespec * ts, int * dlt, unsigned char * h80211, int len, struct rx_info * ri); IMPORT int wi_write(struct wif * wi, struct timespec * ts, int dlt, unsigned char * h80211, int len, struct tx_info * ti); IMPORT int wi_set_channel(struct wif * wi, int chan); IMPORT int wi_set_ht_channel(struct wif * wi, int chan, unsigned int htval); IMPORT int wi_get_channel(struct wif * wi); IMPORT int wi_set_freq(struct wif * wi, int freq); IMPORT int wi_get_freq(struct wif * wi); IMPORT void wi_close(struct wif * wi); IMPORT char * wi_get_ifname(struct wif * wi); IMPORT int wi_get_mac(struct wif * wi, unsigned char * mac); IMPORT int wi_set_mac(struct wif * wi, unsigned char * mac); IMPORT int wi_get_rate(struct wif * wi); IMPORT int wi_set_rate(struct wif * wi, int rate); IMPORT int wi_get_monitor(struct wif * wi); IMPORT int wi_get_mtu(struct wif * wi); IMPORT int wi_set_mtu(struct wif * wi, int mtu); /* wi_open_osdep should determine the type of card and setup the wif structure * appropriately. There is one per OS. Called by wi_open. */ extern struct wif * wi_open_osdep(char * iface); /* This will return the FD used for reading. This is required for using select * on it. */ IMPORT int wi_fd(struct wif * wi); /* Helper routines for osdep code. */ extern struct wif * wi_alloc(int sz); extern void * wi_priv(struct wif * wi); /* Client code can use this to determine the battery state. One per OS. */ IMPORT int get_battery_state(void); /* Client code can create a tap interface */ /* XXX we can unify the tap & wi stuff in the future, but for now, lets keep * them separate until we learn something. */ struct tif { int (*ti_read)(struct tif * ti, void * buf, int len); int (*ti_write)(struct tif * ti, void * buf, int len); int (*ti_fd)(struct tif * ti); char * (*ti_name)(struct tif * ti); int (*ti_set_mtu)(struct tif * ti, int mtu); int (*ti_get_mtu)(struct tif * ti); int (*ti_set_ip)(struct tif * ti, struct in_addr * ip); int (*ti_set_mac)(struct tif * ti, unsigned char * mac); void (*ti_close)(struct tif * ti); void * ti_priv; }; /* one per OS */ IMPORT struct tif * ti_open(char * iface); /* osdep routines */ extern struct tif * ti_alloc(int sz); extern void * ti_priv(struct tif * ti); /* client routines */ IMPORT char * ti_name(struct tif * ti); IMPORT int ti_set_mtu(struct tif * ti, int mtu); IMPORT int ti_get_mtu(struct tif * ti); IMPORT void ti_close(struct tif * ti); IMPORT int ti_fd(struct tif * ti); IMPORT int ti_read(struct tif * ti, void * buf, int len); IMPORT int ti_write(struct tif * ti, void * buf, int len); IMPORT int ti_set_mac(struct tif * ti, unsigned char * mac); IMPORT int ti_set_ip(struct tif * ti, struct in_addr * ip); #endif /* __AIRCRACK_NG_OSEDEP_H__ */
C/C++
aircrack-ng/include/aircrack-ng/osdep/packed.h
/* * Pack structures * * Copyright (c) 2007, 2008, Andrea Bittau <a.bittau@cs.ucl.ac.uk> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef __AIRCRACK_NG_OSDEP_PACKED_H__ #define __AIRCRACK_NG_OSDEP_PACKED_H__ #ifndef __packed #define __packed __attribute__((__packed__)) #endif /* __packed */ #ifndef __aligned #define __aligned(n) #endif #endif /* __AIRCRACK_NG_OSEDEP_PACKED_H__ */
C/C++
aircrack-ng/include/aircrack-ng/pcre/compat-pcre.h
/* * Copyright (C) 2023 Andras Gemes <andrasgemes@outlook.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef AIRCRACK_NG_COMPAT_PCRE_H #define AIRCRACK_NG_COMPAT_PCRE_H #ifdef HAVE_PCRE2 #define PCRE2_CODE_UNIT_WIDTH 8 #include <pcre2.h> #elif defined HAVE_PCRE #include <pcre.h> #endif #ifdef HAVE_PCRE2 #define COMPAT_PCRE_COMPILE(pattern, pcreerror, pcreerroffset) \ pcre2_compile((PCRE2_SPTR) (pattern), \ PCRE2_ZERO_TERMINATED, \ 0, \ (pcreerror), \ (pcreerroffset), \ NULL) #elif defined HAVE_PCRE #define COMPAT_PCRE_COMPILE(pattern, pcreerror, pcreerroffset) \ pcre_compile((pattern), 0, (pcreerror), (pcreerroffset), NULL) #endif #ifdef HAVE_PCRE2 #define COMPAT_PCRE_MATCH(regex, essid, length, match_data) \ pcre2_match((regex), \ (PCRE2_SPTR) (essid), \ (int) strnlen((char *) (essid), (length)), \ 0, \ 0, \ (match_data), \ 0) #elif defined HAVE_PCRE #define COMPAT_PCRE_MATCH(regex, essid, length, match_data) \ pcre_exec((regex), \ NULL, \ (char *) (essid), \ strnlen((char *) (essid), (length)), \ 0, \ 0, \ NULL, \ 0) #endif #ifdef HAVE_PCRE2 #define COMPAT_PCRE_PRINT_ERROR(pcreerroffset, pcreerr) \ printf("Error: regular expression compilation failed at " \ "offset %zu: %s; aborting\n", \ (pcreerroffset), \ (pcreerr)) #elif defined HAVE_PCRE #define COMPAT_PCRE_PRINT_ERROR(pcreerroffset, pcreerrorbuf) \ printf("Error: regular expression compilation failed at " \ "offset %d: %s; aborting\n", \ (pcreerroffset), \ (pcreerrorbuf)) #endif #endif //AIRCRACK_NG_COMPAT_PCRE_H
C/C++
aircrack-ng/include/aircrack-ng/ptw/aircrack-ptw-lib.h
/* * Copyright (c) 2007-2009 Erik Tews, Andrei Pychkine and Ralf-Philipp * Weinmann. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef _AIRCRACK_PTW_H_ #define _AIRCRACK_PTW_H_ #include <stdint.h> // Number of bytes we use for our table of seen IVs, this is (2^24)/8 #define PTW_IVTABLELEN 2097152 // How many sessions do we use to check if a guessed key is correct // 10 seems to be a reasonable choice // Its now the number of sessions for selecting 10 at a random position #define PTW_CONTROLSESSIONS 10000 // The maximum possible length of the main key, 13 is the maximum for a 104 bit // key #define PTW_KEYHSBYTES 29 // How long the IV is, 3 is the default value for WEP #define PTW_IVBYTES 3 // How many bytes of a keystream we collect, 16 are needed for a 104 bit key #define PTW_KSBYTES 32 // The MAGIC VALUE!! #define PTW_n 256 // distinguish klein and ptw #define NO_KLEIN 0x01 #define NO_PTW 0x02 // We use this to keep track of the outputs of A_i typedef struct { // How often the value b appeared as an output of A_i int votes; uint8_t b; } PTW_tableentry; // A recovered session typedef struct { // The IV used in this session uint8_t iv[PTW_IVBYTES]; // The keystream used in this session uint8_t keystream[PTW_KSBYTES]; // Weight for this session int weight; } PTW_session; typedef int (*rc4test_func)(uint8_t * key, int keylen, uint8_t * iv, uint8_t * keystream); // The state of an attack // You should usually never modify these values manually typedef struct { // How many unique packets or IVs have been collected int packets_collected; // Table to check for duplicate IVs uint8_t seen_iv[PTW_IVTABLELEN]; // How many sessions for checking a guessed key have been collected int sessions_collected; // The actual recovered sessions PTW_session sessions[PTW_CONTROLSESSIONS]; // The table with votes for the keybytesums PTW_tableentry table[PTW_KEYHSBYTES][PTW_n]; // Sessions for the original klein attack PTW_session * allsessions; int allsessions_size; // rc4test function, optimized if available rc4test_func rc4test; } PTW_attackstate; PTW_attackstate * PTW_newattackstate(void); void PTW_freeattackstate(PTW_attackstate *); int PTW_addsession(PTW_attackstate *, uint8_t *, uint8_t *, int *, int); int PTW_computeKey( PTW_attackstate *, uint8_t *, int, int, int *, int[][PTW_n], int attacks); #endif
C/C++
aircrack-ng/include/aircrack-ng/support/common.h
/* * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef _COMMON_H_ #define _COMMON_H_ #include <ctype.h> #include <stdbool.h> #include <stdint.h> #include <stdlib.h> #include <time.h> #include <sys/time.h> #include <aircrack-ng/defs.h> #if defined(__CYGWIN32__) && !defined(__CYGWIN64__) int fseeko64(FILE * fp, int64_t offset, int whence); int64_t ftello64(FILE * fp); //-V:fseek:1059 //-V:ftello:1059 #undef fseek #define fseek fseeko64 #undef ftello #define ftello ftello64 #endif #if defined(__FreeBSD__) || defined(__OpenBSD__) //-V:rand:1059 //-V:srand:1059 #undef rand #define rand lrand48 #undef srand #define srand srand48 #endif #define SWAP(x, y) \ { \ unsigned char tmp = x; \ x = y; \ y = tmp; \ } #define SWAP32(x) \ x = ((((x) >> 24u) & 0x000000FFu) | (((x) >> 8u) & 0x0000FF00u) \ | (((x) << 8u) & 0x00FF0000u) \ | (((x) << 24u) & 0xFF000000u)) #define PCT \ { \ struct tm * lt; \ time_t tc = time(NULL); \ lt = localtime(&tc); \ REQUIRE(lt != NULL); \ printf("%02d:%02d:%02d ", lt->tm_hour, lt->tm_min, lt->tm_sec); \ } #ifndef MAX #define MAX(x, y) ((x) > (y) ? (x) : (y)) #endif #ifndef MIN #define MIN(x, y) ((x) > (y) ? (y) : (x)) #endif #ifndef ABS #define ABS(a) ((a) >= 0 ? (a) : (-(a))) #endif #ifdef __cplusplus extern "C" { #endif typedef struct MAC_list * pMAC_t; struct MAC_list { unsigned char mac[6]; pMAC_t next; }; static const unsigned char ZERO[33] = "\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00"; void calctime(time_t t, float calc); /// Retrieves the working directory. char * get_current_working_directory(void); int is_string_number(const char * str); int get_ram_size(void); char * getVersion(const char * progname, const unsigned int maj, const unsigned int min, const unsigned int submin, const char * rev, const unsigned int beta, const unsigned int rc); /// Returns the number of CPU/cores available and online. int get_nb_cpus(void); int maccmp(unsigned char * mac1, unsigned char * mac2); static inline void mac2str(char * str, uint8_t * m, size_t macsize) { REQUIRE(str != NULL); REQUIRE(m != NULL); snprintf(str, macsize, "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", m[0], m[1], m[2], m[3], m[4], m[5]); } #define MAC_ADDRESS_STRING_LEN 18 /// Converts a mac address in a human-readable format. static inline char * mac2string(unsigned char * mac_address) { REQUIRE(mac_address != NULL); char * mac_string = (char *) malloc(MAC_ADDRESS_STRING_LEN); ALLEGE(mac_string != NULL); mac2str(mac_string, mac_address, MAC_ADDRESS_STRING_LEN); return (mac_string); } static inline int str2mac(uint8_t * mac, const char * str) { REQUIRE(mac != NULL); REQUIRE(str != NULL); unsigned int macf[6] = {0}; if (sscanf(str, "%x:%x:%x:%x:%x:%x", &macf[0], &macf[1], &macf[2], &macf[3], &macf[4], &macf[5]) != 6) return (-1); for (int i = 0; i < 6; i++) *mac++ = (uint8_t) macf[i]; return (0); } int hexCharToInt(unsigned char c); int hexStringToArray(char * in, int in_length, unsigned char * out, int out_length); /// Return the mac address bytes (or null if it's not a mac address) int getmac(const char * macAddress, const int strict, unsigned char * mac); int addMAC(pMAC_t pMAC, unsigned char * mac); int getMACcount(pMAC_t pMAC); int flushMACs(pMAC_t pMAC); /// Read a line of characters inputted by the user int readLine(char line[], int maxlength); int hexToInt(char s[], int len); int string_has_suffix(const char * str, const char * suf); // Returns 1 if the current process is running in the background, 0 otherwise int is_background(void); static inline int time_diff(struct timeval * past, struct timeval * now) { REQUIRE(past != NULL); REQUIRE(now != NULL); time_t p = 0, n = 0; if (now->tv_sec > past->tv_sec) n = (now->tv_sec - past->tv_sec) * 1000 * 1000; else p = (past->tv_sec - now->tv_sec) * 1000 * 1000; n += now->tv_usec; p += past->tv_usec; return (int) (n - p); } static inline int elapsed_time_diff(struct timeval * past, struct timeval * now) { REQUIRE(past != NULL); REQUIRE(now != NULL); time_t el = now->tv_sec - past->tv_sec; if (el == 0) { el = now->tv_usec - past->tv_usec; } else { el = (el - 1) * 1000 * 1000; el += 1000 * 1000 - past->tv_usec; el += now->tv_usec; } if (el < 0) return (666 * 1000 * 1000); return (int) (el); } #define msec_diff(past, now) (time_diff((past), (now)) / 1000) /// Return \a str with all leading whitespace removed. static inline void ltrim(char * str) { REQUIRE(str != NULL); size_t i; size_t begin = 0u; size_t end = strlen(str) - 1u; while (isspace((int) str[begin])) begin++; // Shift all characters back to the start of the string array. for (i = begin; i <= end; i++) str[i - begin] = str[i]; // Ensure the string is null terminated. str[i - begin] = '\0'; } /// Return \a str with all trailing whitespace removed. static inline void rtrim(char * str) { REQUIRE(str != NULL); size_t end = strlen(str) - 1u; while ((end != 0) && isspace((int) str[end])) end--; // Ensure the string is null terminated. str[end + 1] = '\0'; } /// Return \a str with all leading and trailing whitespace removed. static inline void trim(char * str) { REQUIRE(str != NULL); ltrim(str); rtrim(str); } /* See if a string contains a character in the first "n" bytes. * * Returns a pointer to the first occurrence of the character, or NULL * if the character is not present in the string. * * Breaks the str* naming convention to avoid a name collision if we're * compiling on a system that has strnchr() */ static inline char * strchr_n(char * str, int c, size_t n) { size_t count = 0; if (str == NULL || n == 0) { return (NULL); } while (*str != c && *str != '\0' && count < n) { str++; count++; } return (*str == c) ? (str) : (NULL); } /* Remove a newline-terminated block of data from a buffer, replacing * the newline with a '\0'. * * Returns the number of characters left in the buffer, or -1 if the * buffer did not contain a newline. */ static inline ssize_t get_line_from_buffer(char * buffer, size_t size, char * line) { char * cursor = strchr_n(buffer, 0x0A, size); if (NULL != cursor) { *cursor = '\0'; cursor++; strlcpy(line, buffer, size); memmove(buffer, cursor, size - (strlen(line) + 1)); return (size - (strlen(line) + 1)); } return (-1); } int station_compare(const void * a, const void * b); /// Initialize standard C random number generator. static inline void rand_init(void) { srand(time(NULL)); // NOLINT(cert-msc32-c,cert-msc51-cpp) } /// Initialize standard C random number generator with specific seed. static inline void rand_init_with(int seed) { srand(seed); // NOLINT(cert-msc32-c,cert-msc51-cpp) } /// Acquire a random unsigned char, from the standard C random number generator. static inline uint8_t rand_u8(void) { // coverity[dont_call] return (uint8_t)( rand() & 0xFFU); // NOLINT(cert-msc30-c,cert-msc50-cpp,hicpp-signed-bitwise) } /// Acquire a random unsigned short, from the standard C random number generator. static inline uint16_t rand_u16(void) { // coverity[dont_call] return (uint16_t)( rand() & 0xFFFFU); // NOLINT(cert-msc30-c,cert-msc50-cpp,hicpp-signed-bitwise) } /// Acquire a random unsigned long, from the standard C random number generator. static inline uint32_t rand_u32(void) { // coverity[dont_call] return (uint32_t)( rand() & 0xFFFFFFFFUL); // NOLINT(cert-msc30-c,cert-msc50-cpp,hicpp-signed-bitwise) } /// Acquire a random float, from the standard C random number generator. static inline float rand_f32(void) { // coverity[dont_call] return ((float) rand() / (float) RAND_MAX); } /// Saturated add for unsigned, 32-bit integers. static inline uint32_t adds_u32(uint32_t a, uint32_t b) { uint32_t c = a + b; if (unlikely(c < a)) /* can only happen due to overflow */ c = -1; return (c); } /// Saturated add for unsigned, machine word integers. static inline uintptr_t adds_uptr(uintptr_t a, uintptr_t b) { uintptr_t c = a + b; if (unlikely(c < a)) /* can only happen due to overflow */ c = -1; return (c); } /// Saturated subtraction for unsigned, 64-bit integers. static inline uint64_t subs_u64(uint64_t x, uint64_t y) { uint64_t res = x - y; res &= -(res <= x); //-V732 return (res); } #ifdef __cplusplus }; #endif #endif
C/C++
aircrack-ng/include/aircrack-ng/support/communications.h
/* * Copyright (C) 2006-2022 Thomas d'Otreppe <tdotreppe@aircrack-ng.org> * Copyright (C) 2006-2009 Martin Beck <martin.beck2@gmx.de> * Copyright (C) 2018-2022 Joseph Benden <joe@benden.us> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef AIRCRACK_NG_COMMUNICATIONS_H #define AIRCRACK_NG_COMMUNICATIONS_H #include <errno.h> #include <limits.h> #include <stdint.h> #include <stdbool.h> #include <sys/time.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <unistd.h> #include <aircrack-ng/defs.h> #include <aircrack-ng/support/pcap_local.h> #include <aircrack-ng/osdep/osdep.h> #include <aircrack-ng/support/common.h> #include <aircrack-ng/third-party/ieee80211.h> /* Tagged parameters in beacon-frames */ #define MGNT_PAR_SSID 0x00 #define MGNT_PAR_CHANNEL 0x03 #define MGNT_PAR_HT_INFO 0x3d #define RATE_1M 1000000 #define RATE_2M 2000000 #define RATE_5_5M 5500000 #define RATE_11M 11000000 #define RATE_6M 6000000 #define RATE_9M 9000000 #define RATE_12M 12000000 #define RATE_18M 18000000 #define RATE_24M 24000000 #define RATE_36M 36000000 #define RATE_48M 48000000 #define RATE_54M 54000000 static const int bitrates[] = {RATE_1M, RATE_2M, RATE_5_5M, RATE_6M, RATE_9M, RATE_11M, RATE_12M, RATE_18M, RATE_24M, RATE_36M, RATE_48M, RATE_54M}; struct communication_options { uint8_t f_bssid[6]; uint8_t f_dmac[6]; uint8_t f_smac[6]; uint8_t f_netmask[6]; int f_minlen; int f_maxlen; int f_type; int f_subtype; int f_tods; int f_fromds; int f_iswep; uint8_t deauth_rc; int r_nbpps; unsigned int r_fctrl; uint8_t r_bssid[6]; uint8_t r_dmac[6]; uint8_t r_smac[6]; uint8_t r_trans[6]; uint8_t r_dip[4]; uint8_t r_sip[4]; char r_essid[33]; int r_fromdsinj; char r_smac_set; char ip_out[16]; // 16 for 15 chars + \x00 char ip_in[16]; int port_out; int port_in; char * iface_out; char * s_face; char * s_file; uint8_t * prga; size_t prgalen; int a_mode; int a_count; int a_delay; int f_retry; int ringbuffer; int ghost; int delay; int npackets; int fast; int bittest; int nodetect; int ignore_negative_one; int rtc; int reassoc; int crypt; uint8_t wepkey[64]; size_t weplen; int f_index; /* outfiles index */ FILE * f_txt; /* output csv file */ FILE * f_kis; /* output kismet csv file */ FILE * f_kis_xml; /* output kismet netxml file */ FILE * f_gps; /* output gps file */ FILE * f_cap; /* output cap file */ FILE * f_ivs; /* output ivs file */ FILE * f_xor; /* output prga file */ FILE * f_logcsv; /* output rolling AP/GPS csv log */ char * f_cap_name; char * prefix; int output_format_pcap; int output_format_csv; int output_format_kismet_csv; int output_format_kismet_netxml; int output_format_log_csv; int usegpsd; /* do we use GPSd? */ int record_data; /* do we record data? */ unsigned char sharedkey[3][4096]; /* array for 3 packets with a size of \ up to 4096Byte */ time_t sk_start; size_t sk_len; size_t sk_len2; int quiet; int verbose; }; struct devices { int fd_in, arptype_in; int fd_out, arptype_out; int fd_rtc; struct tif * dv_ti; struct tif * dv_ti2; uint8_t mac_in[6]; uint8_t mac_out[6]; int is_wlanng; int is_hostap; int is_madwifi; int is_madwifing; int is_bcm43xx; FILE * f_cap_in; struct pcap_file_header pfh_in; }; /* Expects host-endian arguments, but returns little-endian seq. */ static inline uint16_t fnseq(uint16_t fn, uint16_t seq) { uint16_t r = 0; if (fn > 15) { fprintf(stderr, "too many fragments (%d)\n", fn); exit(EXIT_FAILURE); } r = fn; r |= ((seq % 4096) << IEEE80211_SEQ_SEQ_SHIFT); return (htole16(r)); } static inline int get_ip_port(char * iface, char * ip, const int ip_size) { REQUIRE(iface != NULL); REQUIRE(ip != NULL); REQUIRE(ip_size > 0); char * host; char * ptr; int port = -1; struct in_addr addr; host = strdup(iface); if (!host) return (-1); ptr = strchr(host, ':'); if (!ptr) goto out; *ptr++ = 0; if (!inet_aton(host, (struct in_addr *) &addr)) goto out; /* XXX resolve hostname */ if (strlen(host) > 15) goto out; strncpy(ip, host, (size_t) ip_size); port = (int) strtol(ptr, NULL, 10); if (port <= 0 || port > 65535) port = -1; out: free(host); return (port); } int read_packet(struct wif * wi, void * buf, uint32_t count, struct rx_info * ri); int wait_for_beacon(struct wif * wi, uint8_t * bssid, uint8_t * capa, char * essid); int attack_check(uint8_t * bssid, char * essid, uint8_t * capa, struct wif * wi, int ignore_negative_one); typedef void (*read_sleep_cb)(void); static inline void read_sleep(int fd_in, unsigned long usec, read_sleep_cb cb) { struct timeval tv, tv2, tv3; fd_set rfds; gettimeofday(&tv, NULL); gettimeofday(&tv2, NULL); tv3.tv_sec = 0; tv3.tv_usec = 10000; while (((tv2.tv_sec * 1000000UL - tv.tv_sec * 1000000UL) + (tv2.tv_usec - tv.tv_usec)) < (usec)) { FD_ZERO(&rfds); FD_SET(fd_in, &rfds); if (select(fd_in + 1, &rfds, NULL, NULL, &tv3) < 0) { continue; } if (FD_ISSET(fd_in, &rfds)) cb(); gettimeofday(&tv2, NULL); } } extern unsigned long nb_pkt_sent; enum Send_Packet_Option { kNoChange = 1 << 0, kRewriteSequenceNumber = 1 << 1, kRewriteDuration = 1 << 2, }; static inline int send_packet(struct wif * wi, void * buf, size_t count, enum Send_Packet_Option option) { REQUIRE(buf != NULL); REQUIRE(count > 0 && count < INT_MAX); REQUIRE(option >= kNoChange && option <= kRewriteDuration); //-V1016 uint8_t * pkt = (uint8_t *) buf; if ((option & kRewriteSequenceNumber) != 0 && (count > 24) && (pkt[1] & 0x04) == 0 && (pkt[22] & 0x0F) == 0) { pkt[22] = (uint8_t)((nb_pkt_sent & 0x0000000F) << 4); pkt[23] = (uint8_t)((nb_pkt_sent & 0x00000FF0) >> 4); } if ((option & kRewriteDuration) != 0 && count > 24) { // Set the duration... pkt[2] = 0x3A; pkt[3] = 0x01; // Reset Retry Flag pkt[1] = (uint8_t)(pkt[1] & ~0x4); } int rc; do { rc = wi_write(wi, NULL, LINKTYPE_IEEE802_11, buf, (int) count, NULL); if (rc == -1 && errno == ENOBUFS) { usleep(10000); } } while (rc == -1 && (errno == EAGAIN || errno == ENOBUFS)); if (rc == -1) { perror("wi_write()"); return (-1); } ++nb_pkt_sent; return (0); } int getnet(struct wif * wi, uint8_t * capa, int filter, int force, uint8_t * f_bssid, uint8_t * r_bssid, uint8_t * r_essid, int ignore_negative_one, int nodetect); int capture_ask_packet(int * caplen, int just_grab); int filter_packet(unsigned char * h80211, int caplen); int dump_initialize(char * prefix); int dump_initialize_multi_format(char * prefix, int ivs_only); int check_shared_key(const uint8_t * h80211, size_t caplen); int encrypt_data(uint8_t * data, size_t length); int create_wep_packet(uint8_t * packet, size_t * length, size_t hdrlen); int set_clear_arp(uint8_t * buf, uint8_t * smac, uint8_t * dmac); int set_final_arp(uint8_t * buf, uint8_t * mymac); int set_clear_ip(uint8_t * buf, size_t ip_len); int set_final_ip(uint8_t * buf, uint8_t * mymac); int msleep(int msec); int read_prga(unsigned char ** dest, char * file); int set_bitrate(struct wif * wi, int rate); #endif //AIRCRACK_NG_COMMUNICATIONS_H
C/C++
aircrack-ng/include/aircrack-ng/support/crypto_engine_loader.h
/* * Copyright (C) 2018-2022 Joseph Benden <joe@benden.us> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef AIRCRACK_NG_CRYPTO_ENGINE_LOADER_H #define AIRCRACK_NG_CRYPTO_ENGINE_LOADER_H #if defined(_MSC_VER) // Microsoft #define EXPORT __declspec(dllexport) #define IMPORT __declspec(dllimport) #elif defined(__GNUC__) || defined(__llvm__) || defined(__clang__) \ || defined(__INTEL_COMPILER) #define EXPORT __attribute__((visibility("default"))) #define IMPORT #else // do nothing and hope for the best? #define EXPORT #define IMPORT #pragma warning Unknown dynamic link import / export semantics. #endif #define STATIC_ASSERT(COND, MSG) \ typedef char static_assertion_##MSG[(!!(COND)) * 2 - 1] // token pasting madness: #define COMPILE_TIME_ASSERT3(X, L) \ STATIC_ASSERT(X, static_assertion_at_line_##L) #define COMPILE_TIME_ASSERT2(X, L) COMPILE_TIME_ASSERT3(X, L) #define COMPILE_TIME_ASSERT(X) COMPILE_TIME_ASSERT2(X, __LINE__) #if defined(__GNUC__) || defined(__llvm__) || defined(__clang__) \ || defined(__INTEL_COMPILER) #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #else #define likely(x) (x) #define unlikely(x) (x) #endif #include <stdint.h> #include <stddef.h> #include <aircrack-ng/ce-wpa/crypto_engine.h> #ifdef __cplusplus extern "C" { #endif /** * Returns an integer bit representation of the available SIMD * Aircrack-ng Crypto Engine modules for the runtime machine. * * @return Integer bit representation of SIMD flags. */ IMPORT int ac_crypto_engine_loader_get_available(void); /** * Returns an absolute path to the best Aircrack-ng Crypto * library to load. The caller \b MUST deallocate the * returned memory using \a free! * * @param simd_features Integer bit representation of SIMD flags. * @return character sequence that must be deallocated by caller. */ IMPORT char * ac_crypto_engine_loader_best_library_for(int simd_features); /// Produces an integer bit representation of a SIMD character sequence. IMPORT int ac_crypto_engine_loader_string_to_flag(const char * const str); /** * Produces a character representation of the SIMD integer flags. * * All selected bits of \a flags are converted; producing a space * separated string representation. * * Caller \b MUST deallocate the returned value using \a free * * @param flags Integer bit representation of SIMD flags. * @return character sequence that must be deallocated by caller. */ IMPORT char * ac_crypto_engine_loader_flags_to_string(int flags); /// Loads the specified Aircrack-ng Crypto Engine specified by \a flags. /// Does nothing in a static build. IMPORT int ac_crypto_engine_loader_load(int flags); /// Unloads the Aircrack-ng Crypto Engine. Does nothing in a static build. IMPORT void ac_crypto_engine_loader_unload(void); // Symbols defined by the loader. extern int (*dso_ac_crypto_engine_init)(ac_crypto_engine_t * engine); extern void (*dso_ac_crypto_engine_destroy)(ac_crypto_engine_t * engine); extern void (*dso_ac_crypto_engine_set_essid)(ac_crypto_engine_t * engine, const uint8_t * essid); extern int (*dso_ac_crypto_engine_thread_init)(ac_crypto_engine_t * engine, int threadid); extern void (*dso_ac_crypto_engine_thread_destroy)(ac_crypto_engine_t * engine, int threadid); extern int (*dso_ac_crypto_engine_simd_width)(void); extern int (*dso_ac_crypto_engine_wpa_crack)( ac_crypto_engine_t * engine, const wpapsk_password key[MAX_KEYS_PER_CRYPT_SUPPORTED], const uint8_t eapol[256], uint32_t eapol_size, uint8_t mic[MAX_KEYS_PER_CRYPT_SUPPORTED][20], uint8_t keyver, const uint8_t cmpmic[20], int nparallel, int threadid); extern int (*dso_ac_crypto_engine_wpa_pmkid_crack)( ac_crypto_engine_t * engine, const wpapsk_password key[MAX_KEYS_PER_CRYPT_SUPPORTED], const uint8_t pmkid[32], int nparallel, int threadid); extern void (*dso_ac_crypto_engine_set_pmkid_salt)(ac_crypto_engine_t * engine, const uint8_t bssid[6], const uint8_t stmac[6], int threadid); extern void (*dso_ac_crypto_engine_calc_pke)(ac_crypto_engine_t * engine, const uint8_t bssid[6], const uint8_t stmac[6], const uint8_t anonce[32], const uint8_t snonce[32], int threadid); extern int (*dso_ac_crypto_engine_supported_features)(void); extern uint8_t * (*dso_ac_crypto_engine_get_pmk)(ac_crypto_engine_t * engine, int threadid, int index); extern uint8_t * (*dso_ac_crypto_engine_get_ptk)(ac_crypto_engine_t * engine, int threadid, int index); extern void (*dso_ac_crypto_engine_calc_one_pmk)(const uint8_t * key, const uint8_t * essid, uint32_t essid_length, uint8_t pmk[40]); extern void (*dso_ac_crypto_engine_calc_pmk)( ac_crypto_engine_t * engine, const wpapsk_password key[MAX_KEYS_PER_CRYPT_SUPPORTED], int nparallel, int threadid); extern void (*dso_ac_crypto_engine_calc_mic)( ac_crypto_engine_t * engine, const uint8_t eapol[256], const uint32_t eapol_size, uint8_t mic[MAX_KEYS_PER_CRYPT_SUPPORTED][20], const uint8_t keyver, const int vectorIdx, const int threadid); // End symbols defined by the loader. #ifdef __cplusplus } #endif #endif // AIRCRACK_NG_CRYPTO_ENGINE_LOADER_H
C/C++
aircrack-ng/include/aircrack-ng/support/fragments.h
/* * Copyright (C) 2006-2022 Thomas d'Otreppe <tdotreppe@aircrack-ng.org> * Copyright (C) 2006-2009 Martin Beck <martin.beck2@gmx.de> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef AIRCRACK_NG_FRAGMENTS_H #define AIRCRACK_NG_FRAGMENTS_H #include <aircrack-ng/crypto/crypto.h> // if not all fragments are available 60 seconds after the last fragment was // received, they will be removed #define FRAG_TIMEOUT (1000000 * 60) typedef struct Fragment_list * pFrag_t; struct Fragment_list { unsigned char source[6]; unsigned short sequence; unsigned char * fragment[16]; short fragmentlen[16]; char fragnum; unsigned char * header; short headerlen; struct timeval access; char wep; pFrag_t next; }; int addFrag(unsigned char * packet, unsigned char * smac, int len, int crypt, unsigned char * wepkey, int weplen); int timeoutFrag(void); int delFrag(unsigned char * smac, int sequence); unsigned char * getCompleteFrag(unsigned char * smac, int sequence, size_t * packetlen, int crypt, unsigned char * wepkey, int weplen); #endif //AIRCRACK_NG_FRAGMENTS_H
C/C++
aircrack-ng/include/aircrack-ng/support/mcs_index_rates.h
/* * Functions and macros to obtain 802.11n or ac rates based on MCS index * * Copyright (C) 2018-2022 Thomas d'Otreppe <tdotreppe@aircrack-ng.org> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef MCS_INDEX_RATES_H #define MCS_INDEX_RATES_H // http://mcsindex.com/ // 20/40/80/160MHz -> (0, 1, 2, 3) // 0: long GI, 1: short GI // amount of spatial streams (minus 1) // MCS index extern const float MCS_index_rates[4][2][8][10]; float get_80211n_rate(const int width, const int is_short_GI, const int mcs_index); float get_80211ac_rate(const int width, const int is_short_GI, const int mcs_idx, const int amount_ss); #endif // MCS_INDEX_RATES_H
C/C++
aircrack-ng/include/aircrack-ng/support/pcap_local.h
/* * * Copyright (C) 2001-2004 Christophe Devine * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef _AIRCRACK_NG_PCAP_H_ #define _AIRCRACK_NG_PCAP_H_ #include <stdint.h> #define FORMAT_CAP 1 #define FORMAT_IVS 2 #define FORMAT_IVS2 3 #define FORMAT_HCCAP 4 #define FORMAT_HCCAPX 5 #define HCCAPX_MAGIC "HCPX" #define HCCAPX_CIGAM "XPCH" #define TCPDUMP_MAGIC 0xA1B2C3D4 #define TCPDUMP_CIGAM 0xD4C3B2A1 #define IVSONLY_MAGIC "\xBF\xCA\x84\xD4" #define IVS2_MAGIC "\xAE\x78\xD1\xFF" #define IVS2_EXTENSION "ivs" #define IVS2_VERSION 1 #define PCAP_VERSION_MAJOR 2 #define PCAP_VERSION_MINOR 4 #define LINKTYPE_ETHERNET 1 #define LINKTYPE_IEEE802_11 105 #define LINKTYPE_PRISM_HEADER 119 #define LINKTYPE_RADIOTAP_HDR 127 #define LINKTYPE_PPI_HDR 192 // BSSID const. length of 6 bytes; can be together with all the other types #define IVS2_BSSID 0x0001 // ESSID var. length; alone, or with BSSID #define IVS2_ESSID 0x0002 // wpa structure, const. length; alone, or with BSSID #define IVS2_WPA 0x0004 // IV+IDX+KEYSTREAM, var. length; alone or with BSSID #define IVS2_XOR 0x0008 /* [IV+IDX][i][l][XOR_1]..[XOR_i][weight] * * holds i possible keystreams for the same IV with a length of l for each * keystream (l max 32) * * and an array "int weight[16]" at the end */ #define IVS2_PTW 0x0010 // unencrypted packet #define IVS2_CLR 0x0020 // Maximum length of an Information Element #define MAX_IE_ELEMENT_SIZE 256 struct pcap_file_header { uint32_t magic; uint16_t version_major; uint16_t version_minor; int32_t thiszone; uint32_t sigfigs; uint32_t snaplen; uint32_t linktype; }; struct pcap_pkthdr { int32_t tv_sec; int32_t tv_usec; uint32_t caplen; uint32_t len; }; struct ivs2_filehdr { uint16_t version; }; struct ivs2_pkthdr { uint16_t flags; uint16_t len; }; #endif /* common.h */
C/C++
aircrack-ng/include/aircrack-ng/support/station.h
/* * Copyright (C) 2006-2022 Thomas d'Otreppe <tdotreppe@aircrack-ng.org> * Copyright (C) 2006-2009 Martin Beck <martin.beck2@gmx.de> * Copyright (C) 2018-2022 Joseph Benden <joe@benden.us> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #include <aircrack-ng/ce-wpa/crypto_engine.h> #include <aircrack-ng/adt/avl_tree.h> #include <aircrack-ng/support/pcap_local.h> #include <aircrack-ng/ptw/aircrack-ptw-lib.h> #ifndef AIRCRACK_NG_STATION_H #define AIRCRACK_NG_STATION_H #define NB_PRB 10 /* size of probed ESSID ring buffer */ #define NB_PWR 5 /* size of signal power ring buffer */ /* WPS_info struct */ struct WPS_info { unsigned char version; /* WPS Version */ unsigned char state; /* Current WPS state */ unsigned char ap_setup_locked; /* AP setup locked */ unsigned int meth; /* WPS Config Methods */ }; #define MAX_AC_MCS_INDEX 8 /* 802.11n channel information */ struct n_channel_info { char mcs_index; /* Maximum MCS TX index */ char sec_channel; /* 802.11n secondary channel*/ unsigned char short_gi_20; /* Short GI for 20MHz */ unsigned char short_gi_40; /* Short GI for 40MHz */ unsigned char any_chan_width; /* Support for 20 or 40MHz as opposed to only 20 or only 40MHz */ }; /* 802.11ac channel information */ struct ac_channel_info { unsigned char center_sgmt[2]; /* 802.11ac Center segment 0*/ unsigned char mu_mimo; /* MU-MIMO support */ unsigned char short_gi_80; /* Short GI for 80MHz */ unsigned char short_gi_160; /* Short GI for 160MHz */ unsigned char split_chan; /* 80+80MHz Channel support */ unsigned char mhz_160_chan; /* 160 MHz channel support */ unsigned char wave_2; /* Wave 2 */ unsigned char mcs_index[MAX_AC_MCS_INDEX]; /* Maximum TX rate */ }; enum channel_width_enum { CHANNEL_UNKNOWN_WIDTH, CHANNEL_3MHZ, CHANNEL_5MHZ, CHANNEL_10MHZ, CHANNEL_20MHZ, CHANNEL_22MHZ, CHANNEL_30MHZ, CHANNEL_20_OR_40MHZ, CHANNEL_40MHZ, CHANNEL_80MHZ, CHANNEL_80_80MHZ, CHANNEL_160MHZ }; /** linked list of detected access points. */ struct AP_info { struct AP_info * prev; /* prev. AP in list */ struct AP_info * next; /* next AP in list */ time_t tinit, tlast; /* first and last time seen */ int channel; /* AP radio channel */ enum channel_width_enum channel_width; /* Channel width */ char standard[3]; /* 802.11 standard: n or ac */ struct n_channel_info n_channel; /* 802.11n channel info */ struct ac_channel_info ac_channel; /* 802.11ac channel info */ int max_speed; /* AP maximum speed in Mb/s */ int avg_power; /* averaged signal power */ int best_power; /* best signal power */ int power_index; /* index in power ring buf. */ int power_lvl[NB_PWR]; /* signal power ring buffer */ int preamble; /* 0 = long, 1 = short */ unsigned int security; /* ENC_*, AUTH_*, STD_* */ int beacon_logged; /* We need 1 beacon per AP */ int dict_started; /* 1 if dict attack started */ int ssid_length; /* length of ssid */ float gps_loc_min[5]; /* min gps coordinates */ float gps_loc_max[5]; /* max gps coordinates */ float gps_loc_best[5]; /* best gps coordinates */ unsigned long nb_bcn; /* total number of beacons */ unsigned long nb_pkt; /* total number of packets */ unsigned long nb_data; /* number of data packets */ unsigned long nb_data_old; /* number of data packets/sec*/ int nb_dataps; /* number of data packets/sec*/ struct timeval tv; /* time for data per second */ char * manuf; /* the access point's manufacturer */ unsigned long long timestamp; /* Timestamp to calculate uptime */ uint8_t bssid[6]; /* access point MAC address */ uint8_t essid[ESSID_LENGTH + 1]; /* access point identifier */ uint8_t lanip[4]; /* IP address if unencrypted */ uint8_t * ivbuf; /* table holding WEP IV data */ uint8_t ** uiv_root; /* IV uniqueness root struct */ long ivbuf_size; /* IV buffer allocated size */ long nb_ivs; /* total number of unique IVs */ long nb_ivs_clean; /* total number of unique IVs */ long nb_ivs_vague; /* total number of unique IVs */ unsigned int crypt; /* encryption algorithm */ int eapol; /* set if EAPOL is present */ int target; /* flag set if AP is a target */ struct ST_info * st_1st; /* DEPRECATED: linked list of stations */ c_avl_tree_t * stations; /* AVL tree of stations keyed on MAC*/ struct WPA_hdsk wpa; /* valid WPA handshake data */ PTW_attackstate * ptw_clean; PTW_attackstate * ptw_vague; int wpa_stored; /* wpa stored in ivs file? */ int essid_stored; /* essid stored in ivs file? */ int rx_quality; /* percent of captured beacons */ int fcapt; /* amount of captured frames */ int fmiss; /* amount of missed frames */ unsigned int last_seq; /* last sequence number */ struct timeval ftimef; /* time of first frame */ struct timeval ftimel; /* time of last frame */ struct timeval ftimer; /* time of restart */ char * key; /* if wep-key found by dict */ char decloak_detect; /* run decloak detection? */ struct pkt_buf * packets; /* list of captured packets (last few seconds) */ char is_decloak; /* detected decloak */ // This feature eats 48Mb per AP int EAP_detected; uint8_t * data_root; /* first 2 bytes of data if */ /* WEP network; used for */ /* detecting WEP cloak */ /* + one byte to indicate */ /* (in)existence of the IV */ int marked; int marked_color; struct WPS_info wps; }; /** linked list of detected clients */ struct ST_info { struct ST_info * prev; /* the prev client in list */ struct ST_info * next; /* the next client in list */ struct AP_info * base; /* AP this client belongs to */ uint8_t stmac[6]; /* the client's MAC address */ struct WPA_hdsk wpa; /* WPA handshake data */ char * manuf; /* the client's manufacturer */ time_t tinit, tlast; /* first and last time seen */ unsigned long nb_pkt; /* total number of packets */ uint8_t essid[ESSID_LENGTH + 1]; /* last associated essid */ int essid_length; /* essid length of last asso */ int probe_index; /* probed ESSIDs ring index */ char probes[NB_PRB][MAX_IE_ELEMENT_SIZE]; /* probed ESSIDs ring buffer */ int ssid_length[NB_PRB]; /* ssid lengths ring buffer */ int power; /* last signal power */ int best_power; /* best signal power */ int rate_to; /* last bitrate to station */ int rate_from; /* last bitrate from station */ struct timeval ftimer; /* time of restart */ int missed; /* number of missed packets */ unsigned int lastseq; /* last seen sequnce number */ int wpatype; /* 1=wpa1 2=wpa2 */ int wpahash; /* 1=md5(tkip) 2=sha1(ccmp) */ int wep; /* capability encryption bit */ int qos_to_ds; /* does it use 802.11e to ds */ int qos_fr_ds; /* does it receive 802.11e */ int channel; /* Channel station is seen */ float gps_loc_min[5]; /* min gps coordinates */ float gps_loc_max[5]; /* max gps coordinates */ float gps_loc_best[5]; /* best gps coordinates */ }; #endif //AIRCRACK_NG_STATION_H
C/C++
aircrack-ng/include/aircrack-ng/third-party/eapol.h
#ifndef _NET_EAPOL_H_ #define _NET_EAPOL_H_ #include <stdint.h> struct WPA_hdsk { uint8_t stmac[6]; /* supplicant MAC */ uint8_t snonce[32]; /* supplicant nonce */ uint8_t anonce[32]; /* authenticator nonce */ uint8_t pmkid[16]; /* eapol frame PMKID RSN */ uint8_t keymic[16]; /* eapol frame MIC */ uint8_t eapol[256]; /* eapol frame contents */ uint32_t eapol_size; /* eapol frame size */ uint8_t keyver; /* key version (TKIP / AES) */ uint8_t state; /* handshake completion */ uint8_t found; uint8_t eapol_source; uint64_t replay; uint64_t timestamp_start_us; uint64_t timestamp_last_us; }; #endif // _NET_EAPOL_H_
C/C++
aircrack-ng/include/aircrack-ng/third-party/ethernet.h
/* * Fundamental constants relating to ethernet. * * $FreeBSD$ * */ #ifndef _NET_ETHERNET_H_ #define _NET_ETHERNET_H_ /* * Some basic Ethernet constants. */ #define ETHER_ADDR_LEN 6 /* length of an Ethernet address */ #define ETHER_TYPE_LEN 2 /* length of the Ethernet type field */ #define ETHER_CRC_LEN 4 /* length of the Ethernet CRC */ #define ETHER_HDR_LEN (ETHER_ADDR_LEN*2+ETHER_TYPE_LEN) #define ETHER_MIN_LEN 64 /* minimum frame len, including CRC */ #define ETHER_MAX_LEN 1518 /* maximum frame len, including CRC */ #define ETHER_MAX_LEN_JUMBO 9018 /* max jumbo frame len, including CRC */ #define ETHER_VLAN_ENCAP_LEN 4 /* len of 802.1Q VLAN encapsulation */ /* * Mbuf adjust factor to force 32-bit alignment of IP header. * Drivers should do m_adj(m, ETHER_ALIGN) when setting up a * receive so the upper layers get the IP header properly aligned * past the 14-byte Ethernet header. */ #define ETHER_ALIGN 2 /* driver adjust for IP hdr alignment */ /* * Compute the maximum frame size based on ethertype (i.e. possible * encapsulation) and whether or not an FCS is present. */ #define ETHER_MAX_FRAME(ifp, etype, hasfcs) \ ((ifp)->if_mtu + ETHER_HDR_LEN + \ ((hasfcs) ? ETHER_CRC_LEN : 0) + \ (((etype) == ETHERTYPE_VLAN) ? ETHER_VLAN_ENCAP_LEN : 0)) /* * Ethernet-specific mbuf flags. */ #define M_HASFCS M_PROTO5 /* FCS included at end of frame */ /* * Ethernet CRC32 polynomials (big- and little-endian versions). */ #define ETHER_CRC_POLY_LE 0xedb88320 #define ETHER_CRC_POLY_BE 0x04c11db6 /* * A macro to validate a length with */ #define ETHER_IS_VALID_LEN(foo) \ ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN) /* * Structure of a 10Mb/s Ethernet header. */ struct ether_header { u_char ether_dhost[ETHER_ADDR_LEN]; u_char ether_shost[ETHER_ADDR_LEN]; u_short ether_type; } __packed; /* * Structure of a 48-bit Ethernet address. */ struct ether_addr { u_char octet[ETHER_ADDR_LEN]; } __packed; #define ETHER_IS_MULTICAST(addr) (*(addr) & 0x01) /* is address mcast/bcast? */ /* * NOTE: 0x0000-0x05DC (0..1500) are generally IEEE 802.3 length fields. * However, there are some conflicts. */ #define ETHERTYPE_8023 0x0004 /* IEEE 802.3 packet */ /* 0x0101 .. 0x1FF Experimental */ #define ETHERTYPE_PUP 0x0200 /* Xerox PUP protocol - see 0A00 */ #define ETHERTYPE_PUPAT 0x0200 /* PUP Address Translation - see 0A01 */ #define ETHERTYPE_SPRITE 0x0500 /* ??? */ /* 0x0400 Nixdorf */ #define ETHERTYPE_NS 0x0600 /* XNS */ #define ETHERTYPE_NSAT 0x0601 /* XNS Address Translation (3Mb only) */ #define ETHERTYPE_DLOG1 0x0660 /* DLOG (?) */ #define ETHERTYPE_DLOG2 0x0661 /* DLOG (?) */ #define ETHERTYPE_IP 0x0800 /* IP protocol */ #define ETHERTYPE_X75 0x0801 /* X.75 Internet */ #define ETHERTYPE_NBS 0x0802 /* NBS Internet */ #define ETHERTYPE_ECMA 0x0803 /* ECMA Internet */ #define ETHERTYPE_CHAOS 0x0804 /* CHAOSnet */ #define ETHERTYPE_X25 0x0805 /* X.25 Level 3 */ #define ETHERTYPE_ARP 0x0806 /* Address resolution protocol */ #define ETHERTYPE_NSCOMPAT 0x0807 /* XNS Compatibility */ #define ETHERTYPE_FRARP 0x0808 /* Frame Relay ARP (RFC1701) */ /* 0x081C Symbolics Private */ /* 0x0888 - 0x088A Xyplex */ #define ETHERTYPE_UBDEBUG 0x0900 /* Ungermann-Bass network debugger */ #define ETHERTYPE_IEEEPUP 0x0A00 /* Xerox IEEE802.3 PUP */ #define ETHERTYPE_IEEEPUPAT 0x0A01 /* Xerox IEEE802.3 PUP Address Translation */ #define ETHERTYPE_VINES 0x0BAD /* Banyan VINES */ #define ETHERTYPE_VINESLOOP 0x0BAE /* Banyan VINES Loopback */ #define ETHERTYPE_VINESECHO 0x0BAF /* Banyan VINES Echo */ /* 0x1000 - 0x100F Berkeley Trailer */ /* * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have * (type-ETHERTYPE_TRAIL)*512 bytes of data followed * by an ETHER type (as given above) and then the (variable-length) header. */ #define ETHERTYPE_TRAIL 0x1000 /* Trailer packet */ #define ETHERTYPE_NTRAILER 16 #define ETHERTYPE_DCA 0x1234 /* DCA - Multicast */ #define ETHERTYPE_VALID 0x1600 /* VALID system protocol */ #define ETHERTYPE_DOGFIGHT 0x1989 /* Artificial Horizons ("Aviator" dogfight simulator [on Sun]) */ #define ETHERTYPE_RCL 0x1995 /* Datapoint Corporation (RCL lan protocol) */ /* The following 3C0x types are unregistered: */ #define ETHERTYPE_NBPVCD 0x3C00 /* 3Com NBP virtual circuit datagram (like XNS SPP) not registered */ #define ETHERTYPE_NBPSCD 0x3C01 /* 3Com NBP System control datagram not registered */ #define ETHERTYPE_NBPCREQ 0x3C02 /* 3Com NBP Connect request (virtual cct) not registered */ #define ETHERTYPE_NBPCRSP 0x3C03 /* 3Com NBP Connect response not registered */ #define ETHERTYPE_NBPCC 0x3C04 /* 3Com NBP Connect complete not registered */ #define ETHERTYPE_NBPCLREQ 0x3C05 /* 3Com NBP Close request (virtual cct) not registered */ #define ETHERTYPE_NBPCLRSP 0x3C06 /* 3Com NBP Close response not registered */ #define ETHERTYPE_NBPDG 0x3C07 /* 3Com NBP Datagram (like XNS IDP) not registered */ #define ETHERTYPE_NBPDGB 0x3C08 /* 3Com NBP Datagram broadcast not registered */ #define ETHERTYPE_NBPCLAIM 0x3C09 /* 3Com NBP Claim NetBIOS name not registered */ #define ETHERTYPE_NBPDLTE 0x3C0A /* 3Com NBP Delete NetBIOS name not registered */ #define ETHERTYPE_NBPRAS 0x3C0B /* 3Com NBP Remote adaptor status request not registered */ #define ETHERTYPE_NBPRAR 0x3C0C /* 3Com NBP Remote adaptor response not registered */ #define ETHERTYPE_NBPRST 0x3C0D /* 3Com NBP Reset not registered */ #define ETHERTYPE_PCS 0x4242 /* PCS Basic Block Protocol */ #define ETHERTYPE_IMLBLDIAG 0x424C /* Information Modes Little Big LAN diagnostic */ #define ETHERTYPE_DIDDLE 0x4321 /* THD - Diddle */ #define ETHERTYPE_IMLBL 0x4C42 /* Information Modes Little Big LAN */ #define ETHERTYPE_SIMNET 0x5208 /* BBN Simnet Private */ #define ETHERTYPE_DECEXPER 0x6000 /* DEC Unassigned, experimental */ #define ETHERTYPE_MOPDL 0x6001 /* DEC MOP dump/load */ #define ETHERTYPE_MOPRC 0x6002 /* DEC MOP remote console */ #define ETHERTYPE_DECnet 0x6003 /* DEC DECNET Phase IV route */ #define ETHERTYPE_DN ETHERTYPE_DECnet /* libpcap, tcpdump */ #define ETHERTYPE_LAT 0x6004 /* DEC LAT */ #define ETHERTYPE_DECDIAG 0x6005 /* DEC diagnostic protocol (at interface initialization?) */ #define ETHERTYPE_DECCUST 0x6006 /* DEC customer protocol */ #define ETHERTYPE_SCA 0x6007 /* DEC LAVC, SCA */ #define ETHERTYPE_AMBER 0x6008 /* DEC AMBER */ #define ETHERTYPE_DECMUMPS 0x6009 /* DEC MUMPS */ /* 0x6010 - 0x6014 3Com Corporation */ #define ETHERTYPE_TRANSETHER 0x6558 /* Trans Ether Bridging (RFC1701)*/ #define ETHERTYPE_RAWFR 0x6559 /* Raw Frame Relay (RFC1701) */ #define ETHERTYPE_UBDL 0x7000 /* Ungermann-Bass download */ #define ETHERTYPE_UBNIU 0x7001 /* Ungermann-Bass NIUs */ #define ETHERTYPE_UBDIAGLOOP 0x7002 /* Ungermann-Bass diagnostic/loopback */ #define ETHERTYPE_UBNMC 0x7003 /* Ungermann-Bass ??? (NMC to/from UB Bridge) */ #define ETHERTYPE_UBBST 0x7005 /* Ungermann-Bass Bridge Spanning Tree */ #define ETHERTYPE_OS9 0x7007 /* OS/9 Microware */ #define ETHERTYPE_OS9NET 0x7009 /* OS/9 Net? */ /* 0x7020 - 0x7029 LRT (England) (now Sintrom) */ #define ETHERTYPE_RACAL 0x7030 /* Racal-Interlan */ #define ETHERTYPE_PRIMENTS 0x7031 /* Prime NTS (Network Terminal Service) */ #define ETHERTYPE_CABLETRON 0x7034 /* Cabletron */ #define ETHERTYPE_CRONUSVLN 0x8003 /* Cronus VLN */ #define ETHERTYPE_CRONUS 0x8004 /* Cronus Direct */ #define ETHERTYPE_HP 0x8005 /* HP Probe */ #define ETHERTYPE_NESTAR 0x8006 /* Nestar */ #define ETHERTYPE_ATTSTANFORD 0x8008 /* AT&T/Stanford (local use) */ #define ETHERTYPE_EXCELAN 0x8010 /* Excelan */ #define ETHERTYPE_SG_DIAG 0x8013 /* SGI diagnostic type */ #define ETHERTYPE_SG_NETGAMES 0x8014 /* SGI network games */ #define ETHERTYPE_SG_RESV 0x8015 /* SGI reserved type */ #define ETHERTYPE_SG_BOUNCE 0x8016 /* SGI bounce server */ #define ETHERTYPE_APOLLODOMAIN 0x8019 /* Apollo DOMAIN */ #define ETHERTYPE_TYMSHARE 0x802E /* Tymeshare */ #define ETHERTYPE_TIGAN 0x802F /* Tigan, Inc. */ #define ETHERTYPE_REVARP 0x8035 /* Reverse addr resolution protocol */ #define ETHERTYPE_AEONIC 0x8036 /* Aeonic Systems */ #define ETHERTYPE_IPXNEW 0x8037 /* IPX (Novell Netware?) */ #define ETHERTYPE_LANBRIDGE 0x8038 /* DEC LANBridge */ #define ETHERTYPE_DSMD 0x8039 /* DEC DSM/DDP */ #define ETHERTYPE_ARGONAUT 0x803A /* DEC Argonaut Console */ #define ETHERTYPE_VAXELN 0x803B /* DEC VAXELN */ #define ETHERTYPE_DECDNS 0x803C /* DEC DNS Naming Service */ #define ETHERTYPE_ENCRYPT 0x803D /* DEC Ethernet Encryption */ #define ETHERTYPE_DECDTS 0x803E /* DEC Distributed Time Service */ #define ETHERTYPE_DECLTM 0x803F /* DEC LAN Traffic Monitor */ #define ETHERTYPE_DECNETBIOS 0x8040 /* DEC PATHWORKS DECnet NETBIOS Emulation */ #define ETHERTYPE_DECLAST 0x8041 /* DEC Local Area System Transport */ /* 0x8042 DEC Unassigned */ #define ETHERTYPE_PLANNING 0x8044 /* Planning Research Corp. */ /* 0x8046 - 0x8047 AT&T */ #define ETHERTYPE_DECAM 0x8048 /* DEC Availability Manager for Distributed Systems DECamds (but someone at DEC says not) */ #define ETHERTYPE_EXPERDATA 0x8049 /* ExperData */ #define ETHERTYPE_VEXP 0x805B /* Stanford V Kernel exp. */ #define ETHERTYPE_VPROD 0x805C /* Stanford V Kernel prod. */ #define ETHERTYPE_ES 0x805D /* Evans & Sutherland */ #define ETHERTYPE_LITTLE 0x8060 /* Little Machines */ #define ETHERTYPE_COUNTERPOINT 0x8062 /* Counterpoint Computers */ /* 0x8065 - 0x8066 Univ. of Mass @ Amherst */ #define ETHERTYPE_VEECO 0x8067 /* Veeco Integrated Auto. */ #define ETHERTYPE_GENDYN 0x8068 /* General Dynamics */ #define ETHERTYPE_ATT 0x8069 /* AT&T */ #define ETHERTYPE_AUTOPHON 0x806A /* Autophon */ #define ETHERTYPE_COMDESIGN 0x806C /* ComDesign */ #define ETHERTYPE_COMPUGRAPHIC 0x806D /* Compugraphic Corporation */ /* 0x806E - 0x8077 Landmark Graphics Corp. */ #define ETHERTYPE_MATRA 0x807A /* Matra */ #define ETHERTYPE_DDE 0x807B /* Dansk Data Elektronik */ #define ETHERTYPE_MERIT 0x807C /* Merit Internodal (or Univ of Michigan?) */ /* 0x807D - 0x807F Vitalink Communications */ #define ETHERTYPE_VLTLMAN 0x8080 /* Vitalink TransLAN III Management */ /* 0x8081 - 0x8083 Counterpoint Computers */ /* 0x8088 - 0x808A Xyplex */ #define ETHERTYPE_ATALK 0x809B /* AppleTalk */ #define ETHERTYPE_AT ETHERTYPE_ATALK /* old NetBSD */ #define ETHERTYPE_APPLETALK ETHERTYPE_ATALK /* HP-UX */ /* 0x809C - 0x809E Datability */ #define ETHERTYPE_SPIDER 0x809F /* Spider Systems Ltd. */ /* 0x80A3 Nixdorf */ /* 0x80A4 - 0x80B3 Siemens Gammasonics Inc. */ /* 0x80C0 - 0x80C3 DCA (Digital Comm. Assoc.) Data Exchange Cluster */ /* 0x80C4 - 0x80C5 Banyan Systems */ #define ETHERTYPE_PACER 0x80C6 /* Pacer Software */ #define ETHERTYPE_APPLITEK 0x80C7 /* Applitek Corporation */ /* 0x80C8 - 0x80CC Intergraph Corporation */ /* 0x80CD - 0x80CE Harris Corporation */ /* 0x80CF - 0x80D2 Taylor Instrument */ /* 0x80D3 - 0x80D4 Rosemount Corporation */ #define ETHERTYPE_SNA 0x80D5 /* IBM SNA Services over Ethernet */ #define ETHERTYPE_VARIAN 0x80DD /* Varian Associates */ /* 0x80DE - 0x80DF TRFS (Integrated Solutions Transparent Remote File System) */ /* 0x80E0 - 0x80E3 Allen-Bradley */ /* 0x80E4 - 0x80F0 Datability */ #define ETHERTYPE_RETIX 0x80F2 /* Retix */ #define ETHERTYPE_AARP 0x80F3 /* AppleTalk AARP */ /* 0x80F4 - 0x80F5 Kinetics */ #define ETHERTYPE_APOLLO 0x80F7 /* Apollo Computer */ #define ETHERTYPE_VLAN 0x8100 /* IEEE 802.1Q VLAN tagging (XXX conflicts) */ /* 0x80FF - 0x8101 Wellfleet Communications (XXX conflicts) */ #define ETHERTYPE_BOFL 0x8102 /* Wellfleet; BOFL (Breath OF Life) pkts [every 5-10 secs.] */ #define ETHERTYPE_WELLFLEET 0x8103 /* Wellfleet Communications */ /* 0x8107 - 0x8109 Symbolics Private */ #define ETHERTYPE_TALARIS 0x812B /* Talaris */ #define ETHERTYPE_WATERLOO 0x8130 /* Waterloo Microsystems Inc. (XXX which?) */ #define ETHERTYPE_HAYES 0x8130 /* Hayes Microcomputers (XXX which?) */ #define ETHERTYPE_VGLAB 0x8131 /* VG Laboratory Systems */ /* 0x8132 - 0x8137 Bridge Communications */ #define ETHERTYPE_IPX 0x8137 /* Novell (old) NetWare IPX (ECONFIG E option) */ #define ETHERTYPE_NOVELL 0x8138 /* Novell, Inc. */ /* 0x8139 - 0x813D KTI */ #define ETHERTYPE_MUMPS 0x813F /* M/MUMPS data sharing */ #define ETHERTYPE_AMOEBA 0x8145 /* Vrije Universiteit (NL) Amoeba 4 RPC (obsolete) */ #define ETHERTYPE_FLIP 0x8146 /* Vrije Universiteit (NL) FLIP (Fast Local Internet Protocol) */ #define ETHERTYPE_VURESERVED 0x8147 /* Vrije Universiteit (NL) [reserved] */ #define ETHERTYPE_LOGICRAFT 0x8148 /* Logicraft */ #define ETHERTYPE_NCD 0x8149 /* Network Computing Devices */ #define ETHERTYPE_ALPHA 0x814A /* Alpha Micro */ #define ETHERTYPE_SNMP 0x814C /* SNMP over Ethernet (see RFC1089) */ /* 0x814D - 0x814E BIIN */ #define ETHERTYPE_TEC 0x814F /* Technically Elite Concepts */ #define ETHERTYPE_RATIONAL 0x8150 /* Rational Corp */ /* 0x8151 - 0x8153 Qualcomm */ /* 0x815C - 0x815E Computer Protocol Pty Ltd */ /* 0x8164 - 0x8166 Charles River Data Systems */ #define ETHERTYPE_XTP 0x817D /* Protocol Engines XTP */ #define ETHERTYPE_SGITW 0x817E /* SGI/Time Warner prop. */ #define ETHERTYPE_HIPPI_FP 0x8180 /* HIPPI-FP encapsulation */ #define ETHERTYPE_STP 0x8181 /* Scheduled Transfer STP, HIPPI-ST */ /* 0x8182 - 0x8183 Reserved for HIPPI-6400 */ /* 0x8184 - 0x818C SGI prop. */ #define ETHERTYPE_MOTOROLA 0x818D /* Motorola */ #define ETHERTYPE_NETBEUI 0x8191 /* PowerLAN NetBIOS/NetBEUI (PC) */ /* 0x819A - 0x81A3 RAD Network Devices */ /* 0x81B7 - 0x81B9 Xyplex */ /* 0x81CC - 0x81D5 Apricot Computers */ /* 0x81D6 - 0x81DD Artisoft Lantastic */ /* 0x81E6 - 0x81EF Polygon */ /* 0x81F0 - 0x81F2 Comsat Labs */ /* 0x81F3 - 0x81F5 SAIC */ /* 0x81F6 - 0x81F8 VG Analytical */ /* 0x8203 - 0x8205 QNX Software Systems Ltd. */ /* 0x8221 - 0x8222 Ascom Banking Systems */ /* 0x823E - 0x8240 Advanced Encryption Systems */ /* 0x8263 - 0x826A Charles River Data Systems */ /* 0x827F - 0x8282 Athena Programming */ /* 0x829A - 0x829B Inst Ind Info Tech */ /* 0x829C - 0x82AB Taurus Controls */ /* 0x82AC - 0x8693 Walker Richer & Quinn */ #define ETHERTYPE_ACCTON 0x8390 /* Accton Technologies (unregistered) */ #define ETHERTYPE_TALARISMC 0x852B /* Talaris multicast */ #define ETHERTYPE_KALPANA 0x8582 /* Kalpana */ /* 0x8694 - 0x869D Idea Courier */ /* 0x869E - 0x86A1 Computer Network Tech */ /* 0x86A3 - 0x86AC Gateway Communications */ #define ETHERTYPE_SECTRA 0x86DB /* SECTRA */ #define ETHERTYPE_IPV6 0x86DD /* IP protocol version 6 */ #define ETHERTYPE_DELTACON 0x86DE /* Delta Controls */ #define ETHERTYPE_ATOMIC 0x86DF /* ATOMIC */ /* 0x86E0 - 0x86EF Landis & Gyr Powers */ /* 0x8700 - 0x8710 Motorola */ #define ETHERTYPE_RDP 0x8739 /* Control Technology Inc. RDP Without IP */ #define ETHERTYPE_MICP 0x873A /* Control Technology Inc. Mcast Industrial Ctrl Proto. */ /* 0x873B - 0x873C Control Technology Inc. Proprietary */ #define ETHERTYPE_TCPCOMP 0x876B /* TCP/IP Compression (RFC1701) */ #define ETHERTYPE_IPAS 0x876C /* IP Autonomous Systems (RFC1701) */ #define ETHERTYPE_SECUREDATA 0x876D /* Secure Data (RFC1701) */ #define ETHERTYPE_FLOWCONTROL 0x8808 /* 802.3x flow control packet */ #define ETHERTYPE_SLOW 0x8809 /* 802.3ad link aggregation (LACP) */ #define ETHERTYPE_PPP 0x880B /* PPP (obsolete by PPPoE) */ #define ETHERTYPE_HITACHI 0x8820 /* Hitachi Cable (Optoelectronic Systems Laboratory) */ #define ETHERTYPE_MPLS 0x8847 /* MPLS Unicast */ #define ETHERTYPE_MPLS_MCAST 0x8848 /* MPLS Multicast */ #define ETHERTYPE_AXIS 0x8856 /* Axis Communications AB proprietary bootstrap/config */ #define ETHERTYPE_PPPOEDISC 0x8863 /* PPP Over Ethernet Discovery Stage */ #define ETHERTYPE_PPPOE 0x8864 /* PPP Over Ethernet Session Stage */ #define ETHERTYPE_LANPROBE 0x8888 /* HP LanProbe test? */ #define ETHERTYPE_PAE 0x888e /* EAPOL PAE/802.1x */ #define ETHERTYPE_LOOPBACK 0x9000 /* Loopback: used to test interfaces */ #define ETHERTYPE_LBACK ETHERTYPE_LOOPBACK /* DEC MOP loopback */ #define ETHERTYPE_XNSSM 0x9001 /* 3Com (Formerly Bridge Communications), XNS Systems Management */ #define ETHERTYPE_TCPSM 0x9002 /* 3Com (Formerly Bridge Communications), TCP/IP Systems Management */ #define ETHERTYPE_BCLOOP 0x9003 /* 3Com (Formerly Bridge Communications), loopback detection */ #define ETHERTYPE_DEBNI 0xAAAA /* DECNET? Used by VAX 6220 DEBNI */ #define ETHERTYPE_SONIX 0xFAF5 /* Sonix Arpeggio */ #define ETHERTYPE_VITAL 0xFF00 /* BBN VITAL-LanBridge cache wakeups */ /* 0xFF00 - 0xFFOF ISC Bunker Ramo */ #define ETHERTYPE_MAX 0xFFFF /* Maximum valid ethernet type, reserved */ /* * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have * (type-ETHERTYPE_TRAIL)*512 bytes of data followed * by an ETHER type (as given above) and then the (variable-length) header. */ #define ETHERTYPE_TRAIL 0x1000 /* Trailer packet */ #define ETHERTYPE_NTRAILER 16 #define ETHERMTU (ETHER_MAX_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN) #define ETHERMIN (ETHER_MIN_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN) #define ETHERMTU_JUMBO (ETHER_MAX_LEN_JUMBO - ETHER_HDR_LEN - ETHER_CRC_LEN) /* * The ETHER_BPF_MTAP macro should be used by drivers which support hardware * offload for VLAN tag processing. It will check the mbuf to see if it has * M_VLANTAG set, and if it does, will pass the packet along to * ether_vlan_mtap. This function will re-insert VLAN tags for the duration * of the tap, so they show up properly for network analyzers. */ #define ETHER_BPF_MTAP(_ifp, _m) do { \ if (bpf_peers_present((_ifp)->if_bpf)) { \ M_ASSERTVALID(_m); \ if (((_m)->m_flags & M_VLANTAG) != 0) \ ether_vlan_mtap((_ifp)->if_bpf, (_m), NULL, 0); \ else \ bpf_mtap((_ifp)->if_bpf, (_m)); \ } \ } while (0) #ifdef _KERNEL struct ifnet; struct mbuf; struct route; struct sockaddr; struct bpf_if; extern uint32_t ether_crc32_le(const uint8_t *, size_t); extern uint32_t ether_crc32_be(const uint8_t *, size_t); extern void ether_demux(struct ifnet *, struct mbuf *); extern void ether_ifattach(struct ifnet *, const u_int8_t *); extern void ether_ifdetach(struct ifnet *); extern int ether_ioctl(struct ifnet *, u_long, caddr_t); extern int ether_output(struct ifnet *, struct mbuf *, const struct sockaddr *, struct route *); extern int ether_output_frame(struct ifnet *, struct mbuf *); extern char *ether_sprintf(const u_int8_t *); void ether_vlan_mtap(struct bpf_if *, struct mbuf *, void *, u_int); struct mbuf *ether_vlanencap(struct mbuf *, uint16_t); #else /* _KERNEL */ /* * Ethernet address conversion/parsing routines. */ #ifdef __cplusplus extern "C" { #endif struct ether_addr *ether_aton(const char *); struct ether_addr *ether_aton_r(const char *, struct ether_addr *); int ether_hostton(const char *, struct ether_addr *); int ether_line(const char *, struct ether_addr *, char *); char *ether_ntoa(const struct ether_addr *); char *ether_ntoa_r(const struct ether_addr *, char *); int ether_ntohost(char *, const struct ether_addr *); #ifdef __cplusplus } #endif #endif /* !_KERNEL */ #endif /* !_NET_ETHERNET_H_ */
C/C++
aircrack-ng/include/aircrack-ng/third-party/hashcat.h
/* * Hashcat structures and macros * * Copyright (C) 2018-2022 Thomas d'Otreppe <tdotreppe@aircrack-ng.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef _HASHCAT_H_ #define _HASHCAT_H_ #include <stdint.h> // Hashcat v3.5 and lower typedef struct { char essid[36]; unsigned char mac1[6]; unsigned char mac2[6]; unsigned char nonce1[32]; unsigned char nonce2[32]; unsigned char eapol[256]; int eapol_size; int keyver; unsigned char keymic[16]; } hccap_t; // Docs: https://hashcat.net/wiki/doku.php?id=hccapx #define HCCAPX_SIGNATURE 0x58504348 // HCPX #define HCCAPX_CURRENT_VERSION 4 // https://hashcat.net/wiki/doku.php?id=hccapx typedef struct hccapx { uint32_t signature; /* signature (file magic) of .hccapx files, it is always the string HCPX */ uint32_t version; /* version number of the .hccapx file format */ uint8_t message_pair; /* possible values range from 0 to 5 or 128 to 133 */ /* message_pair was extended with some additional information: the highest * bit could be used * to indicate if the message pair matching was done based on replay counter * or not. Whenever * the highest bit (bit 8) was set to 1 it means that the replay counter was * ignored (i.e. it * was not considered at all by the matching algorithm): * * .----------------------------------------------------------------------------------------------------------------------------. * | message_pair (hex) | message_pair (dec) | Highest bit | Meaning | * .----------------------------------------------------------------------------------------------------------------------------. * | 0x00 to 0x05 | 0 to 5 | 0 | Message pair * according to table below with replay counter matching | * | 0x80 to 0x85 | 128 to 133 | 1 | Message pair * according to table below, replay counter was ignored | * .----------------------------------------------------------------------------------------------------------------------------. * * The message_pair value describes which messages of the 4-way handshake were * combined to form the * .hccapx structure. It is always a pair of 2 messages: 1 from the AP (access * point) and 1 from the STA (client). * * Furthermore, the message_pair value also gives a hint from which of the 2 * messages the EAPOL origins. * This is interesting data, but not necessarily needed for hashcat to be able * to crack the hash. * * On the other hand, it could be very important to know if "only" message 1 * and message 2 were captured * or if for instance message 3 and/or message 4 were captured too. If message * 3 and/or message 4 were captured * it should be a hard evidence that the connection was established and that * the password the client used was the * correct one. * * The following table lists all values currently allowed for the message_pair * field: * * .----------------------------------------------------------------------------------------------------------------------------. * | message_pair value | Messages of the handshake | Source of the EAPOL | AP * message | STA message | Replay counter matching | * .----------------------------------------------------------------------------------------------------------------------------. * | 0 | M1 + M2 | M2 | M1 * | M2 | Yes | * | 1 | M1 + M4 | M4 | M1 * | M4 | Yes | * | 2 | M2 + M3 | M2 | M3 * | M2 | Yes | * | 3 | M2 + M3 | M3 | M3 * | M2 | Yes | * | 4 | M3 + M4 | M3 | M3 * | M4 | Yes | * | 5 | M3 + M4 | M4 | M3 * | M4 | Yes | * | 128 | M1 + M2 | M2 | M1 * | M2 | No | * | 129 | M1 + M4 | M4 | M1 * | M4 | No | * | 130 | M2 + M3 | M2 | M3 * | M2 | No | * | 131 | M2 + M3 | M3 | M3 * | M2 | No | * | 132 | M3 + M4 | M3 | M3 * | M4 | No | * | 133 | M3 + M4 | M4 | M3 * | M4 | No | * .----------------------------------------------------------------------------------------------------------------------------. * * Note: M1 means message 1 of the handshake, M2 means message 2 of the * handshake, M3 means message 3 of * the handshake and M4 means message 4 of the 4-way handshake */ uint8_t essid_len; /* length of the network name (ESSID) */ uint8_t essid[32]; /* ESSID */ uint8_t keyver; /* set to 1 if WPA is used, other values (preferably 2) means WPA2 */ uint8_t keymic[16]; /* the actual hash value (MD5 for WPA, SHA1 for WPA2) truncated to 128 bit (16 bytes) */ uint8_t mac_ap[6]; /* BSSID */ uint8_t nonce_ap[32]; /* nonce (random salt) generated by the access point */ uint8_t mac_sta[6]; /* mac address of the client connecting to the access point */ uint8_t nonce_sta[32]; /* nonce (random salt) generated by the client connecting to the access point */ uint16_t eapol_len; /* length of the EAPOL */ uint8_t eapol[256]; /* EAPOL (max 256 bytes) */ } __attribute__((packed)) hccapx_t; #endif
C/C++
aircrack-ng/include/aircrack-ng/third-party/ieee80211.h
/* $NetBSD: ieee80211.h,v 1.26 2013/03/30 14:14:31 christos Exp $ */ /*- * Copyright (c) 2001 Atsushi Onoe * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * Alternatively, this software may be distributed under the terms of the * GNU General Public License ("GPL") version 2 as published by the Free * Software Foundation. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/net80211/ieee80211.h,v 1.10 2005/07/22 16:55:27 sam Exp $ */ #ifndef _NET80211_IEEE80211_H_ #define _NET80211_IEEE80211_H_ /* * 802.11 protocol definitions. */ #define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */ /* is 802.11 address multicast/broadcast? */ #define IEEE80211_IS_MULTICAST(_a) (*(_a) & 0x01) /* IEEE 802.11 PLCP header */ struct ieee80211_plcp_hdr { u_int16_t i_sfd; u_int8_t i_signal; u_int8_t i_service; u_int16_t i_length; u_int16_t i_crc; } __packed; #define IEEE80211_PLCP_SFD 0xF3A0 #define IEEE80211_PLCP_SERVICE 0x00 /* * generic definitions for IEEE 802.11 frames */ struct ieee80211_frame { u_int8_t i_fc[2]; u_int8_t i_dur[2]; u_int8_t i_addr1[IEEE80211_ADDR_LEN]; u_int8_t i_addr2[IEEE80211_ADDR_LEN]; u_int8_t i_addr3[IEEE80211_ADDR_LEN]; u_int8_t i_seq[2]; /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */ /* see below */ } __packed; struct ieee80211_qosframe { u_int8_t i_fc[2]; u_int8_t i_dur[2]; u_int8_t i_addr1[IEEE80211_ADDR_LEN]; u_int8_t i_addr2[IEEE80211_ADDR_LEN]; u_int8_t i_addr3[IEEE80211_ADDR_LEN]; u_int8_t i_seq[2]; u_int8_t i_qos[2]; /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */ /* see below */ } __packed; struct ieee80211_qoscntl { u_int8_t i_qos[2]; }; struct ieee80211_frame_addr4 { u_int8_t i_fc[2]; u_int8_t i_dur[2]; u_int8_t i_addr1[IEEE80211_ADDR_LEN]; u_int8_t i_addr2[IEEE80211_ADDR_LEN]; u_int8_t i_addr3[IEEE80211_ADDR_LEN]; u_int8_t i_seq[2]; u_int8_t i_addr4[IEEE80211_ADDR_LEN]; } __packed; struct ieee80211_qosframe_addr4 { u_int8_t i_fc[2]; u_int8_t i_dur[2]; u_int8_t i_addr1[IEEE80211_ADDR_LEN]; u_int8_t i_addr2[IEEE80211_ADDR_LEN]; u_int8_t i_addr3[IEEE80211_ADDR_LEN]; u_int8_t i_seq[2]; u_int8_t i_addr4[IEEE80211_ADDR_LEN]; u_int8_t i_qos[2]; } __packed; #define IEEE80211_FC0_VERSION_MASK 0x03 #define IEEE80211_FC0_VERSION_SHIFT 0 #define IEEE80211_FC0_VERSION_0 0x00 #define IEEE80211_FC0_TYPE_MASK 0x0c #define IEEE80211_FC0_TYPE_SHIFT 2 #define IEEE80211_FC0_TYPE_MGT 0x00 #define IEEE80211_FC0_TYPE_CTL 0x04 #define IEEE80211_FC0_TYPE_DATA 0x08 #define IEEE80211_FC0_SUBTYPE_MASK 0xf0 #define IEEE80211_FC0_SUBTYPE_SHIFT 4 /* for TYPE_MGT */ #define IEEE80211_FC0_SUBTYPE_ASSOC_REQ 0x00 #define IEEE80211_FC0_SUBTYPE_ASSOC_RESP 0x10 #define IEEE80211_FC0_SUBTYPE_REASSOC_REQ 0x20 #define IEEE80211_FC0_SUBTYPE_REASSOC_RESP 0x30 #define IEEE80211_FC0_SUBTYPE_PROBE_REQ 0x40 #define IEEE80211_FC0_SUBTYPE_PROBE_RESP 0x50 #define IEEE80211_FC0_SUBTYPE_BEACON 0x80 #define IEEE80211_FC0_SUBTYPE_ATIM 0x90 #define IEEE80211_FC0_SUBTYPE_DISASSOC 0xa0 #define IEEE80211_FC0_SUBTYPE_AUTH 0xb0 #define IEEE80211_FC0_SUBTYPE_DEAUTH 0xc0 /* for TYPE_CTL */ #define IEEE80211_FC0_SUBTYPE_PS_POLL 0xa0 #define IEEE80211_FC0_SUBTYPE_RTS 0xb0 #define IEEE80211_FC0_SUBTYPE_CTS 0xc0 #define IEEE80211_FC0_SUBTYPE_ACK 0xd0 #define IEEE80211_FC0_SUBTYPE_CF_END 0xe0 #define IEEE80211_FC0_SUBTYPE_CF_END_ACK 0xf0 /* for TYPE_DATA (bit combination) */ #define IEEE80211_FC0_SUBTYPE_DATA 0x00 #define IEEE80211_FC0_SUBTYPE_CF_ACK 0x10 #define IEEE80211_FC0_SUBTYPE_CF_POLL 0x20 #define IEEE80211_FC0_SUBTYPE_CF_ACPL 0x30 #define IEEE80211_FC0_SUBTYPE_NODATA 0x40 #define IEEE80211_FC0_SUBTYPE_CFACK 0x50 #define IEEE80211_FC0_SUBTYPE_CFPOLL 0x60 #define IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK 0x70 #define IEEE80211_FC0_SUBTYPE_QOS 0x80 #define IEEE80211_FC0_SUBTYPE_QOS_NULL 0xc0 /* * DS bit usage * * TA = transmitter address * RA = receiver address * DA = destination address * SA = source address * * ToDS FromDS A1(RA) A2(TA) A3 A4 Use * ----------------------------------------------------------------- * 0 0 DA SA BSSID - IBSS/DLS * 0 1 DA BSSID SA - AP -> STA * 1 0 BSSID SA DA - AP <- STA * 1 1 RA TA DA SA unspecified (WDS) */ #define IEEE80211_FC1_DIR_MASK 0x03 #define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */ #define IEEE80211_FC1_DIR_TODS 0x01 /* STA->AP */ #define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */ #define IEEE80211_FC1_DIR_DSTODS 0x03 /* AP ->AP */ #define IEEE80211_FC1_MORE_FRAG 0x04 #define IEEE80211_FC1_RETRY 0x08 #define IEEE80211_FC1_PWR_MGT 0x10 #define IEEE80211_FC1_MORE_DATA 0x20 #define IEEE80211_FC1_PROTECTED 0x40 #define IEEE80211_FC1_WEP 0x40 /* pre-RSNA compat */ #define IEEE80211_FC1_ORDER 0x80 #define IEEE80211_SEQ_FRAG_MASK 0x000f #define IEEE80211_SEQ_FRAG_SHIFT 0 #define IEEE80211_SEQ_SEQ_MASK 0xfff0 #define IEEE80211_SEQ_SEQ_SHIFT 4 #define IEEE80211_NWID_LEN 32 /* * QoS Control field (see 7.1.3.5). */ /* bit 8 is reserved */ #define IEEE80211_QOS_TXOP 0xff00 #define IEEE80211_QOS_AMSDU 0x0080 /* 11n */ #define IEEE80211_QOS_ACKPOLICY_NORMAL 0x0000 #define IEEE80211_QOS_ACKPOLICY_NOACK 0x0020 #define IEEE80211_QOS_ACKPOLICY_NOEXPLACK 0x0040 #define IEEE80211_QOS_ACKPOLICY 0x0060 #define IEEE80211_QOS_ACKPOLICY_S 5 #define IEEE80211_QOS_ACKPOLICY_MASK 0x0060 #define IEEE80211_QOS_ACKPOLICY_BA 0x0060 #define IEEE80211_QOS_ESOP 0x0010 #define IEEE80211_QOS_ESOP_S 4 #define IEEE80211_QOS_TID 0x000f /* * WME/802.11e information element. */ struct ieee80211_wme_info { u_int8_t wme_id; /* IEEE80211_ELEMID_VENDOR */ u_int8_t wme_len; /* length in bytes */ u_int8_t wme_oui[3]; /* 0x00, 0x50, 0xf2 */ u_int8_t wme_type; /* OUI type */ u_int8_t wme_subtype; /* OUI subtype */ u_int8_t wme_version; /* spec revision */ u_int8_t wme_info; /* QoS info */ } __packed; /* * WME/802.11e Tspec Element */ struct ieee80211_wme_tspec { u_int8_t ts_id; u_int8_t ts_len; u_int8_t ts_oui[3]; u_int8_t ts_oui_type; u_int8_t ts_oui_subtype; u_int8_t ts_version; u_int8_t ts_tsinfo[3]; u_int8_t ts_nom_msdu[2]; u_int8_t ts_max_msdu[2]; u_int8_t ts_min_svc[4]; u_int8_t ts_max_svc[4]; u_int8_t ts_inactv_intv[4]; u_int8_t ts_susp_intv[4]; u_int8_t ts_start_svc[4]; u_int8_t ts_min_rate[4]; u_int8_t ts_mean_rate[4]; u_int8_t ts_max_burst[4]; u_int8_t ts_min_phy[4]; u_int8_t ts_peak_rate[4]; u_int8_t ts_delay[4]; u_int8_t ts_surplus[2]; u_int8_t ts_medium_time[2]; } __packed; /* * WME AC parameter field */ struct ieee80211_wme_acparams { u_int8_t acp_aci_aifsn; u_int8_t acp_logcwminmax; u_int16_t acp_txop; } __packed; /* WME stream classes */ enum ieee80211_wme_ac { WME_AC_BE = 0, /* best effort */ WME_AC_BK = 1, /* background */ WME_AC_VI = 2, /* video */ WME_AC_VO = 3, /* voice */ }; #define WME_NUM_AC 4 /* 4 AC categories */ #define WME_PARAM_ACI 0x60 /* Mask for ACI field */ #define WME_PARAM_ACI_S 5 /* Shift for ACI field */ #define WME_PARAM_ACM 0x10 /* Mask for ACM bit */ #define WME_PARAM_ACM_S 4 /* Shift for ACM bit */ #define WME_PARAM_AIFSN 0x0f /* Mask for aifsn field */ #define WME_PARAM_AIFSN_S 0 /* Shift for aifsn field */ #define WME_PARAM_LOGCWMIN 0x0f /* Mask for CwMin field (in log) */ #define WME_PARAM_LOGCWMIN_S 0 /* Shift for CwMin field */ #define WME_PARAM_LOGCWMAX 0xf0 /* Mask for CwMax field (in log) */ #define WME_PARAM_LOGCWMAX_S 4 /* Shift for CwMax field */ #define WME_AC_TO_TID(_ac) ( \ ((_ac) == WME_AC_VO) ? 6 : \ ((_ac) == WME_AC_VI) ? 5 : \ ((_ac) == WME_AC_BK) ? 1 : \ 0) #define TID_TO_WME_AC(_tid) ( \ ((_tid) < 1) ? WME_AC_BE : \ ((_tid) < 3) ? WME_AC_BK : \ ((_tid) < 6) ? WME_AC_VI : \ WME_AC_VO) /* * WME Parameter Element */ struct ieee80211_wme_param { u_int8_t param_id; u_int8_t param_len; u_int8_t param_oui[3]; u_int8_t param_oui_type; u_int8_t param_oui_sybtype; u_int8_t param_version; u_int8_t param_qosInfo; #define WME_QOSINFO_COUNT 0x0f /* Mask for param count field */ u_int8_t param_reserved; struct ieee80211_wme_acparams params_acParams[WME_NUM_AC]; } __packed; /* * Management Notification Frame */ struct ieee80211_mnf { u_int8_t mnf_category; u_int8_t mnf_action; u_int8_t mnf_dialog; u_int8_t mnf_status; } __packed; #define MNF_SETUP_REQ 0 #define MNF_SETUP_RESP 1 #define MNF_TEARDOWN 2 /* * Control frames. */ struct ieee80211_frame_min { u_int8_t i_fc[2]; u_int8_t i_dur[2]; u_int8_t i_addr1[IEEE80211_ADDR_LEN]; u_int8_t i_addr2[IEEE80211_ADDR_LEN]; /* FCS */ } __packed; struct ieee80211_frame_rts { u_int8_t i_fc[2]; u_int8_t i_dur[2]; u_int8_t i_ra[IEEE80211_ADDR_LEN]; u_int8_t i_ta[IEEE80211_ADDR_LEN]; /* FCS */ } __packed; struct ieee80211_frame_cts { u_int8_t i_fc[2]; u_int8_t i_dur[2]; u_int8_t i_ra[IEEE80211_ADDR_LEN]; /* FCS */ } __packed; struct ieee80211_frame_ack { u_int8_t i_fc[2]; u_int8_t i_dur[2]; u_int8_t i_ra[IEEE80211_ADDR_LEN]; /* FCS */ } __packed; struct ieee80211_frame_pspoll { u_int8_t i_fc[2]; u_int8_t i_aid[2]; u_int8_t i_bssid[IEEE80211_ADDR_LEN]; u_int8_t i_ta[IEEE80211_ADDR_LEN]; /* FCS */ } __packed; struct ieee80211_frame_cfend { /* NB: also CF-End+CF-Ack */ u_int8_t i_fc[2]; u_int8_t i_dur[2]; /* should be zero */ u_int8_t i_ra[IEEE80211_ADDR_LEN]; u_int8_t i_bssid[IEEE80211_ADDR_LEN]; /* FCS */ } __packed; static __inline int ieee80211_has_seq(const struct ieee80211_frame *wh) { return (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) != IEEE80211_FC0_TYPE_CTL; } static __inline int ieee80211_has_addr4(const struct ieee80211_frame *wh) { return (wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) == IEEE80211_FC1_DIR_DSTODS; } static __inline int ieee80211_has_qos(const struct ieee80211_frame *wh) { return (wh->i_fc[0] & (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_QOS)) == (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS); } static __inline int ieee80211_has_htc(const struct ieee80211_frame *wh) { return (wh->i_fc[1] & IEEE80211_FC1_ORDER) && (ieee80211_has_qos(wh) || (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == IEEE80211_FC0_TYPE_MGT); } static __inline u_int16_t ieee80211_get_qos(const struct ieee80211_frame *wh) { const u_int8_t *frm; if (ieee80211_has_addr4(wh)) frm = ((const struct ieee80211_qosframe_addr4 *)wh)->i_qos; else frm = ((const struct ieee80211_qosframe *)wh)->i_qos; return le16toh(*(const u_int16_t *)frm); } /* * BEACON management packets * * octet timestamp[8] * octet beacon interval[2] * octet capability information[2] * information element * octet elemid * octet length * octet information[length] */ typedef u_int8_t *ieee80211_mgt_beacon_t; #define IEEE80211_BEACON_INTERVAL(beacon) \ ((beacon)[8] | ((beacon)[9] << 8)) #define IEEE80211_BEACON_CAPABILITY(beacon) \ ((beacon)[10] | ((beacon)[11] << 8)) #define IEEE80211_CAPINFO_ESS 0x0001 #define IEEE80211_CAPINFO_IBSS 0x0002 #define IEEE80211_CAPINFO_CF_POLLABLE 0x0004 #define IEEE80211_CAPINFO_CF_POLLREQ 0x0008 #define IEEE80211_CAPINFO_PRIVACY 0x0010 #define IEEE80211_CAPINFO_SHORT_PREAMBLE 0x0020 #define IEEE80211_CAPINFO_PBCC 0x0040 #define IEEE80211_CAPINFO_CHNL_AGILITY 0x0080 /* bits 8-9 are reserved */ #define IEEE80211_CAPINFO_SHORT_SLOTTIME 0x0400 #define IEEE80211_CAPINFO_RSN 0x0800 /* bit 12 is reserved */ #define IEEE80211_CAPINFO_DSSSOFDM 0x2000 /* bits 14-15 are reserved */ /* * 802.11i/WPA information element (maximally sized). */ struct ieee80211_ie_wpa { u_int8_t wpa_id; /* IEEE80211_ELEMID_VENDOR */ u_int8_t wpa_len; /* length in bytes */ u_int8_t wpa_oui[3]; /* 0x00, 0x50, 0xf2 */ u_int8_t wpa_type; /* OUI type */ u_int16_t wpa_version; /* spec revision */ u_int32_t wpa_mcipher[1]; /* multicast/group key cipher */ u_int16_t wpa_uciphercnt; /* # pairwise key ciphers */ u_int32_t wpa_uciphers[8];/* ciphers */ u_int16_t wpa_authselcnt; /* authentication selector cnt*/ u_int32_t wpa_authsels[8];/* selectors */ u_int16_t wpa_caps; /* 802.11i capabilities */ u_int16_t wpa_pmkidcnt; /* 802.11i pmkid count */ u_int16_t wpa_pmkids[8]; /* 802.11i pmkids */ } __packed; /* * Management information element payloads. */ enum { IEEE80211_ELEMID_SSID = 0, IEEE80211_ELEMID_RATES = 1, IEEE80211_ELEMID_FHPARMS = 2, IEEE80211_ELEMID_DSPARMS = 3, IEEE80211_ELEMID_CFPARMS = 4, IEEE80211_ELEMID_TIM = 5, IEEE80211_ELEMID_IBSSPARMS = 6, IEEE80211_ELEMID_COUNTRY = 7, IEEE80211_ELEMID_EDCAPARMS = 12, IEEE80211_ELEMID_CHALLENGE = 16, /* 17-31 reserved for challenge text extension */ IEEE80211_ELEMID_PWRCNSTR = 32, IEEE80211_ELEMID_PWRCAP = 33, IEEE80211_ELEMID_TPCREQ = 34, IEEE80211_ELEMID_TPCREP = 35, IEEE80211_ELEMID_SUPPCHAN = 36, IEEE80211_ELEMID_CHANSWITCHANN = 37, IEEE80211_ELEMID_MEASREQ = 38, IEEE80211_ELEMID_MEASREP = 39, IEEE80211_ELEMID_QUIET = 40, IEEE80211_ELEMID_IBSSDFS = 41, IEEE80211_ELEMID_ERP = 42, IEEE80211_ELEMID_HTCAP = 45, /* 11n */ IEEE80211_ELEMID_QOS_CAP = 46, IEEE80211_ELEMID_RSN = 48, IEEE80211_ELEMID_XRATES = 50, IEEE80211_ELEMID_TIE = 56, /* 11r */ IEEE80211_ELEMID_HTINFO = 61, /* 11n */ IEEE80211_ELEMID_MMIE = 76, /* 11w */ IEEE80211_ELEMID_TPC = 150, IEEE80211_ELEMID_CCKM = 156, IEEE80211_ELEMID_VENDOR = 221 /* vendor private */ }; struct ieee80211_tim_ie { u_int8_t tim_ie; /* IEEE80211_ELEMID_TIM */ u_int8_t tim_len; u_int8_t tim_count; /* DTIM count */ u_int8_t tim_period; /* DTIM period */ u_int8_t tim_bitctl; /* bitmap control */ u_int8_t tim_bitmap[1]; /* variable-length bitmap */ } __packed; struct ieee80211_band { u_int8_t schan; /* starting channel */ u_int8_t nchan; /* number channels */ u_int8_t maxtxpwr; /* tx power cap */ } __packed; struct ieee80211_country_ie { u_int8_t ie; /* IEEE80211_ELEMID_COUNTRY */ u_int8_t len; u_int8_t cc[3]; /* ISO CC+(I)ndoor/(O)utdoor */ struct ieee80211_band band[4]; /* up to 4 sub bands */ } __packed; #define IEEE80211_CHALLENGE_LEN 128 #define IEEE80211_RATE_BASIC 0x80 #define IEEE80211_RATE_VAL 0x7f /* EPR information element flags */ #define IEEE80211_ERP_NON_ERP_PRESENT 0x01 #define IEEE80211_ERP_USE_PROTECTION 0x02 #define IEEE80211_ERP_LONG_PREAMBLE 0x04 /* Atheros private advanced capabilities info */ #define ATHEROS_CAP_TURBO_PRIME 0x01 #define ATHEROS_CAP_COMPRESSION 0x02 #define ATHEROS_CAP_FAST_FRAME 0x04 /* bits 3-6 reserved */ #define ATHEROS_CAP_BOOST 0x80 #define ATH_OUI 0x7f0300 /* Atheros OUI */ #define ATH_OUI_TYPE 0x01 #define ATH_OUI_VERSION 0x01 #define WPA_OUI 0xf25000 #define WPA_OUI_TYPE 0x01 #define WPA_VERSION 1 /* current supported version */ #define WPA_CSE_NULL 0x00 #define WPA_CSE_WEP40 0x01 #define WPA_CSE_TKIP 0x02 #define WPA_CSE_CCMP 0x04 #define WPA_CSE_WEP104 0x05 #define WPA_ASE_NONE 0x00 #define WPA_ASE_8021X_UNSPEC 0x01 #define WPA_ASE_8021X_PSK 0x02 #define RSN_OUI 0xac0f00 #define RSN_VERSION 1 /* current supported version */ #define RSN_CSE_NULL 0x00 #define RSN_CSE_WEP40 0x01 #define RSN_CSE_TKIP 0x02 #define RSN_CSE_WRAP 0x03 #define RSN_CSE_CCMP 0x04 #define RSN_CSE_WEP104 0x05 #define RSN_ASE_NONE 0x00 #define RSN_ASE_8021X_UNSPEC 0x01 #define RSN_ASE_8021X_PSK 0x02 #define RSN_CAP_PREAUTH 0x01 #define WME_OUI 0xf25000 #define WME_OUI_TYPE 0x02 #define WME_INFO_OUI_SUBTYPE 0x00 #define WME_PARAM_OUI_SUBTYPE 0x01 #define WME_VERSION 1 /* * AUTH management packets * * octet algo[2] * octet seq[2] * octet status[2] * octet chal.id * octet chal.length * octet chal.text[253] */ typedef u_int8_t *ieee80211_mgt_auth_t; #define IEEE80211_AUTH_ALGORITHM(auth) \ ((auth)[0] | ((auth)[1] << 8)) #define IEEE80211_AUTH_TRANSACTION(auth) \ ((auth)[2] | ((auth)[3] << 8)) #define IEEE80211_AUTH_STATUS(auth) \ ((auth)[4] | ((auth)[5] << 8)) #define IEEE80211_AUTH_ALG_OPEN 0x0000 #define IEEE80211_AUTH_ALG_SHARED 0x0001 #define IEEE80211_AUTH_ALG_LEAP 0x0080 enum { IEEE80211_AUTH_OPEN_REQUEST = 1, IEEE80211_AUTH_OPEN_RESPONSE = 2 }; enum { IEEE80211_AUTH_SHARED_REQUEST = 1, IEEE80211_AUTH_SHARED_CHALLENGE = 2, IEEE80211_AUTH_SHARED_RESPONSE = 3, IEEE80211_AUTH_SHARED_PASS = 4 }; /* * Reason codes * * Unlisted codes are reserved */ enum { IEEE80211_REASON_UNSPECIFIED = 1, IEEE80211_REASON_AUTH_EXPIRE = 2, IEEE80211_REASON_AUTH_LEAVE = 3, IEEE80211_REASON_ASSOC_EXPIRE = 4, IEEE80211_REASON_ASSOC_TOOMANY = 5, IEEE80211_REASON_NOT_AUTHED = 6, IEEE80211_REASON_NOT_ASSOCED = 7, IEEE80211_REASON_ASSOC_LEAVE = 8, IEEE80211_REASON_ASSOC_NOT_AUTHED = 9, IEEE80211_REASON_RSN_REQUIRED = 11, IEEE80211_REASON_RSN_INCONSISTENT = 12, IEEE80211_REASON_IE_INVALID = 13, IEEE80211_REASON_MIC_FAILURE = 14, IEEE80211_STATUS_SUCCESS = 0, IEEE80211_STATUS_UNSPECIFIED = 1, IEEE80211_STATUS_CAPINFO = 10, IEEE80211_STATUS_NOT_ASSOCED = 11, IEEE80211_STATUS_OTHER = 12, IEEE80211_STATUS_ALG = 13, IEEE80211_STATUS_SEQUENCE = 14, IEEE80211_STATUS_CHALLENGE = 15, IEEE80211_STATUS_TIMEOUT = 16, IEEE80211_STATUS_TOOMANY = 17, IEEE80211_STATUS_BASIC_RATE = 18, IEEE80211_STATUS_SP_REQUIRED = 19, IEEE80211_STATUS_PBCC_REQUIRED = 20, IEEE80211_STATUS_CA_REQUIRED = 21, IEEE80211_STATUS_TOO_MANY_STATIONS = 22, IEEE80211_STATUS_RATES = 23, IEEE80211_STATUS_SHORTSLOT_REQUIRED = 25, IEEE80211_STATUS_DSSSOFDM_REQUIRED = 26 }; #define IEEE80211_WEP_KEYLEN 5 /* 40bit */ #define IEEE80211_WEP_IVLEN 3 /* 24bit */ #define IEEE80211_WEP_KIDLEN 1 /* 1 octet */ #define IEEE80211_WEP_CRCLEN 4 /* CRC-32 */ #define IEEE80211_WEP_TOTLEN (IEEE80211_WEP_IVLEN + \ IEEE80211_WEP_KIDLEN + \ IEEE80211_WEP_CRCLEN) #define IEEE80211_WEP_NKID 4 /* number of key ids */ /* * 802.11i defines an extended IV for use with non-WEP ciphers. * When the EXTIV bit is set in the key id byte an additional * 4 bytes immediately follow the IV for TKIP. For CCMP the * EXTIV bit is likewise set but the 8 bytes represent the * CCMP header rather than IV+extended-IV. */ #define IEEE80211_WEP_EXTIV 0x20 #define IEEE80211_WEP_EXTIVLEN 4 /* extended IV length */ #define IEEE80211_WEP_MICLEN 8 /* trailing MIC */ #define IEEE80211_CRC_LEN 4 /* * Maximum acceptable MTU is: * IEEE80211_MAX_LEN - WEP overhead - CRC - * QoS overhead - RSN/WPA overhead * Min is arbitrarily chosen > IEEE80211_MIN_LEN. The default * mtu is Ethernet-compatible; it's set by ether_ifattach. */ #define IEEE80211_MTU_MAX 2290 #define IEEE80211_MTU_MIN 32 #define IEEE80211_MAX_LEN (2300 + IEEE80211_CRC_LEN + \ (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN)) #define IEEE80211_ACK_LEN \ (sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN) #define IEEE80211_MIN_LEN \ (sizeof(struct ieee80211_frame_min) + IEEE80211_CRC_LEN) /* * The 802.11 spec says at most 2007 stations may be * associated at once. For most AP's this is way more * than is feasible so we use a default of 128. This * number may be overridden by the driver and/or by * user configuration. */ #define IEEE80211_AID_MAX 2007 #define IEEE80211_AID_DEF 128 #define IEEE80211_AID(b) ((b) &~ 0xc000) /* * RTS frame length parameters. The default is specified in * the 802.11 spec as 512; we treat it as implementation-dependent * so it's defined in ieee80211_var.h. The max may be wrong * for jumbo frames. */ #define IEEE80211_RTS_MIN 1 #define IEEE80211_RTS_MAX 2346 /* * TX fragmentation parameters. As above for RTS, we treat * default as implementation-dependent so define it elsewhere. */ #define IEEE80211_FRAG_MIN 256 #define IEEE80211_FRAG_MAX 2346 /* * 802.11 frame duration definitions. */ struct ieee80211_duration { uint16_t d_rts_dur; uint16_t d_data_dur; uint16_t d_plcp_len; uint8_t d_residue; /* unused octets in time slot */ }; /* One Time Unit (TU) is 1Kus = 1024 microseconds. */ #define IEEE80211_DUR_TU 1024 /* IEEE 802.11b durations for DSSS PHY in microseconds */ #define IEEE80211_DUR_DS_LONG_PREAMBLE 144 #define IEEE80211_DUR_DS_SHORT_PREAMBLE 72 #define IEEE80211_DUR_DS_SLOW_PLCPHDR 48 #define IEEE80211_DUR_DS_FAST_PLCPHDR 24 #define IEEE80211_DUR_DS_SLOW_ACK 112 #define IEEE80211_DUR_DS_FAST_ACK 56 #define IEEE80211_DUR_DS_SLOW_CTS 112 #define IEEE80211_DUR_DS_FAST_CTS 56 #define IEEE80211_DUR_DS_SLOT 20 #define IEEE80211_DUR_DS_SIFS 10 #define IEEE80211_DUR_DS_PIFS (IEEE80211_DUR_DS_SIFS + IEEE80211_DUR_DS_SLOT) #define IEEE80211_DUR_DS_DIFS (IEEE80211_DUR_DS_SIFS + \ 2 * IEEE80211_DUR_DS_SLOT) #define IEEE80211_DUR_DS_EIFS (IEEE80211_DUR_DS_SIFS + \ IEEE80211_DUR_DS_SLOW_ACK + \ IEEE80211_DUR_DS_LONG_PREAMBLE + \ IEEE80211_DUR_DS_SLOW_PLCPHDR + \ IEEE80211_DUR_DS_DIFS) #endif /* !_NET80211_IEEE80211_H_ */
C/C++
aircrack-ng/include/aircrack-ng/third-party/if_arp.h
/*- * Copyright (c) 1986, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)if_arp.h 8.1 (Berkeley) 6/10/93 * $FreeBSD$ */ #ifndef _NET_IF_ARP_H_ #define _NET_IF_ARP_H_ /* * Address Resolution Protocol. * * See RFC 826 for protocol description. ARP packets are variable * in size; the arphdr structure defines the fixed-length portion. * Protocol type values are the same as those for 10 Mb/s Ethernet. * It is followed by the variable-sized fields ar_sha, arp_spa, * arp_tha and arp_tpa in that order, according to the lengths * specified. Field names used correspond to RFC 826. */ struct arphdr { u_short ar_hrd; /* format of hardware address */ #define ARPHRD_ETHER 1 /* ethernet hardware format */ #define ARPHRD_IEEE802 6 /* token-ring hardware format */ #define ARPHRD_ARCNET 7 /* arcnet hardware format */ #define ARPHRD_FRELAY 15 /* frame relay hardware format */ #define ARPHRD_IEEE1394 24 /* firewire hardware format */ #define ARPHRD_INFINIBAND 32 /* infiniband hardware format */ u_short ar_pro; /* format of protocol address */ u_char ar_hln; /* length of hardware address */ u_char ar_pln; /* length of protocol address */ u_short ar_op; /* one of: */ #define ARPOP_REQUEST 1 /* request to resolve address */ #define ARPOP_REPLY 2 /* response to previous request */ #define ARPOP_REVREQUEST 3 /* request protocol address given hardware */ #define ARPOP_REVREPLY 4 /* response giving protocol address */ #define ARPOP_INVREQUEST 8 /* request to identify peer */ #define ARPOP_INVREPLY 9 /* response identifying peer */ /* * The remaining fields are variable in size, * according to the sizes above. */ #ifdef COMMENT_ONLY u_char ar_sha[]; /* sender hardware address */ u_char ar_spa[]; /* sender protocol address */ u_char ar_tha[]; /* target hardware address */ u_char ar_tpa[]; /* target protocol address */ #endif }; #define ar_sha(ap) (((caddr_t)((ap)+1)) + 0) #define ar_spa(ap) (((caddr_t)((ap)+1)) + (ap)->ar_hln) #define ar_tha(ap) (((caddr_t)((ap)+1)) + (ap)->ar_hln + (ap)->ar_pln) #define ar_tpa(ap) (((caddr_t)((ap)+1)) + 2*(ap)->ar_hln + (ap)->ar_pln) #define arphdr_len2(ar_hln, ar_pln) \ (sizeof(struct arphdr) + 2*(ar_hln) + 2*(ar_pln)) #define arphdr_len(ap) (arphdr_len2((ap)->ar_hln, (ap)->ar_pln)) /* * ARP ioctl request */ struct arpreq { struct sockaddr arp_pa; /* protocol address */ struct sockaddr arp_ha; /* hardware address */ int arp_flags; /* flags */ }; /* arp_flags and at_flags field values */ #define ATF_INUSE 0x01 /* entry in use */ #define ATF_COM 0x02 /* completed entry (enaddr valid) */ #define ATF_PERM 0x04 /* permanent entry */ #define ATF_PUBL 0x08 /* publish entry (respond for other host) */ #define ATF_USETRAILERS 0x10 /* has requested trailers */ #ifdef _KERNEL /* * Structure shared between the ethernet driver modules and * the address resolution code. */ struct arpcom { struct ifnet *ac_ifp; /* network-visible interface */ void *ac_netgraph; /* ng_ether(4) netgraph node info */ }; #define IFP2AC(ifp) ((struct arpcom *)(ifp->if_l2com)) #define AC2IFP(ac) ((ac)->ac_ifp) #endif /* _KERNEL */ struct arpstat { /* Normal things that happen: */ uint64_t txrequests; /* # of ARP requests sent by this host. */ uint64_t txreplies; /* # of ARP replies sent by this host. */ uint64_t rxrequests; /* # of ARP requests received by this host. */ uint64_t rxreplies; /* # of ARP replies received by this host. */ uint64_t received; /* # of ARP packets received by this host. */ uint64_t arp_spares[4]; /* For either the upper or lower half. */ /* Abnormal event and error counting: */ uint64_t dropped; /* # of packets dropped waiting for a reply. */ uint64_t timeouts; /* # of times with entries removed */ /* due to timeout. */ uint64_t dupips; /* # of duplicate IPs detected. */ }; #ifdef _KERNEL #include <sys/counter.h> #include <net/vnet.h> VNET_PCPUSTAT_DECLARE(struct arpstat, arpstat); /* * In-kernel consumers can use these accessor macros directly to update * stats. */ #define ARPSTAT_ADD(name, val) \ VNET_PCPUSTAT_ADD(struct arpstat, arpstat, name, (val)) #define ARPSTAT_SUB(name, val) ARPSTAT_ADD(name, -(val)) #define ARPSTAT_INC(name) ARPSTAT_ADD(name, 1) #define ARPSTAT_DEC(name) ARPSTAT_SUB(name, 1) #endif /* _KERNEL */ #endif /* !_NET_IF_ARP_H_ */
C/C++
aircrack-ng/include/aircrack-ng/third-party/if_llc.h
/* $NetBSD: if_llc.h,v 1.21 2014/09/05 05:32:07 matt Exp $ */ /* * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)if_llc.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NET_IF_LLC_H_ #define _NET_IF_LLC_H_ /* * IEEE 802.2 Link Level Control headers, for use in conjunction with * 802.{3,4,5} media access control methods. * * Headers here do not use bit fields due to shortcomings in many * compilers. */ struct llc { uint8_t llc_dsap; uint8_t llc_ssap; union { struct { uint8_t control; uint8_t format_id; uint8_t class_u; uint8_t window_x2; } type_u /* XXX __packed ??? */; struct { uint8_t num_snd_x2; uint8_t num_rcv_x2; } type_i /* XXX __packed ??? */; struct { uint8_t control; uint8_t num_rcv_x2; } type_s /* XXX __packed ??? */; struct { uint8_t control; /* * We cannot put the following fields in a structure because * the structure rounding might cause padding. */ uint8_t frmr_rej_pdu0; uint8_t frmr_rej_pdu1; uint8_t frmr_control; uint8_t frmr_control_ext; uint8_t frmr_cause; } type_frmr /* XXX __packed ??? */; struct { uint8_t control; uint8_t org_code[3]; uint16_t ether_type; } type_snap __packed; struct { uint8_t control; uint8_t control_ext; } type_raw /* XXX __packed ??? */; } llc_un /* XXX __packed ??? */; } __packed; struct frmrinfo { uint8_t frmr_rej_pdu0; uint8_t frmr_rej_pdu1; uint8_t frmr_control; uint8_t frmr_control_ext; uint8_t frmr_cause; } __packed; #define llc_control llc_un.type_u.control #define llc_control_ext llc_un.type_raw.control_ext #define llc_fid llc_un.type_u.format_id #define llc_class llc_un.type_u.class_u #define llc_window llc_un.type_u.window_x2 #define llc_frmrinfo llc_un.type_frmr.frmr_rej_pdu0 #define llc_frmr_pdu0 llc_un.type_frmr.frmr_rej_pdu0 #define llc_frmr_pdu1 llc_un.type_frmr.frmr_rej_pdu1 #define llc_frmr_control llc_un.type_frmr.frmr_control #define llc_frmr_control_ext llc_un.type_frmr.frmr_control_ext #define llc_frmr_cause llc_un.type_frmr.frmr_cause #define llc_snap llc_un.type_snap /* * Don't use sizeof(struct llc_un) for LLC header sizes */ #define LLC_ISFRAMELEN 4 #define LLC_UFRAMELEN 3 #define LLC_FRMRLEN 7 #define LLC_SNAPFRAMELEN 8 /* * Unnumbered LLC format commands */ #define LLC_UI 0x3 #define LLC_UI_P 0x13 #define LLC_DISC 0x43 #define LLC_DISC_P 0x53 #define LLC_UA 0x63 #define LLC_UA_P 0x73 #define LLC_TEST 0xe3 #define LLC_TEST_P 0xf3 #define LLC_FRMR 0x87 #define LLC_FRMR_P 0x97 #define LLC_DM 0x0f #define LLC_DM_P 0x1f #define LLC_XID 0xaf #define LLC_XID_P 0xbf #define LLC_SABME 0x6f #define LLC_SABME_P 0x7f /* * Supervisory LLC commands */ #define LLC_RR 0x01 #define LLC_RNR 0x05 #define LLC_REJ 0x09 /* * Info format - dummy only */ #define LLC_INFO 0x00 /* * ISO PDTR 10178 contains among others */ #define LLC_8021D_LSAP 0x42 #define LLC_X25_LSAP 0x7e #define LLC_SNAP_LSAP 0xaa #define LLC_ISO_LSAP 0xfe /* * LLC XID definitions from 802.2, as needed */ #define LLC_XID_FORMAT_BASIC 0x81 #define LLC_XID_BASIC_MINLEN (LLC_UFRAMELEN + 3) #define LLC_XID_CLASS_I 0x1 #define LLC_XID_CLASS_II 0x3 #define LLC_XID_CLASS_III 0x5 #define LLC_XID_CLASS_IV 0x7 #endif /* !_NET_IF_LLC_H_ */
C/C++
aircrack-ng/include/aircrack-ng/tui/console.h
/* * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef AIRCRACK_NG_CONSOLE_H #define AIRCRACK_NG_CONSOLE_H /** * Styling attributes for \a textstyle function. */ #define TEXT_RESET 0 #define TEXT_BRIGHT 1 #define TEXT_DIM 2 #define TEXT_UNDERLINE 3 #define TEXT_BLINK 4 #define TEXT_REVERSE 7 #define TEXT_HIDDEN 8 #define TEXT_MAX_STYLE 8 /** * Color definitions for \a textcolor functions. */ #define TEXT_BLACK 0 #define TEXT_RED 1 #define TEXT_GREEN 2 #define TEXT_YELLOW 3 #define TEXT_BLUE 4 #define TEXT_MAGENTA 5 #define TEXT_CYAN 6 #define TEXT_WHITE 7 #define TEXT_MAX_COLOR 7 /** * Movement direction definitions for \a move function. */ #define CURSOR_UP 0 #define CURSOR_DOWN 1 #define CURSOR_FORWARD 2 #define CURSOR_BACK 3 /** * Character codes for common keyboard keys. */ #define KEY_TAB 0x09 #define KEY_ESCAPE 0x1B #define KEY_SPACE 0x20 #define KEY_ARROW_UP 0x41 #define KEY_ARROW_DOWN 0x42 #define KEY_ARROW_RIGHT 0x43 #define KEY_ARROW_LEFT 0x44 #define KEY_a 0x61 #define KEY_c 0x63 #define KEY_d 0x64 #define KEY_i 0x69 #define KEY_m 0x6D #define KEY_n 0x6E #define KEY_q 0x71 #define KEY_r 0x72 #define KEY_s 0x73 #define KEY_o 0x6F //color on #define KEY_p 0x70 //color off /// Changes the styling, foreground, and background /// character color, as shown in the user's terminal /// console. void textcolor(int attr, int fg, int bg); /// Changes the foreground character color, as shown in the /// user's terminal console. void textcolor_fg(int fg); /// Changes the background character color, as shown in the /// user's terminal console. void textcolor_bg(int bg); /// Switch to normal color or intensity, as shown in the /// user's terminal console. void textcolor_normal(void); /// Switches the styling applied to future written characters to /// the user's terminal console. void textstyle(int attr); /// Moves the cursor to specified column and row, 1-based. void moveto(int x, int y); /// Move the cursor a specified number of positions, in the specified /// direction. void move(int which, int n); /// \brief Erase a subset of the terminal console. /** * From Wikipedia: * * Clears part of the screen. If n {\displaystyle n} n is 0 (or missing), * clear from cursor to end of screen. If n {\displaystyle n} n is 1, * clear from cursor to beginning of the screen. If n {\displaystyle n} n * is 2, clear entire screen (and moves cursor to upper left on DOS * ANSI.SYS). If n {\displaystyle n} n is 3, clear entire screen and * delete all lines saved in the scrollback buffer (this feature was * added for xterm and is supported by other terminal applications). */ void erase_display(int n); /// \brief Erase part of the line; of the user's terminal console. void erase_line(int n); /// Hide the cursor within the terminal console. void hide_cursor(void); /// Show the cursor within the terminal console. void show_cursor(void); /// Reset the terminal console display back to a known working state. void reset_term(void); /// Wrapper around \a getch to avoid displaying the character on the terminal /// console. int mygetch(void); void console_utf8_enable(void); static inline void console_puts(const char * msg) { printf("%s", msg); erase_line(0); putchar('\n'); } #endif // AIRCRACK_NG_CONSOLE_H
C/C++
aircrack-ng/include/aircrack-ng/utf8/verifyssid.h
#ifndef VERIFYSSID_H_INCLUDED #define VERIFYSSID_H_INCLUDED #include <string.h> #ifdef __cplusplus extern "C" { #endif extern int verifyssid(const unsigned char * s); #ifdef __cplusplus }; #endif #endif // VERIFYSSID_H_INCLUDED
Include
aircrack-ng/lib/Makefile.inc
# Aircrack-ng # # Copyright (C) 2022 Joseph Benden <joe@benden.us> # # Autotool support was written by: Joseph Benden <joe@benden.us> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA # # In addition, as a special exception, the copyright holders give # permission to link the code of portions of this program with the # OpenSSL library under certain conditions as described in each # individual source file, and distribute linked combinations # including the two. # # You must obey the GNU General Public License in all respects # for all of the code used other than OpenSSL. # # If you modify file(s) with this exception, you may extend this # exception to your dnl version of the file(s), but you are not obligated # to do so. # # If you dnl do not wish to do so, delete this exception statement from your # version. # # If you delete this exception statement from all source files in the # program, then also delete it here. include %D%/osdep/Makefile.inc SRC_CE_WEP = %D%/ce-wep/uniqueiv.c SRC_CE_WPA = %D%/ce-wpa/crypto_engine.c \ %D%/ce-wpa/memory.c \ %D%/ce-wpa/simd-intrinsics.c \ %D%/ce-wpa/wpapsk.c SRC_COW = %D%/cowpatty/cowpatty.c SRC_CRYPTO = %D%/crypto/crypto.c SRC_PTW = %D%/ptw/aircrack-ptw-lib.c SRC_LIBAC = %D%/libac/adt/avl_tree.c \ %D%/libac/adt/circular_buffer.c \ %D%/libac/adt/circular_queue.c \ %D%/libac/cpu/simd_cpuid.c \ %D%/libac/support/fragments.c \ %D%/libac/support/common.c \ %D%/libac/support/communications.c \ %D%/libac/support/crypto_engine_loader.c \ %D%/libac/support/mcs_index_rates.c \ %D%/libac/tui/console.c \ %D%/libac/utf8/verifyssid.c SRC_RADIOTAP = %D%/radiotap/radiotap.c SRC_CRYPTO += %D%/crypto/md5.c SRC_CRYPTO += %D%/crypto/mac-hmac-md5-generic.c SRC_CRYPTO += %D%/crypto/sha1.c SRC_CRYPTO += %D%/crypto/sha1-git.c SRC_CRYPTO += %D%/crypto/mac-hmac-sha1-generic.c SRC_CRYPTO += %D%/crypto/sha256.c SRC_CRYPTO += %D%/crypto/mac-hmac-sha256-generic.c if LIBGCRYPT if !GCRYPT_WITH_ARCFOUR SRC_CRYPTO += %D%/crypto/arcfour-generic.c endif if GCRYPT_WITH_ARCFOUR SRC_CRYPTO += %D%/crypto/arcfour-gcrypt.c endif if !GCRYPT_WITH_MD5 SRC_CRYPTO += %D%/crypto/md5-generic.c endif if GCRYPT_WITH_MD5 SRC_CRYPTO += %D%/crypto/md5-gcrypt.c endif if !GCRYPT_WITH_SHA1 SRC_CRYPTO += %D%/crypto/sha1-generic.c endif if GCRYPT_WITH_SHA1 SRC_CRYPTO += %D%/crypto/sha1-gcrypt.c endif if GCRYPT_WITH_SHA256 SRC_CRYPTO += %D%/crypto/sha256-gcrypt.c endif if GCRYPT_WITH_CMAC SRC_CRYPTO += %D%/crypto/mac-omac1-gcrypt.c endif if GCRYPT_WITH_AES SRC_CRYPTO += %D%/crypto/aes-128-cbc-gcrypt.c endif endif if !LIBGCRYPT if !OPENSSL_WITH_ARCFOUR SRC_CRYPTO += %D%/crypto/arcfour-generic.c else SRC_CRYPTO += %D%/crypto/arcfour-openssl.c endif if OPENSSL_WITH_MD5 SRC_CRYPTO += %D%/crypto/md5-openssl.c else SRC_CRYPTO += %D%/crypto/md5-generic.c endif if OPENSSL_WITH_SHA1 SRC_CRYPTO += %D%/crypto/sha1-openssl.c else SRC_CRYPTO += %D%/crypto/sha1-generic.c endif if OPENSSL_WITH_SHA256 SRC_CRYPTO += %D%/crypto/sha256-openssl.c endif if OPENSSL_WITH_CMAC SRC_CRYPTO += %D%/crypto/mac-omac1-openssl.c endif if OPENSSL_WITH_AES SRC_CRYPTO += %D%/crypto/aes-128-cbc-openssl.c endif endif if !OPENSSL_WITH_CMAC if !GCRYPT_WITH_CMAC SRC_CRYPTO += %D%/crypto/mac-omac1-generic.c endif endif if !OPENSSL_WITH_AES if !GCRYPT_WITH_AES SRC_CRYPTO += %D%/crypto/aes-128-cbc-generic.c endif endif libaccrypto_la_SOURCES = $(SRC_CRYPTO) libaccrypto_la_CFLAGS = $(COMMON_CFLAGS) $(PCRE_CFLAGS) $(PCRE2_CFLAGS) libaccrypto_la_LIBADD = $(PCRE_LIBS) $(PCRE2_LIBS) $(LIBAIRCRACK_OSDEP_LIBS) $(CRYPTO_LDFLAGS) $(CRYPTO_LIBS) libcowpatty_la_SOURCES = $(SRC_COW) libcowpatty_la_CFLAGS = $(COMMON_CFLAGS) $(LIBCOW_CFLAGS) if !STATIC_CRYPTO libcowpatty_la_LIBADD = $(COMMON_LDADD) endif libptw_la_SOURCES = $(SRC_PTW) libptw_la_CFLAGS = $(COMMON_CFLAGS) if !STATIC_CRYPTO libptw_la_LIBADD = $(COMMON_LDADD) endif libradiotap_la_SOURCES = $(SRC_RADIOTAP) libradiotap_la_LDFLAGS = -no-undefined ######################################################################## # Aircrack Support Library # ######################################################################## if ARM TRAMPOLINE = %D%/libac/cpu/trampoline_arm.c endif if PPC TRAMPOLINE = %D%/libac/cpu/trampoline_ppc.c endif if X86 TRAMPOLINE = %D%/libac/cpu/trampoline_x86.c endif if !ARM if !PPC if !X86 TRAMPOLINE = %D%/libac/cpu/trampoline_stubs.c endif endif endif if HAVE_HWLOC CPUSET = %D%/libac/cpu/cpuset_hwloc.c endif if !HAVE_HWLOC CPUSET = %D%/libac/cpu/cpuset_pthread.c endif if INCLUDE_COMPAT_STRLCAT SRC_LIBAC += %D%/libac/support/strlcat.c endif if INCLUDE_COMPAT_STRLCPY SRC_LIBAC += %D%/libac/support/strlcpy.c endif libaircrack_la_SOURCES = $(SRC_LIBAC) $(TRAMPOLINE) $(CPUSET) libaircrack_la_CFLAGS = $(COMMON_CFLAGS) $(PCRE_CFLAGS) $(PCRE2_CFLAGS) \ "-DLIBAIRCRACK_CE_WPA_PATH=\"$(LIBAIRCRACK_CE_WPA_PATH)\"" \ "-DABS_TOP_SRCDIR=\"$(abs_top_srcdir)\"" \ "-DABS_TOP_BUILDDIR=\"$(abs_top_builddir)\"" \ "-DLIBDIR=\"$(libdir)\"" libaircrack_la_LIBADD = $(COMMON_LDADD) $(LIBAIRCRACK_OSDEP_LIBS) $(PCRE_LIBS) $(PCRE2_LIBS) $(CRYPTO_LDFLAGS) $(CRYPTO_LIBS) if CYGWIN libaircrack_la_LIBADD += -lshlwapi endif if STATIC_BUILD libaircrack_la_CFLAGS += -DSTATIC_BUILD endif if HAVE_HWLOC libaircrack_la_CFLAGS += $(HWLOC_CFLAGS) if !CYGWIN if !STATIC_HWLOC libaircrack_la_LIBADD += $(HWLOC_LIBS) endif endif if CYGWIN if !STATIC_HWLOC libaircrack_la_LIBADD += $(HWLOC_LIBS) endif endif endif ######################################################################## # Aircrack Crypto Engine for WEP # ######################################################################## libaircrack_ce_wep_la_SOURCES = $(SRC_CE_WEP) libaircrack_ce_wep_la_CFLAGS = $(COMMON_CFLAGS) libaircrack_ce_wep_la_LIBADD = $(CRYPTO_LDFLAGS) $(CRYPTO_LIBS) ######################################################################## # Aircrack Crypto Engine for WPA # ######################################################################## # Intel/AMD libaircrack_ce_wpa_x86_avx512_la_SOURCES = $(SRC_CE_WPA) libaircrack_ce_wpa_x86_avx512_la_CFLAGS = $(x86_avx512_cflags) -DSIMD_CORE -DJOHN_AVX512F $(PTHREAD_CFLAGS) $(CRYPTO_CFLAGS) $(ZLIB_CFLAGS) libaircrack_ce_wpa_x86_avx512_la_LDFLAGS = -release $(LT_VER) -no-undefined if !STATIC_CRYPTO libaircrack_ce_wpa_x86_avx512_la_LIBADD = $(LIBACCRYPTO_LIBS) $(PTHREAD_LIBS) $(CRYPTO_LDFLAGS) $(CRYPTO_LIBS) $(ZLIB_LIBS) endif libaircrack_ce_wpa_x86_avx2_la_SOURCES = $(SRC_CE_WPA) libaircrack_ce_wpa_x86_avx2_la_CFLAGS = $(x86_avx2_cflags) -DSIMD_CORE -DJOHN_AVX2 $(PTHREAD_CFLAGS) $(CRYPTO_CFLAGS) $(ZLIB_CFLAGS) libaircrack_ce_wpa_x86_avx2_la_LDFLAGS = -release $(LT_VER) -no-undefined if !STATIC_CRYPTO libaircrack_ce_wpa_x86_avx2_la_LIBADD = $(LIBACCRYPTO_LIBS) $(PTHREAD_LIBS) $(CRYPTO_LDFLAGS) $(CRYPTO_LIBS) $(ZLIB_LIBS) endif libaircrack_ce_wpa_x86_avx_la_SOURCES = $(SRC_CE_WPA) libaircrack_ce_wpa_x86_avx_la_CFLAGS = $(x86_avx_cflags) -DSIMD_CORE -DJOHN_AVX $(PTHREAD_CFLAGS) $(CRYPTO_CFLAGS) $(ZLIB_CFLAGS) libaircrack_ce_wpa_x86_avx_la_LDFLAGS = -release $(LT_VER) -no-undefined if !STATIC_CRYPTO libaircrack_ce_wpa_x86_avx_la_LIBADD = $(LIBACCRYPTO_LIBS) $(PTHREAD_LIBS) $(CRYPTO_LDFLAGS) $(CRYPTO_LIBS) $(ZLIB_LIBS) endif libaircrack_ce_wpa_x86_sse2_la_SOURCES = $(SRC_CE_WPA) libaircrack_ce_wpa_x86_sse2_la_CFLAGS = $(x86_sse2_cflags) -DSIMD_CORE -DJOHN_SSE2 $(PTHREAD_CFLAGS) $(CRYPTO_CFLAGS) $(ZLIB_CFLAGS) libaircrack_ce_wpa_x86_sse2_la_LDFLAGS = -release $(LT_VER) -no-undefined if !STATIC_CRYPTO libaircrack_ce_wpa_x86_sse2_la_LIBADD = $(LIBACCRYPTO_LIBS) $(PTHREAD_LIBS) $(CRYPTO_LDFLAGS) $(CRYPTO_LIBS) $(ZLIB_LIBS) endif # ARM/AARCH64 libaircrack_ce_wpa_arm_neon_la_SOURCES = $(SRC_CE_WPA) libaircrack_ce_wpa_arm_neon_la_CFLAGS = $(arm_neon_cflags) -DSIMD_CORE -DHAS_NEON $(PTHREAD_CFLAGS) $(CRYPTO_CFLAGS) $(ZLIB_CFLAGS) libaircrack_ce_wpa_arm_neon_la_LDFLAGS = -release $(LT_VER) -no-undefined if !STATIC_CRYPTO libaircrack_ce_wpa_arm_neon_la_LIBADD = $(LIBACCRYPTO_LIBS) $(PTHREAD_LIBS) $(CRYPTO_LDFLAGS) $(CRYPTO_LIBS) $(ZLIB_LIBS) endif # PowerPC libaircrack_ce_wpa_ppc_altivec_la_SOURCES = $(SRC_CE_WPA) libaircrack_ce_wpa_ppc_altivec_la_CFLAGS = $(ppc_altivec_cflags) -DSIMD_CORE -DHAS_ALTIVEC=1 -DJOHN_ALTIVEC $(PTHREAD_CFLAGS) $(CRYPTO_CFLAGS) $(ZLIB_CFLAGS) libaircrack_ce_wpa_ppc_altivec_la_LDFLAGS = -release $(LT_VER) -no-undefined if !STATIC_CRYPTO libaircrack_ce_wpa_ppc_altivec_la_LIBADD = $(LIBACCRYPTO_LIBS) $(PTHREAD_LIBS) $(CRYPTO_LDFLAGS) $(CRYPTO_LIBS) $(ZLIB_LIBS) endif libaircrack_ce_wpa_ppc_power8_la_SOURCES = $(SRC_CE_WPA) libaircrack_ce_wpa_ppc_power8_la_CFLAGS = $(ppc_altivec_cflags) -DSIMD_CORE -DHAS_ALTIVEC=1 -DJOHN_ALTIVEC -DJOHN_POWER8 $(PTHREAD_CFLAGS) $(CRYPTO_CFLAGS) $(ZLIB_CFLAGS) libaircrack_ce_wpa_ppc_power8_la_LDFLAGS = -release $(LT_VER) -no-undefined if !STATIC_CRYPTO libaircrack_ce_wpa_ppc_power8_la_LIBADD = $(LIBACCRYPTO_LIBS) $(PTHREAD_LIBS) $(CRYPTO_LDFLAGS) $(CRYPTO_LIBS) $(ZLIB_LIBS) endif # Generic library libaircrack_ce_wpa_la_CFLAGS = $(PTHREAD_CFLAGS) $(CRYPTO_CFLAGS) $(ZLIB_CFLAGS) libaircrack_ce_wpa_la_SOURCES = $(SRC_CE_WPA) libaircrack_ce_wpa_la_LDFLAGS = -release $(LT_VER) -no-undefined if !STATIC_CRYPTO libaircrack_ce_wpa_la_LIBADD = $(LIBACCRYPTO_LIBS) $(PTHREAD_LIBS) $(CRYPTO_LDFLAGS) $(CRYPTO_LIBS) $(ZLIB_LIBS) endif # Build librarie(s) lib_LTLIBRARIES += libaircrack-ce-wpa.la if ARM if NEON lib_LTLIBRARIES += libaircrack-ce-wpa-arm-neon.la endif endif if PPC if ALTIVEC lib_LTLIBRARIES += libaircrack-ce-wpa-ppc-altivec.la endif if POWER8 lib_LTLIBRARIES += libaircrack-ce-wpa-ppc-power8.la endif endif if X86 if AVX512F lib_LTLIBRARIES += libaircrack-ce-wpa-x86-avx512.la endif lib_LTLIBRARIES += libaircrack-ce-wpa-x86-avx2.la libaircrack-ce-wpa-x86-avx.la libaircrack-ce-wpa-x86-sse2.la endif noinst_LTLIBRARIES += libaircrack-ce-wep.la libcowpatty.la libaccrypto.la libptw.la libaircrack.la libradiotap.la EXTRA_DIST += %D%/ce-wep/uniqueiv.c \ %D%/ce-wpa/crypto_engine.c \ %D%/ce-wpa/memory.c \ %D%/ce-wpa/simd-intrinsics.c \ %D%/ce-wpa/wpapsk.c \ %D%/cowpatty/cowpatty.c \ %D%/crypto/aes-128-cbc-gcrypt.c \ %D%/crypto/aes-128-cbc-openssl.c \ %D%/crypto/arcfour-gcrypt.c \ %D%/crypto/arcfour-generic.c \ %D%/crypto/crypto.c \ %D%/crypto/md5.c \ %D%/crypto/md5-gcrypt.c \ %D%/crypto/md5-generic.c \ %D%/crypto/md5-openssl.c \ %D%/crypto/mac-hmac-md5-generic.c \ %D%/crypto/mac-hmac-sha1-generic.c \ %D%/crypto/mac-hmac-sha256-generic.c \ %D%/crypto/mac-omac1-gcrypt.c \ %D%/crypto/mac-omac1-generic.c \ %D%/crypto/mac-omac1-openssl.c \ %D%/crypto/sha1.c \ %D%/crypto/sha1-git.c \ %D%/crypto/sha1-gcrypt.c \ %D%/crypto/sha1-generic.c \ %D%/crypto/sha1-openssl.c \ %D%/crypto/sha256.c \ %D%/crypto/sha256-openssl.c \ %D%/crypto/sha256-gcrypt.c \ %D%/libac/adt/avl_tree.c \ %D%/libac/adt/circular_buffer.c \ %D%/libac/adt/circular_queue.c \ %D%/libac/cpu/cpuset_hwloc.c \ %D%/libac/cpu/cpuset_pthread.c \ %D%/libac/cpu/simd_cpuid.c \ %D%/libac/cpu/trampoline_arm.c \ %D%/libac/cpu/trampoline_ppc.c \ %D%/libac/cpu/trampoline_stubs.c \ %D%/libac/cpu/trampoline_x86.c \ %D%/libac/support/common.c \ %D%/libac/support/communications.c \ %D%/libac/support/crypto_engine_loader.c \ %D%/libac/support/fragments.c \ %D%/libac/support/mcs_index_rates.c \ %D%/libac/tui/console.c \ %D%/libac/utf8/verifyssid.c \ %D%/osdep/aircrack_ng_airpcap.h \ %D%/osdep/airpcap.c \ %D%/osdep/common.c \ %D%/osdep/crctable_osdep.h \ %D%/osdep/cygwin.c \ %D%/osdep/cygwin.h \ %D%/osdep/cygwin_tap.c \ %D%/osdep/darwin.c \ %D%/osdep/darwin_tap.c \ %D%/osdep/dummy.c \ %D%/osdep/dummy_tap.c \ %D%/osdep/file.c \ %D%/osdep/freebsd.c \ %D%/osdep/freebsd_tap.c \ %D%/osdep/linux.c \ %D%/osdep/linux_tap.c \ %D%/osdep/netbsd.c \ %D%/osdep/netbsd_tap.c \ %D%/osdep/network.c \ %D%/osdep/openbsd.c \ %D%/osdep/openbsd_tap.c \ %D%/osdep/osdep.c \ %D%/osdep/tap-win32/common.h \ %D%/ptw/aircrack-ptw-lib.c \ %D%/radiotap/COPYING \ %D%/radiotap/parse.c \ %D%/radiotap/platform.h \ %D%/radiotap/radiotap.c \ %D%/radiotap/radiotap.h \ %D%/radiotap/radiotap_iter.h