From f887849007312454574ebc1057a438beaa2916df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Fri, 12 Jul 2019 11:14:19 +0100 Subject: crypto: fix function signatures for nettle 2.7 vs 3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Alex Bennée Tested-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Daniel P. Berrangé --- crypto/hmac-nettle.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'crypto/hmac-nettle.c') diff --git a/crypto/hmac-nettle.c b/crypto/hmac-nettle.c index ec2d61bdde..1152b741fd 100644 --- a/crypto/hmac-nettle.c +++ b/crypto/hmac-nettle.c @@ -18,14 +18,23 @@ #include "hmacpriv.h" #include +#if CONFIG_NETTLE_VERSION_MAJOR < 3 +typedef unsigned int hmac_length_t; +#else +typedef size_t hmac_length_t; +#endif + typedef void (*qcrypto_nettle_hmac_setkey)(void *ctx, - size_t key_length, const uint8_t *key); + hmac_length_t key_length, + const uint8_t *key); typedef void (*qcrypto_nettle_hmac_update)(void *ctx, - size_t length, const uint8_t *data); + hmac_length_t length, + const uint8_t *data); typedef void (*qcrypto_nettle_hmac_digest)(void *ctx, - size_t length, uint8_t *digest); + hmac_length_t length, + uint8_t *digest); typedef struct QCryptoHmacNettle QCryptoHmacNettle; struct QCryptoHmacNettle { @@ -135,7 +144,7 @@ qcrypto_nettle_hmac_bytesv(QCryptoHmac *hmac, Error **errp) { QCryptoHmacNettle *ctx; - int i; + size_t i; ctx = (QCryptoHmacNettle *)hmac->opaque; -- cgit v1.2.3