aboutsummaryrefslogtreecommitdiff
path: root/crypto/hash-nettle.c
diff options
context:
space:
mode:
authorDaniel P. Berrangé <berrange@redhat.com>2019-07-12 11:14:19 +0100
committerDaniel P. Berrangé <berrange@redhat.com>2019-07-19 12:48:22 +0100
commitf887849007312454574ebc1057a438beaa2916df (patch)
tree3eb356915aade4fad4600d6e56d90e0a318e3f0d /crypto/hash-nettle.c
parente8e67ca4c17f4d525330d2d6b9b0a3cd19174c06 (diff)
crypto: fix function signatures for nettle 2.7 vs 3
Nettle version 2.7.x used 'unsigned int' instead of 'size_t' for length parameters in functions. Use a local typedef so that we can build with the correct signature depending on nettle version, as we already do in the cipher code. Reported-by: Amol Surati <suratiamol@gmail.com> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Tested-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Diffstat (limited to 'crypto/hash-nettle.c')
-rw-r--r--crypto/hash-nettle.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/crypto/hash-nettle.c b/crypto/hash-nettle.c
index 96f186f442..6ffb9c3db7 100644
--- a/crypto/hash-nettle.c
+++ b/crypto/hash-nettle.c
@@ -26,12 +26,18 @@
#include <nettle/sha.h>
#include <nettle/ripemd160.h>
+#if CONFIG_NETTLE_VERSION_MAJOR < 3
+typedef unsigned int hash_length_t;
+#else
+typedef size_t hash_length_t;
+#endif
+
typedef void (*qcrypto_nettle_init)(void *ctx);
typedef void (*qcrypto_nettle_write)(void *ctx,
- unsigned int len,
+ hash_length_t len,
const uint8_t *buf);
typedef void (*qcrypto_nettle_result)(void *ctx,
- unsigned int len,
+ hash_length_t len,
uint8_t *buf);
union qcrypto_hash_ctx {
@@ -112,7 +118,7 @@ qcrypto_nettle_hash_bytesv(QCryptoHashAlgorithm alg,
size_t *resultlen,
Error **errp)
{
- int i;
+ size_t i;
union qcrypto_hash_ctx ctx;
if (!qcrypto_hash_supports(alg)) {