diff --git a/CMakeLists.txt b/CMakeLists.txt index 4193d45..ac3739f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,13 @@ pkg_check_modules(SPICE_PKGCONFIG REQUIRED hogweed ) +if (SPICE_PKGCONFIG_nettle_VERSION) + if (SPICE_PKGCONFIG_nettle_VERSION VERSION_GREATER_EQUAL "4.0") + message(STATUS "Using nettle >= 4.0 compatibility") + add_compile_definitions(USE_NETTLE_GE_4) + endif() +endif() + add_definitions(-D USE_NETTLE) add_compile_options( diff --git a/src/rsa.c b/src/rsa.c index 73fba92..a5f384b 100644 --- a/src/rsa.c +++ b/src/rsa.c @@ -62,7 +62,12 @@ static void sha1(uint8_t * hash, const uint8_t *data, unsigned int len) sha1_init(&ctx); sha1_update(&ctx, len, data); + +#if defined(USE_NETTLE_GE_4) + sha1_digest(&ctx, hash); +#else sha1_digest(&ctx, SHA1_HASH_LEN, hash); +#endif } static void oaep_mask(uint8_t * dest, size_t dest_len,