From: Daniel P. Berrangé Date: Thu, 10 Oct 2024 11:40:49 +0000 (+0100) Subject: crypto: drop obsolete back compat logic for old nettle X-Git-Tag: v9.2.0-rc0~55^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=95cc223afbde013c2dd0d6399211227861dbd9b2;p=thirdparty%2Fqemu.git crypto: drop obsolete back compat logic for old nettle The nettle 2.x series declared all the hash functions with 'int' for the data size. Since we dropped support for anything older than 3.4 we can assume nettle is using 'size_t' and thus avoid the back compat looping logic. Reviewed-by: Cédric Le Goater Signed-off-by: Daniel P. Berrangé --- diff --git a/crypto/hash-nettle.c b/crypto/hash-nettle.c index 570ce8a6456..3b847aa60e8 100644 --- a/crypto/hash-nettle.c +++ b/crypto/hash-nettle.c @@ -135,20 +135,9 @@ int qcrypto_nettle_hash_update(QCryptoHash *hash, union qcrypto_hash_ctx *ctx = hash->opaque; for (int i = 0; i < niov; i++) { - /* - * Some versions of nettle have functions - * declared with 'int' instead of 'size_t' - * so to be safe avoid writing more than - * UINT_MAX bytes at a time - */ - size_t len = iov[i].iov_len; - uint8_t *base = iov[i].iov_base; - while (len) { - size_t shortlen = MIN(len, UINT_MAX); - qcrypto_hash_alg_map[hash->alg].write(ctx, len, base); - len -= shortlen; - base += len; - } + qcrypto_hash_alg_map[hash->alg].write(ctx, + iov[i].iov_len, + iov[i].iov_base); } return 0;