qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] crypto/cipher-nettle.c: Pass correct function type to cbc_encrypt and cbc_decrypt.
@ 2015-07-16  9:55 Richard W.M. Jones
  2015-07-16 10:04 ` Peter Maydell
  2015-07-17 10:47 ` Daniel P. Berrange
  0 siblings, 2 replies; 6+ messages in thread
From: Richard W.M. Jones @ 2015-07-16  9:55 UTC (permalink / raw)
  To: qemu-devel

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] crypto/cipher-nettle.c: Pass correct function type to cbc_encrypt and cbc_decrypt.
  2015-07-16  9:55 [Qemu-devel] [PATCH] crypto/cipher-nettle.c: Pass correct function type to cbc_encrypt and cbc_decrypt Richard W.M. Jones
@ 2015-07-16 10:04 ` Peter Maydell
  2015-07-16 10:08   ` Paolo Bonzini
  2015-07-16 10:28   ` Richard W.M. Jones
  2015-07-17 10:47 ` Daniel P. Berrange
  1 sibling, 2 replies; 6+ messages in thread
From: Peter Maydell @ 2015-07-16 10:04 UTC (permalink / raw)
  To: Richard W.M. Jones; +Cc: QEMU Developers

On 16 July 2015 at 10:55, Richard W.M. Jones <rjones@redhat.com> wrote:
> 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,

Is this the same issue that Radim's patchset from a few days
back is addressing?

thanks
-- PMM

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] crypto/cipher-nettle.c: Pass correct function type to cbc_encrypt and cbc_decrypt.
  2015-07-16 10:04 ` 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
  1 sibling, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2015-07-16 10:08 UTC (permalink / raw)
  To: Peter Maydell, Richard W.M. Jones; +Cc: QEMU Developers



On 16/07/2015 12:04, Peter Maydell wrote:
> Is this the same issue that Radim's patchset from a few days
> back is addressing?

Yes.  Are you going to apply it, or should I include it in the pull
request I'll send out today?

Paolo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] crypto/cipher-nettle.c: Pass correct function type to cbc_encrypt and cbc_decrypt.
  2015-07-16 10:08   ` Paolo Bonzini
@ 2015-07-16 10:12     ` Peter Maydell
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2015-07-16 10:12 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Richard W.M. Jones, QEMU Developers

On 16 July 2015 at 11:08, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
>
> On 16/07/2015 12:04, Peter Maydell wrote:
>> Is this the same issue that Radim's patchset from a few days
>> back is addressing?
>
> Yes.  Are you going to apply it, or should I include it in the pull
> request I'll send out today?

If you put it in your pull request that would be easier for me.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] crypto/cipher-nettle.c: Pass correct function type to cbc_encrypt and cbc_decrypt.
  2015-07-16 10:04 ` Peter Maydell
  2015-07-16 10:08   ` Paolo Bonzini
@ 2015-07-16 10:28   ` Richard W.M. Jones
  1 sibling, 0 replies; 6+ messages in thread
From: Richard W.M. Jones @ 2015-07-16 10:28 UTC (permalink / raw)
  To: Peter Maydell; +Cc: QEMU Developers

On Thu, Jul 16, 2015 at 11:04:15AM +0100, Peter Maydell wrote:
> Is this the same issue that Radim's patchset from a few days
> back is addressing?

Yes, looks like it, so ignore this patch.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] crypto/cipher-nettle.c: Pass correct function type to cbc_encrypt and cbc_decrypt.
  2015-07-16  9:55 [Qemu-devel] [PATCH] crypto/cipher-nettle.c: Pass correct function type to cbc_encrypt and cbc_decrypt Richard W.M. Jones
  2015-07-16 10:04 ` Peter Maydell
@ 2015-07-17 10:47 ` Daniel P. Berrange
  1 sibling, 0 replies; 6+ messages in thread
From: Daniel P. Berrange @ 2015-07-17 10:47 UTC (permalink / raw)
  To: Richard W.M. Jones; +Cc: qemu-devel

On Thu, Jul 16, 2015 at 10:55:22AM +0100, Richard W.M. Jones wrote:
> 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.

Presumably you used Fedora rawhide which will have nettle 3.x
where as my code was written against FEdora 22 nettle 2.7.x
The function prototypes were changed in 3.x, so we need a
conditional fix - one was just sent in a pull request yesterday:

  https://lists.gnu.org/archive/html/qemu-devel/2015-07/msg03678.html

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-07-17 10:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-16  9:55 [Qemu-devel] [PATCH] crypto/cipher-nettle.c: Pass correct function type to cbc_encrypt and cbc_decrypt Richard W.M. Jones
2015-07-16 10:04 ` 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

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).