| 1 |
AC_DEFUN([ACX_CRYPTO_BACKEND],[ |
| 2 |
|
| 3 |
# First check if we want to support ECC and GOST |
| 4 |
|
| 5 |
AC_ARG_ENABLE(ecc, |
| 6 |
AC_HELP_STRING([--enable-ecc], |
| 7 |
[Enable support for ECC (default detect)] |
| 8 |
), |
| 9 |
[enable_ecc="${enableval}"], |
| 10 |
[enable_ecc="detect"] |
| 11 |
) |
| 12 |
|
| 13 |
AC_ARG_ENABLE(gost, |
| 14 |
AC_HELP_STRING([--enable-gost], |
| 15 |
[Enable support for GOST (default detect)] |
| 16 |
), |
| 17 |
[enable_gost="${enableval}"], |
| 18 |
[enable_gost="detect"] |
| 19 |
) |
| 20 |
|
| 21 |
# Add Eddsa check |
| 22 |
|
| 23 |
AC_ARG_ENABLE(eddsa, |
| 24 |
AC_HELP_STRING([--enable-eddsa], |
| 25 |
[Enable support for EDDSA (default detect)] |
| 26 |
), |
| 27 |
[enable_eddsa="${enableval}"], |
| 28 |
[enable_eddsa="detect"] |
| 29 |
) |
| 30 |
|
| 31 |
# Second check for the FIPS 140-2 mode |
| 32 |
|
| 33 |
AC_ARG_ENABLE(fips, |
| 34 |
AC_HELP_STRING([--enable-fips], |
| 35 |
[Enable support for FIPS 140-2 mode (default disabled)] |
| 36 |
), |
| 37 |
[enable_fips="${enableval}"], |
| 38 |
[enable_fips="no"] |
| 39 |
) |
| 40 |
AC_MSG_CHECKING(for FIPS 140-2 mode) |
| 41 |
if test "x${enable_fips}" = "xyes"; then |
| 42 |
AC_MSG_RESULT(yes) |
| 43 |
AC_DEFINE_UNQUOTED( |
| 44 |
[WITH_FIPS], |
| 45 |
[], |
| 46 |
[Compile with FIPS 140-2 mode] |
| 47 |
) |
| 48 |
else |
| 49 |
AC_MSG_RESULT(no) |
| 50 |
fi |
| 51 |
|
| 52 |
# Then check what crypto library we want to use |
| 53 |
|
| 54 |
AC_ARG_WITH(crypto-backend, |
| 55 |
AC_HELP_STRING([--with-crypto-backend], |
| 56 |
[Select crypto backend (openssl|botan)] |
| 57 |
), |
| 58 |
[crypto_backend="${withval}"], |
| 59 |
[crypto_backend="openssl"] |
| 60 |
) |
| 61 |
|
| 62 |
AC_MSG_CHECKING(for crypto backend) |
| 63 |
|
| 64 |
if test "x${crypto_backend}" = "xopenssl"; then |
| 65 |
AC_MSG_RESULT(OpenSSL) |
| 66 |
|
| 67 |
if test "x${enable_fips}" = "xyes"; then |
| 68 |
ACX_OPENSSL(1,0,1) |
| 69 |
else |
| 70 |
ACX_OPENSSL(1,0,0) |
| 71 |
fi |
| 72 |
|
| 73 |
CRYPTO_INCLUDES=$OPENSSL_INCLUDES |
| 74 |
CRYPTO_LIBS=$OPENSSL_LIBS |
| 75 |
|
| 76 |
case "${enable_ecc}" in |
| 77 |
yes|detect) ACX_OPENSSL_ECC;; |
| 78 |
esac |
| 79 |
case "${enable_ecc}-${have_lib_openssl_ecc_support}" in |
| 80 |
yes-no) AC_MSG_ERROR([OpenSSL library has no ECC support]);; |
| 81 |
detect-*) enable_ecc="${have_lib_openssl_ecc_support}";; |
| 82 |
esac |
| 83 |
|
| 84 |
case "${enable_eddsa}" in |
| 85 |
yes|detect) ACX_OPENSSL_EDDSA;; |
| 86 |
esac |
| 87 |
case "${enable_eddsa}-${have_lib_openssl_ed25519_support}-${have_lib_openssl_ed448_support}" in |
| 88 |
yes*-no*) AC_MSG_ERROR([OpenSSL library has no EDDSA support]);; |
| 89 |
detect-yes-yes) enable_eddsa="yes";; |
| 90 |
detect*-no*) enable_eddsa="no";; |
| 91 |
esac |
| 92 |
|
| 93 |
case "${enable_gost}-${enable_fips}" in |
| 94 |
yes-yes) AC_MSG_ERROR([GOST is not FIPS approved]);; |
| 95 |
yes-no|detect-no) ACX_OPENSSL_GOST;; |
| 96 |
esac |
| 97 |
case "${enable_gost}-${have_lib_openssl_gost_support}" in |
| 98 |
yes-no) AC_MSG_ERROR([OpenSSL library has no GOST support]);; |
| 99 |
detect-*) enable_gost="${have_lib_openssl_gost_support}";; |
| 100 |
esac |
| 101 |
|
| 102 |
if test "x${enable_fips}" = "xyes"; then |
| 103 |
ACX_OPENSSL_FIPS |
| 104 |
else |
| 105 |
ACX_OPENSSL_EVPAESWRAP |
| 106 |
fi |
| 107 |
|
| 108 |
AC_DEFINE_UNQUOTED( |
| 109 |
[WITH_RAW_PSS], |
| 110 |
[1], |
| 111 |
[Compile with raw RSA PKCS PSS] |
| 112 |
) |
| 113 |
AC_DEFINE_UNQUOTED( |
| 114 |
[WITH_OPENSSL], |
| 115 |
[], |
| 116 |
[Compile with OpenSSL support] |
| 117 |
) |
| 118 |
|
| 119 |
elif test "x${crypto_backend}" = "xbotan"; then |
| 120 |
AC_MSG_RESULT(Botan) |
| 121 |
|
| 122 |
ACX_BOTAN(2,0,0) |
| 123 |
|
| 124 |
CRYPTO_INCLUDES=$BOTAN_CFLAGS |
| 125 |
CRYPTO_LIBS=$BOTAN_LIBS |
| 126 |
|
| 127 |
case "${enable_ecc}" in |
| 128 |
yes|detect) ACX_BOTAN_ECC;; |
| 129 |
esac |
| 130 |
case "${enable_ecc}-${have_lib_botan_ecc_support}" in |
| 131 |
yes-no) AC_MSG_ERROR([Botan library has no ECC support]);; |
| 132 |
detect-*) enable_ecc="${have_lib_botan_ecc_support}";; |
| 133 |
esac |
| 134 |
|
| 135 |
case "${enable_eddsa}" in |
| 136 |
yes|detect) ACX_BOTAN_EDDSA;; |
| 137 |
esac |
| 138 |
case "${enable_eddsa}-${have_lib_botan_eddsa_support}" in |
| 139 |
yes-no) AC_MSG_ERROR([Botan library has no EDDSA support]);; |
| 140 |
detect-*) enable_eddsa="${have_lib_botan_eddsa_support}";; |
| 141 |
esac |
| 142 |
|
| 143 |
case "${enable_gost}" in |
| 144 |
yes|detect) ACX_BOTAN_GOST;; |
| 145 |
esac |
| 146 |
case "${enable_gost}-${have_lib_botan_gost_support}" in |
| 147 |
yes-no) AC_MSG_ERROR([Botan library has no GOST support]);; |
| 148 |
detect-*) enable_gost="${have_lib_botan_gost_support}";; |
| 149 |
esac |
| 150 |
|
| 151 |
if test "x${enable_fips}" = "xyes"; then |
| 152 |
AC_MSG_ERROR([Botan does not support FIPS 140-2 mode]) |
| 153 |
fi |
| 154 |
|
| 155 |
ACX_BOTAN_RFC5649 |
| 156 |
ACX_BOTAN_RAWPSS |
| 157 |
|
| 158 |
AC_DEFINE_UNQUOTED( |
| 159 |
[WITH_BOTAN], |
| 160 |
[], |
| 161 |
[Compile with Botan support] |
| 162 |
) |
| 163 |
|
| 164 |
else |
| 165 |
AC_MSG_RESULT(Unknown) |
| 166 |
AC_MSG_ERROR([Crypto backend ${crypto_backend} not supported. Use openssl or botan.]) |
| 167 |
fi |
| 168 |
|
| 169 |
AC_MSG_CHECKING(for ECC support) |
| 170 |
if test "x${enable_ecc}" = "xyes"; then |
| 171 |
AC_MSG_RESULT(yes) |
| 172 |
AC_DEFINE_UNQUOTED( |
| 173 |
[WITH_ECC], |
| 174 |
[], |
| 175 |
[Compile with ECC support] |
| 176 |
) |
| 177 |
else |
| 178 |
AC_MSG_RESULT(no) |
| 179 |
fi |
| 180 |
AM_CONDITIONAL([WITH_ECC], [test "x${enable_ecc}" = "xyes"]) |
| 181 |
|
| 182 |
AC_MSG_CHECKING(for GOST support) |
| 183 |
if test "x${enable_gost}" = "xyes"; then |
| 184 |
AC_MSG_RESULT(yes) |
| 185 |
AC_DEFINE_UNQUOTED( |
| 186 |
[WITH_GOST], |
| 187 |
[], |
| 188 |
[Compile with GOST support] |
| 189 |
) |
| 190 |
else |
| 191 |
AC_MSG_RESULT(no) |
| 192 |
fi |
| 193 |
AM_CONDITIONAL([WITH_GOST], [test "x${enable_gost}" = "xyes"]) |
| 194 |
|
| 195 |
AC_MSG_CHECKING(for EDDSA support) |
| 196 |
if test "x${enable_eddsa}" = "xyes"; then |
| 197 |
AC_MSG_RESULT(yes) |
| 198 |
AC_DEFINE_UNQUOTED( |
| 199 |
[WITH_EDDSA], |
| 200 |
[], |
| 201 |
[Compile with EDDSA support] |
| 202 |
) |
| 203 |
else |
| 204 |
AC_MSG_RESULT(no) |
| 205 |
fi |
| 206 |
AM_CONDITIONAL([WITH_EDDSA], [test "x${enable_eddsa}" = "xyes"]) |
| 207 |
|
| 208 |
|
| 209 |
AC_SUBST(CRYPTO_INCLUDES) |
| 210 |
AC_SUBST(CRYPTO_LIBS) |
| 211 |
AM_CONDITIONAL([WITH_OPENSSL], [test "x${crypto_backend}" = "xopenssl"]) |
| 212 |
AM_CONDITIONAL([WITH_BOTAN], [test "x${crypto_backend}" = "xbotan"]) |
| 213 |
|
| 214 |
]) |