From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58110) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFft5-00052D-6d for qemu-devel@nongnu.org; Thu, 16 Jul 2015 05:55:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZFft1-0004U2-T2 for qemu-devel@nongnu.org; Thu, 16 Jul 2015 05:55:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54794) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFft1-0004Tw-Li for qemu-devel@nongnu.org; Thu, 16 Jul 2015 05:55:27 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id BF3A4388B53 for ; Thu, 16 Jul 2015 09:55:26 +0000 (UTC) From: "Richard W.M. Jones" Date: Thu, 16 Jul 2015 10:55:22 +0100 Message-Id: <1437040522-19799-1-git-send-email-rjones@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH] crypto/cipher-nettle.c: Pass correct function type to cbc_encrypt and cbc_decrypt. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org The prototypes of the {nettle_}cbc_encrypt and cbc_decrypt functions are: void cbc_encrypt(const void *ctx, nettle_cipher_func *f, size_t block_size, uint8_t *iv, size_t length, uint8_t *dst, const uint8_t *src); void cbc_decrypt(const void *ctx, nettle_cipher_func *f, size_t block_size, uint8_t *iv, size_t length, uint8_t *dst, const uint8_t *src); Since we passed nettle_crypt_func (instead of nettle_cipher_func) as the second argument, this gave the errors below. In file included from crypto/cipher.c:71:0: ./crypto/cipher-nettle.c: In function =E2=80=98qcrypto_cipher_encrypt=E2=80= =99: ./crypto/cipher-nettle.c:154:39: error: passing argument 2 of =E2=80=98ne= ttle_cbc_encrypt=E2=80=99 from incompatible pointer type [-Werror=3Dincom= patible-pointer-types] 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 =E2=80=98void (*)(const vo= id *, size_t, uint8_t *, const uint8_t *) {aka void (*)(const void *, lo= ng unsigned int, unsigned char *, const unsigned char *)}=E2=80=99 but a= rgument is of type =E2=80=98void (*)(void *, size_t, uint8_t *, const ui= nt8_t *) {aka void (*)(void *, long unsigned int, unsigned char *, const= unsigned char *)}=E2=80=99 cbc_encrypt(const void *ctx, nettle_cipher_func *f, ^ In file included from crypto/cipher.c:71:0: ./crypto/cipher-nettle.c: In function =E2=80=98qcrypto_cipher_decrypt=E2=80= =99: ./crypto/cipher-nettle.c:183:21: error: passing argument 2 of =E2=80=98ne= ttle_cbc_decrypt=E2=80=99 from incompatible pointer type [-Werror=3Dincom= patible-pointer-types] ctx->alg_decrypt, ctx->niv, ctx->iv, ^ In file included from ./crypto/cipher-nettle.c:24:0, from crypto/cipher.c:71: /usr/include/nettle/cbc.h:54:1: note: expected =E2=80=98void (*)(const vo= id *, size_t, uint8_t *, const uint8_t *) {aka void (*)(const void *, lo= ng unsigned int, unsigned char *, const unsigned char *)}=E2=80=99 but a= rgument is of type =E2=80=98void (*)(void *, size_t, uint8_t *, const ui= nt8_t *) {aka void (*)(void *, long unsigned int, unsigned char *, const= unsigned char *)}=E2=80=99 cbc_decrypt(const void *ctx, nettle_cipher_func *f, Signed-off-by: Richard W.M. Jones --- crypto/cipher-nettle.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crypto/cipher-nettle.c b/crypto/cipher-nettle.c index e5a14bc..f06ea92 100644 --- a/crypto/cipher-nettle.c +++ b/crypto/cipher-nettle.c @@ -27,8 +27,8 @@ typedef struct QCryptoCipherNettle QCryptoCipherNettle; struct QCryptoCipherNettle { void *ctx_encrypt; void *ctx_decrypt; - nettle_crypt_func *alg_encrypt; - nettle_crypt_func *alg_decrypt; + nettle_cipher_func *alg_encrypt; + nettle_cipher_func *alg_decrypt; uint8_t *iv; size_t niv; }; @@ -83,8 +83,8 @@ QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorith= m alg, des_set_key(ctx->ctx_encrypt, rfbkey); g_free(rfbkey); =20 - ctx->alg_encrypt =3D (nettle_crypt_func *)des_encrypt; - ctx->alg_decrypt =3D (nettle_crypt_func *)des_decrypt; + ctx->alg_encrypt =3D (nettle_cipher_func *)des_encrypt; + ctx->alg_decrypt =3D (nettle_cipher_func *)des_decrypt; =20 ctx->niv =3D DES_BLOCK_SIZE; break; @@ -98,8 +98,8 @@ QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorith= m alg, aes_set_encrypt_key(ctx->ctx_encrypt, nkey, key); aes_set_decrypt_key(ctx->ctx_decrypt, nkey, key); =20 - ctx->alg_encrypt =3D (nettle_crypt_func *)aes_encrypt; - ctx->alg_decrypt =3D (nettle_crypt_func *)aes_decrypt; + ctx->alg_encrypt =3D (nettle_cipher_func *)aes_encrypt; + ctx->alg_decrypt =3D (nettle_cipher_func *)aes_decrypt; =20 ctx->niv =3D AES_BLOCK_SIZE; break; --=20 2.4.3