| 1 |
AC_DEFUN([ACX_OPENSSL_GOST],[ |
| 2 |
AC_MSG_CHECKING(for OpenSSL GOST support) |
| 3 |
|
| 4 |
tmp_CPPFLAGS=$CPPFLAGS |
| 5 |
tmp_LIBS=$LIBS |
| 6 |
|
| 7 |
CPPFLAGS="$CPPFLAGS $CRYPTO_INCLUDES" |
| 8 |
LIBS="$CRYPTO_LIBS $LIBS" |
| 9 |
|
| 10 |
AC_LANG_PUSH([C]) |
| 11 |
AC_CACHE_VAL([acx_cv_lib_openssl_gost_support],[ |
| 12 |
acx_cv_lib_openssl_gost_support=no |
| 13 |
AC_RUN_IFELSE([ |
| 14 |
AC_LANG_SOURCE([[ |
| 15 |
#include <openssl/engine.h> |
| 16 |
#include <openssl/crypto.h> |
| 17 |
#include <openssl/opensslv.h> |
| 18 |
int main() |
| 19 |
{ |
| 20 |
ENGINE* eg; |
| 21 |
const EVP_MD* EVP_GOST_34_11; |
| 22 |
|
| 23 |
/* Initialise OpenSSL */ |
| 24 |
OpenSSL_add_all_algorithms(); |
| 25 |
|
| 26 |
/* Load engines */ |
| 27 |
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) |
| 28 |
ENGINE_load_builtin_engines(); |
| 29 |
#else |
| 30 |
OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_ALL_BUILTIN | OPENSSL_INIT_LOAD_CONFIG, NULL); |
| 31 |
#endif |
| 32 |
|
| 33 |
/* Initialise the GOST engine */ |
| 34 |
eg = ENGINE_by_id("gost"); |
| 35 |
if (eg == NULL) |
| 36 |
return 1; |
| 37 |
if (ENGINE_init(eg) <= 0) |
| 38 |
return 1; |
| 39 |
|
| 40 |
/* better than digest_gost */ |
| 41 |
EVP_GOST_34_11 = ENGINE_get_digest(eg, NID_id_GostR3411_94); |
| 42 |
if (EVP_GOST_34_11 == NULL) |
| 43 |
return 1; |
| 44 |
|
| 45 |
/* from the openssl.cnf */ |
| 46 |
if (ENGINE_register_pkey_asn1_meths(eg) <= 0) |
| 47 |
return 1; |
| 48 |
if (ENGINE_ctrl_cmd_string(eg, |
| 49 |
"CRYPT_PARAMS", |
| 50 |
"id-Gost28147-89-CryptoPro-A-ParamSet", |
| 51 |
0) <= 0) |
| 52 |
return 1; |
| 53 |
|
| 54 |
return 0; |
| 55 |
} |
| 56 |
]]) |
| 57 |
],[ |
| 58 |
AC_MSG_RESULT([Found GOST engine]) |
| 59 |
acx_cv_lib_openssl_gost_support=yes |
| 60 |
],[ |
| 61 |
AC_MSG_RESULT([Cannot find GOST engine]) |
| 62 |
acx_cv_lib_openssl_gost_support=no |
| 63 |
],[ |
| 64 |
AC_MSG_WARN([Cannot test, assuming GOST engine]) |
| 65 |
acx_cv_lib_openssl_gost_support=yes |
| 66 |
]) |
| 67 |
]) |
| 68 |
AC_LANG_POP([C]) |
| 69 |
|
| 70 |
CPPFLAGS=$tmp_CPPFLAGS |
| 71 |
LIBS=$tmp_LIBS |
| 72 |
have_lib_openssl_gost_support="${acx_cv_lib_openssl_gost_support}" |
| 73 |
]) |