| 1 |
# =========================================================================== |
| 2 |
# https://www.gnu.org/software/autoconf-archive/ax_lib_gcrypt.html |
| 3 |
# =========================================================================== |
| 4 |
# |
| 5 |
# SYNOPSIS |
| 6 |
# |
| 7 |
# AX_LIB_GCRYPT([yes|no|auto]) |
| 8 |
# |
| 9 |
# DESCRIPTION |
| 10 |
# |
| 11 |
# Searches for the 'gcrypt' library with the --with... option. |
| 12 |
# |
| 13 |
# If found, define HAVE_GCRYPT and macro GCRYPT_LIBS and GCRYPT_CFLAGS. |
| 14 |
# Also defines GCRYPT_WITH_<algo> for the algorithms found available. |
| 15 |
# Possible algorithms are: AES ARCFOUR BLOWFISH CAST5 DES IDEA RFC2268 |
| 16 |
# SERPENT TWOFISH CRC HAVAL MD2 MD4 MD5 RMD160 SHA0 SHA1 SHA224 SHA256 |
| 17 |
# SHA384 SHA512 TIGER WHIRLPOOL DSA ELGAMAL RSA |
| 18 |
# |
| 19 |
# The argument is used if no --with...-gcrypt option is set. Value "yes" |
| 20 |
# requires the configuration by default. Value "no" does not require it by |
| 21 |
# default. Value "auto" configures the library only if available. |
| 22 |
# |
| 23 |
# See also AX_LIB_BEECRYPT and AX_LIB_CRYPTO. |
| 24 |
# |
| 25 |
# LICENSE |
| 26 |
# |
| 27 |
# Copyright (c) 2009 Fabien Coelho <[email protected]> |
| 28 |
# |
| 29 |
# Copying and distribution of this file, with or without modification, are |
| 30 |
# permitted in any medium without royalty provided the copyright notice |
| 31 |
# and this notice are preserved. This file is offered as-is, without any |
| 32 |
# warranty. |
| 33 |
|
| 34 |
#serial 12 |
| 35 |
|
| 36 |
# AX_CHECK_GCRYPT_ALGO([algo]) |
| 37 |
# generate convenient defines for each algorithm |
| 38 |
AC_DEFUN([AX_CHECK_GCRYPT_ALGO],[ |
| 39 |
AC_REQUIRE([AC_PROG_EGREP]) |
| 40 |
AC_MSG_CHECKING([for $1 in gcrypt]) |
| 41 |
if echo $gcrypt_algos | $EGREP -i ":.*( $1 | $1$)" > /dev/null ; then |
| 42 |
AC_DEFINE([GCRYPT_WITH_$1],[1],[Algorithm $1 in gcrypt library]) |
| 43 |
AC_SUBST([GCRYPT_WITH_$1], [1]) |
| 44 |
AC_MSG_RESULT([yes]) |
| 45 |
else |
| 46 |
AC_MSG_RESULT([no]) |
| 47 |
fi |
| 48 |
]) |
| 49 |
|
| 50 |
# AX_LIB_GCRYPT([yes|no|auto]) |
| 51 |
AC_DEFUN([AX_LIB_GCRYPT],[ |
| 52 |
AC_MSG_CHECKING([whether gcrypt is enabled]) |
| 53 |
AC_ARG_WITH([gcrypt],[ --with-gcrypt require gcrypt library |
| 54 |
--without-gcrypt disable gcrypt library],[ |
| 55 |
AC_MSG_RESULT([$withval]) |
| 56 |
ac_with_gcrypt=$withval |
| 57 |
],[ |
| 58 |
AC_MSG_RESULT($1) |
| 59 |
ac_with_gcrypt=$1 |
| 60 |
]) |
| 61 |
if test "$ac_with_gcrypt" = "yes" -o "$ac_with_gcrypt" = "auto" ; then |
| 62 |
AM_PATH_LIBGCRYPT([1.2.0],[ |
| 63 |
AC_DEFINE([HAVE_GCRYPT],[1],[Gcrypt library is available]) |
| 64 |
HAVE_GCRYPT=1 |
| 65 |
# checking for available algorithms... |
| 66 |
gcrypt_algos=`$LIBGCRYPT_CONFIG --algorithms` |
| 67 |
# ciphers |
| 68 |
# this does not work with a "for" loop: nothing generated in config.h:-( |
| 69 |
AX_CHECK_GCRYPT_ALGO([AES]) |
| 70 |
AX_CHECK_GCRYPT_ALGO([ARCFOUR]) |
| 71 |
AX_CHECK_GCRYPT_ALGO([BLOWFISH]) |
| 72 |
AX_CHECK_GCRYPT_ALGO([CAST5]) |
| 73 |
AX_CHECK_GCRYPT_ALGO([DES]) |
| 74 |
AX_CHECK_GCRYPT_ALGO([IDEA]) |
| 75 |
AX_CHECK_GCRYPT_ALGO([RFC2268]) |
| 76 |
AX_CHECK_GCRYPT_ALGO([SERPENT]) |
| 77 |
AX_CHECK_GCRYPT_ALGO([TWOFISH]) |
| 78 |
# digests |
| 79 |
AX_CHECK_GCRYPT_ALGO([CRC]) |
| 80 |
AX_CHECK_GCRYPT_ALGO([HAVAL]) |
| 81 |
AX_CHECK_GCRYPT_ALGO([MD2]) |
| 82 |
AX_CHECK_GCRYPT_ALGO([MD4]) |
| 83 |
AX_CHECK_GCRYPT_ALGO([MD5]) |
| 84 |
AX_CHECK_GCRYPT_ALGO([RMD160]) |
| 85 |
AX_CHECK_GCRYPT_ALGO([SHA0]) |
| 86 |
AX_CHECK_GCRYPT_ALGO([SHA1]) |
| 87 |
AX_CHECK_GCRYPT_ALGO([SHA224]) |
| 88 |
AX_CHECK_GCRYPT_ALGO([SHA256]) |
| 89 |
AX_CHECK_GCRYPT_ALGO([SHA384]) |
| 90 |
AX_CHECK_GCRYPT_ALGO([SHA512]) |
| 91 |
AX_CHECK_GCRYPT_ALGO([TIGER]) |
| 92 |
AX_CHECK_GCRYPT_ALGO([WHIRLPOOL]) |
| 93 |
# others |
| 94 |
AX_CHECK_GCRYPT_ALGO([DSA]) |
| 95 |
AX_CHECK_GCRYPT_ALGO([ELGAMAL]) |
| 96 |
AX_CHECK_GCRYPT_ALGO([RSA]) |
| 97 |
# CMAC support |
| 98 |
AC_MSG_CHECKING([for CMAC_AES in gcrypt]) |
| 99 |
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gcrypt.h>]], [[ |
| 100 |
int ok = GCRY_MAC_CMAC_AES; |
| 101 |
(void)ok; |
| 102 |
]])],[ |
| 103 |
AC_MSG_RESULT([yes]) |
| 104 |
AC_DEFINE([GCRYPT_WITH_CMAC_AES],[1],[Algorithm CMAC_AES in gcrypt library]) |
| 105 |
AC_SUBST([GCRYPT_WITH_CMAC_AES], [1]) |
| 106 |
HAVE_CMAC=yes |
| 107 |
], [ |
| 108 |
AC_MSG_RESULT([no]) |
| 109 |
HAVE_CMAC=no |
| 110 |
]) |
| 111 |
# conclusion |
| 112 |
GCRYPT_CFLAGS=`$LIBGCRYPT_CONFIG --cflags` |
| 113 |
GCRYPT_LIBS=`$LIBGCRYPT_CONFIG --libs` |
| 114 |
AC_SUBST(GCRYPT_CFLAGS) |
| 115 |
AC_SUBST(GCRYPT_LIBS) |
| 116 |
],[ |
| 117 |
# complain only if explicitly required |
| 118 |
if test "$ac_with_gcrypt" = "yes" ; then |
| 119 |
AC_MSG_ERROR([cannot configure required gcrypt library]) |
| 120 |
fi |
| 121 |
]) |
| 122 |
fi |
| 123 |
]) |