aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2016-11-06 15:43:31 +0100
committerAndreas Schneider <asn@cryptomilk.org>2018-06-29 17:08:54 +0200
commit1642cec280038663d6ecc4119a23e2f98d06a558 (patch)
tree4e18519faed427041dbbb263e45e2a164aadae9a
parent2f1c6668e7015d5718703292617a0826f509866b (diff)
downloadlibssh-1642cec280038663d6ecc4119a23e2f98d06a558.tar.gz
libssh-1642cec280038663d6ecc4119a23e2f98d06a558.tar.xz
libssh-1642cec280038663d6ecc4119a23e2f98d06a558.zip
cmake: Use configure check for CRYPTO_ctr128_encrypt
Cherry-picked from 3daf1760a18c091159338fc9077fa71bfbd726a1 Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--ConfigureChecks.cmake4
-rw-r--r--config.h.cmake3
-rw-r--r--src/libcrypto.c4
3 files changed, 9 insertions, 2 deletions
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 9f2c8c73..0e2c2cc7 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -91,6 +91,10 @@ if (OPENSSL_FOUND)
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
check_include_file(openssl/ecdsa.h HAVE_OPENSSL_ECDSA_H)
+
+ set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
+ set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
+ check_function_exists(CRYPTO_ctr128_encrypt HAVE_OPENSSL_CRYPTO_CTR128_ENCRYPT)
endif()
if (CMAKE_HAVE_PTHREAD_H)
diff --git a/config.h.cmake b/config.h.cmake
index 0685f10c..f2288b60 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -76,6 +76,9 @@
/*************************** FUNCTIONS ***************************/
+/* Define to 1 if you have the `CRYPTO_ctr128_encrypt' function. */
+#cmakedefine HAVE_OPENSSL_CRYPTO_CTR128_ENCRYPT 1
+
/* Define to 1 if you have the `snprintf' function. */
#cmakedefine HAVE_SNPRINTF 1
diff --git a/src/libcrypto.c b/src/libcrypto.c
index c8e99a40..bcd5ba15 100644
--- a/src/libcrypto.c
+++ b/src/libcrypto.c
@@ -458,12 +458,12 @@ static void aes_ctr128_encrypt(struct ssh_cipher_struct *cipher, void *in, void
* Same for num, which is being used to store the current offset in blocksize in CTR
* function.
*/
-# if OPENSSL_VERSION_NUMBER >= 0x10100000L
+#ifdef HAVE_OPENSSL_CRYPTO_CTR128_ENCRYPT
CRYPTO_ctr128_encrypt(in, out, len, cipher->key, cipher->IV, tmp_buffer,
&num, (block128_f)AES_encrypt);
# else
AES_ctr128_encrypt(in, out, len, cipher->key, cipher->IV, tmp_buffer, &num);
-# endif /* OPENSSL_VERSION_NUMBER >= 0x10100000L */
+#endif /* HAVE_OPENSSL_CRYPTO_CTR128_ENCRYPT */
}
#endif /* BROKEN_AES_CTR */
#endif /* HAS_AES */