diff --git a/configure.ac b/configure.ac index 0f0f12ea..5b9f82d7 100644 --- a/configure.ac +++ b/configure.ac @@ -50,6 +50,11 @@ AC_CHECK_LIB(gnutls, gnutls_pkcs11_reinit, [ AC_DEFINE([HAVE_PKCS11], [], [PKCS11 detected in gnutls]) ]) +if ! $PKG_CONFIG --atleast-version=3.0 nettle; then + AC_DEFINE([NETTLE_OLD_BASE64_API], [1], + [nettle uses the pre-3.x base64 API]) +fi + AC_ARG_WITH(protobuf, AS_HELP_STRING([--without-protobuf], [use the included protobuf library]), test_for_protobuf=$withval, diff --git a/src/base64-helper.c b/src/base64-helper.c index 9140b193..23c34858 100644 --- a/src/base64-helper.c +++ b/src/base64-helper.c @@ -44,7 +44,17 @@ oc_base64_decode(const uint8_t *src, unsigned src_length, base64_decode_init(&ctx); +#ifdef NETTLE_OLD_BASE64_API + { + unsigned int len = *dst_length; + ret = base64_decode_update(&ctx, &len, dst, src_length, src); + if (ret != 0) + *dst_length = len; + } +#else ret = base64_decode_update(&ctx, dst_length, dst, src_length, src); +#endif + if (ret == 0) return 0;