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é <[email protected]>
> ---
> 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 <[email protected]>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org