diff --git a/meson.build b/meson.build index cc7007e280..57f9b316f6 100644 --- a/meson.build +++ b/meson.build @@ -437,7 +437,7 @@ foreach t : test_sha1 sha1_dep = libsha1_dep endif elif t == 'libnettle' - nettle_dep = dependency('nettle', required: false) + nettle_dep = dependency('nettle', version: '>= 2.6', required: false) if nettle_dep.found() sha1_found = true sha1_dep = nettle_dep diff --git a/os/xsha1.c b/os/xsha1.c index 0a8b10b540..f71b1ace75 100644 --- a/os/xsha1.c +++ b/os/xsha1.c @@ -152,7 +152,8 @@ x_sha1_final(void *ctx, unsigned char result[20]) #elif defined(HAVE_SHA1_IN_LIBNETTLE) /* Use libnettle for SHA1 */ -#include +#include +#include void * x_sha1_init(void) @@ -175,7 +176,11 @@ x_sha1_update(void *ctx, void *data, int size) int x_sha1_final(void *ctx, unsigned char result[20]) { +#if NETTLE_VERSION_MAJOR < 4 sha1_digest(ctx, 20, result); +#else + sha1_digest(ctx, result); +#endif free(ctx); return 1; }