[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 14:38:36 +0100 |
On 10 July 2015 at 14:31, Radim Krčmář <address@hidden> wrote:
> 2015-07-10 13:56+0100, Peter Maydell:
>> On 10 July 2015 at 13:33, Radim Krčmář <address@hidden> wrote:
>>> @@ -83,8 +87,8 @@ QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorithm
>>> alg,
>>> - 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;
>>> @@ -98,8 +102,8 @@ QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorithm
>>> alg,
>>> - 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...
>
> Yes.
>
> We pass 'ctx' as a 'void *' in the code, but these functions accept
> specialized structures, which makes them incompatible:
>
> void nettle_cipher_func(const void *ctx, size_t length, [...])
>
> void aes_decrypt(const struct aes_ctx *ctx, size_t length, [...])
> void des_decrypt(const struct des_ctx *ctx, size_t length, [...])
But aren't both the typedef and the aes/des_decrypt functions
provided by the nettle library? Why is the library providing
functions whose prototypes don't match its own typedef?
-- PMM