[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 15/18] crypto: add gnutls hash provider
From: |
Eric Blake |
Subject: |
Re: [PATCH 15/18] crypto: add gnutls hash provider |
Date: |
Thu, 8 Jul 2021 14:29:20 -0500 |
User-agent: |
NeoMutt/20210205-556-f84451-dirty |
On Tue, Jul 06, 2021 at 10:59:21AM +0100, Daniel P. Berrangé wrote:
> This adds support for using gnutls as a provider of the crypto
> hash APIs.
>
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
> crypto/hash-gnutls.c | 104 +++++++++++++++++++++++++++++++++++++++++++
> crypto/meson.build | 2 +
> 2 files changed, 106 insertions(+)
> create mode 100644 crypto/hash-gnutls.c
>
> diff --git a/crypto/hash-gnutls.c b/crypto/hash-gnutls.c
> new file mode 100644
> index 0000000000..f88db71f00
> --- /dev/null
> +++ b/crypto/hash-gnutls.c
> @@ -0,0 +1,104 @@
> +/*
> + * QEMU Crypto hash algorithms
> + *
> + * Copyright (c) 2016 Red Hat, Inc.
Want to add 2021 here?
> +static int
> +qcrypto_gnutls_hash_bytesv(QCryptoHashAlgorithm alg,
> + const struct iovec *iov,
> + size_t niov,
> + uint8_t **result,
> + size_t *resultlen,
> + Error **errp)
> +{
> +
> + ret = gnutls_hash_init(&hash, qcrypto_hash_alg_map[alg]);
> + if (ret < 0) {
> + error_setg(errp,
> + "Unable to initialize hash algorithm: %s",
> + gnutls_strerror(ret));
> + return -1;
> + }
> +
> + for (i = 0; i < niov; i++) {
> + gnutls_hash(hash, iov[i].iov_base, iov[i].iov_len);
> + }
> +
> + gnutls_hash_deinit(hash, *result);
Is there any speed penalty for creating a new gnutls_hash object for
each call to qcrypto_gnutls_hash_bytesv(), compared to creating a hash
object just once and using gnutls_hash_output() to grab results and
reset it for reuse? But that can be a later patch (if it even works -
I may have mis-read gnutls docs), so it doesn't affect review of this
patch.
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
[PATCH 14/18] crypto: add gnutls cipher provider, Daniel P . Berrangé, 2021/07/06
[PATCH 15/18] crypto: add gnutls hash provider, Daniel P . Berrangé, 2021/07/06
- Re: [PATCH 15/18] crypto: add gnutls hash provider,
Eric Blake <=
[PATCH 16/18] crypto: add gnutls hmac provider, Daniel P . Berrangé, 2021/07/06
[PATCH 18/18] crypto: prefer gnutls as the crypto backend if new enough, Daniel P . Berrangé, 2021/07/06
[PATCH 17/18] crypto: add gnutls pbkdf provider, Daniel P . Berrangé, 2021/07/06