qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Richard W.M. Jones" <rjones@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] crypto/cipher-nettle.c: Pass correct function type to cbc_encrypt and cbc_decrypt.
Date: Thu, 16 Jul 2015 10:55:22 +0100	[thread overview]
Message-ID: <1437040522-19799-1-git-send-email-rjones@redhat.com> (raw)

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 ‘qcrypto_cipher_encrypt’:
./crypto/cipher-nettle.c:154:39: error: passing argument 2 of ‘nettle_cbc_encrypt’ from incompatible pointer type [-Werror=incompatible-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 ‘void (*)(const void *, size_t,  uint8_t *, const uint8_t *) {aka void (*)(const void *, long unsigned int,  unsigned char *, const unsigned char *)}’ but argument is of type ‘void (*)(void *, size_t,  uint8_t *, const uint8_t *) {aka void (*)(void *, long unsigned int,  unsigned char *, const unsigned char *)}’
 cbc_encrypt(const void *ctx, nettle_cipher_func *f,
 ^
In file included from crypto/cipher.c:71:0:
./crypto/cipher-nettle.c: In function ‘qcrypto_cipher_decrypt’:
./crypto/cipher-nettle.c:183:21: error: passing argument 2 of ‘nettle_cbc_decrypt’ from incompatible pointer type [-Werror=incompatible-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 ‘void (*)(const void *, size_t,  uint8_t *, const uint8_t *) {aka void (*)(const void *, long unsigned int,  unsigned char *, const unsigned char *)}’ but argument is of type ‘void (*)(void *, size_t,  uint8_t *, const uint8_t *) {aka void (*)(void *, long unsigned int,  unsigned char *, const unsigned char *)}’
 cbc_decrypt(const void *ctx, nettle_cipher_func *f,

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
---
 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(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 +98,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;
 
         ctx->niv = AES_BLOCK_SIZE;
         break;
-- 
2.4.3

             reply	other threads:[~2015-07-16  9:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-16  9:55 Richard W.M. Jones [this message]
2015-07-16 10:04 ` [Qemu-devel] [PATCH] crypto/cipher-nettle.c: Pass correct function type to cbc_encrypt and cbc_decrypt Peter Maydell
2015-07-16 10:08   ` Paolo Bonzini
2015-07-16 10:12     ` Peter Maydell
2015-07-16 10:28   ` Richard W.M. Jones
2015-07-17 10:47 ` Daniel P. Berrange

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=1437040522-19799-1-git-send-email-rjones@redhat.com \
    --to=rjones@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).