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 13:56:17 +0100 [thread overview]
Message-ID: <CAFEAcA-2E=0qUkASMPRuf-WLOY9fUa-W+7zoReTehHskb8fMJw@mail.gmail.com> (raw)
In-Reply-To: <1436531615-30183-1-git-send-email-rkrcmar@redhat.com>
On 10 July 2015 at 13:33, Radim Krčmář <rkrcmar@redhat.com> 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ář <rkrcmar@redhat.com>
> ---
> 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
next prev parent reply other threads:[~2015-07-10 12:56 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 [this message]
2015-07-10 13:31 ` Radim Krčmář
2015-07-10 13:38 ` Peter Maydell
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='CAFEAcA-2E=0qUkASMPRuf-WLOY9fUa-W+7zoReTehHskb8fMJw@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).