qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] crypt: fix build with nettle >= 3.0.0


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH] crypt: fix build with nettle >= 3.0.0
Date: Fri, 10 Jul 2015 13:56:17 +0100

On 10 July 2015 at 13:33, Radim Krčmář <address@hidden> wrote:
> In nettle 3, cbc_encrypt() accepts 'nettle_cipher_func' instead of
> 'nettle_crypt_func' and these two differ in 'const' qualifier of the
> first argument.  The build fails with:
>
>   In file included from crypto/cipher.c:71:0:
>   ./crypto/cipher-nettle.c: In function ‘qcrypto_cipher_encrypt’:
>   ./crypto/cipher-nettle.c:154:38: error: passing argument 2 of
>   ‘nettle_cbc_encrypt’ from incompatible pointer type
>            cbc_encrypt(ctx->ctx_encrypt, ctx->alg_encrypt,
>                                                ^
>   In file included from ./crypto/cipher-nettle.c:24:0,
>                    from crypto/cipher.c:71:
>   /usr/include/nettle/cbc.h:48:1: note: expected
>   ‘void (*)(const void *, size_t, uint8_t *, const uint8_t *)
>   but argument is of type
>   ‘void (*)(      void *, size_t, uint8_t *, const uint8_t *)
>
> To allow both versions, we switch to the new definition and #if typedef
> it for old versions.
>
> Signed-off-by: Radim Krčmář <address@hidden>
> ---
>  I don't know if we want to kill the #if compatibility after a while
>  (so QEMU doesn't become glibc-like) -- I could split this patch into
>  two, where the first one would just be reverted.

We might eventually kill the compat, but we'd probably
want to do it while retaining a version check in configure,
so I'd just leave it as one patch.

> @@ -83,8 +87,8 @@ QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorithm 
> alg,
>          des_set_key(ctx->ctx_encrypt, rfbkey);
>          g_free(rfbkey);
>
> -        ctx->alg_encrypt = (nettle_crypt_func *)des_encrypt;
> -        ctx->alg_decrypt = (nettle_crypt_func *)des_decrypt;
> +        ctx->alg_encrypt = (nettle_cipher_func *)des_encrypt;
> +        ctx->alg_decrypt = (nettle_cipher_func *)des_decrypt;
>
>          ctx->niv = DES_BLOCK_SIZE;
>          break;
> @@ -98,8 +102,8 @@ QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorithm 
> alg,
>          aes_set_encrypt_key(ctx->ctx_encrypt, nkey, key);
>          aes_set_decrypt_key(ctx->ctx_decrypt, nkey, key);
>
> -        ctx->alg_encrypt = (nettle_crypt_func *)aes_encrypt;
> -        ctx->alg_decrypt = (nettle_crypt_func *)aes_decrypt;
> +        ctx->alg_encrypt = (nettle_cipher_func *)aes_encrypt;
> +        ctx->alg_decrypt = (nettle_cipher_func *)aes_decrypt;

Why do we need the casts here at all? If the functions
we're passing around don't have the right signature
anyway we're in big trouble and casting them is
just going to hide the problem until runtime...

thanks
-- PMM



reply via email to

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