qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: "Radim Krčmář" <rkrcmar@redhat.com>
Cc: QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] crypt: fix build with nettle >= 3.0.0
Date: Fri, 10 Jul 2015 14:38:36 +0100	[thread overview]
Message-ID: <CAFEAcA8xAPCtY2nPMvJPRpXc9P3aBbirZ3hNOhD=je2RMER-oQ@mail.gmail.com> (raw)
In-Reply-To: <20150710133131.GB3818@potion.brq.redhat.com>

On 10 July 2015 at 14:31, Radim Krčmář <rkrcmar@redhat.com> wrote:
> 2015-07-10 13:56+0100, Peter Maydell:
>> On 10 July 2015 at 13:33, Radim Krčmář <rkrcmar@redhat.com> 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

  reply	other threads:[~2015-07-10 13:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-10 12:33 [Qemu-devel] [PATCH] crypt: fix build with nettle >= 3.0.0 Radim Krčmář
2015-07-10 12:56 ` Peter Maydell
2015-07-10 13:31   ` Radim Krčmář
2015-07-10 13:38     ` Peter Maydell [this message]
2015-07-10 13:56       ` Peter Maydell
2015-07-10 17:21         ` Radim Krčmář
2015-07-10 13:59       ` Radim Krčmář

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFEAcA8xAPCtY2nPMvJPRpXc9P3aBbirZ3hNOhD=je2RMER-oQ@mail.gmail.com' \
    --to=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rkrcmar@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).