curve25519: refactor mbedTLS code to remove code duplication

Signed-off-by: Praneeth Sarode <praneethsarode@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
Praneeth Sarode
2025-03-21 22:29:30 +05:30
committed by Jakub Jelen
parent 49a355c272
commit a5e9529ca7
2 changed files with 64 additions and 80 deletions

View File

@@ -236,20 +236,13 @@ if (MBEDTLS_FOUND)
set(CMAKE_REQUIRED_INCLUDES "${MBEDTLS_INCLUDE_DIR}/mbedtls")
check_include_file(chacha20.h HAVE_MBEDTLS_CHACHA20_H)
check_include_file(poly1305.h HAVE_MBEDTLS_POLY1305_H)
if (MBEDTLS_VERSION VERSION_LESS "3.0.0")
check_symbol_exists(MBEDTLS_ECP_DP_CURVE25519_ENABLED "config.h" HAVE_MBEDTLS_CURVE25519)
else()
check_symbol_exists(MBEDTLS_ECP_DP_CURVE25519_ENABLED "mbedtls_config.h" HAVE_MBEDTLS_CURVE25519)
endif()
set(CMAKE_REQUIRED_INCLUDES "${MBEDTLS_INCLUDE_DIR}")
check_c_source_compiles("
#include <mbedtls/ecp.h>
int main() {
#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED)
return 0;
#else
#error \"X25519 not supported\"
#endif
}
" HAVE_MBEDTLS_CURVE25519)
if (WITH_BLOWFISH_CIPHER)
check_include_file(blowfish.h HAVE_BLOWFISH)
endif()