qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 14/18] crypto: add gnutls cipher provider


From: Eric Blake
Subject: Re: [PATCH 14/18] crypto: add gnutls cipher provider
Date: Thu, 8 Jul 2021 14:13:15 -0500
User-agent: NeoMutt/20210205-556-f84451-dirty

On Tue, Jul 06, 2021 at 10:59:20AM +0100, Daniel P. Berrangé wrote:
> Add an implementation of the QEMU cipher APIs to the gnutls
> crypto backend. XTS support is only available for gnutls
> version >= 3.6.8. Since ECB mode is not exposed by gnutls
> APIs, we can't use the private XTS code for compatibility.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  crypto/cipher-gnutls.c.inc | 325 +++++++++++++++++++++++++++++++++++++
>  crypto/cipher.c            |   2 +
>  2 files changed, 327 insertions(+)
>  create mode 100644 crypto/cipher-gnutls.c.inc
> 
> diff --git a/crypto/cipher-gnutls.c.inc b/crypto/cipher-gnutls.c.inc
> new file mode 100644
> index 0000000000..eb6eb49546
> --- /dev/null
> +++ b/crypto/cipher-gnutls.c.inc

> +
> +bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg,
> +                             QCryptoCipherMode mode)
> +{
> +
> +    switch (mode) {
> +    case QCRYPTO_CIPHER_MODE_ECB:
> +    case QCRYPTO_CIPHER_MODE_CBC:
> +        switch (alg) {
> +        case QCRYPTO_CIPHER_ALG_AES_128:
> +        case QCRYPTO_CIPHER_ALG_AES_192:
> +        case QCRYPTO_CIPHER_ALG_AES_256:
> +        case QCRYPTO_CIPHER_ALG_DES:
> +        case QCRYPTO_CIPHER_ALG_3DES:
> +            return true;
> +        default:
> +            return false;
> +        }
> +#ifdef QEMU_GNUTLS_XTS
> +    case QCRYPTO_CIPHER_MODE_XTS:
> +        switch (alg) {
> +        case QCRYPTO_CIPHER_ALG_AES_128:
> +        case QCRYPTO_CIPHER_ALG_AES_256:
> +            return true;
> +        default:
> +            return false;
> +        }
> +        return true;

This line is dead code.

> +#endif
> +    default:
> +        return false;
> +    }
> +}
> +

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org




reply via email to

[Prev in Thread] Current Thread [Next in Thread]