crypto/cipher-nettle.c: Pass correct function type to cbc_encrypt and cbc_decrypt.
PATCH 1/1 crypto/cipher-nettle.c: Pass correct function type to cbc_encrypt and cbc_decrypt.
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,
--- crypto/cipher-nettle.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
crypto/cipher-nettle.c +6 -6
@@ -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 ;
Signature · 1 line
2.4.3
Quoted 31 lines · Richard W.M. Jones
The prototypes of the {nettle_}cbc_encrypt and
cbc_decryptfunctions are:void
cbc_encrypt(const void *ctx,nettle_cipher_func*f,
size_tblock_size,uint8_t*iv,size_tlength,uint8_t*dst, constuint8_t*src);void
cbc_decrypt(const void *ctx,nettle_cipher_func*f,
size_tblock_size,uint8_t*iv,size_tlength,uint8_t*dst, constuint8_t*src);Since we passed
nettle_crypt_func(instead ofnettle_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,
fromcrypto/cipher.c:71:/usr/include/nettle/cbc.h:48:1: note: expected ‘void (*)(const void *,size_t,uint8_t*, constuint8_t*) {aka void (*)(const void *, long unsigned int, unsigned char *, const unsigned char *)}’ but argument is of type ‘void (*)(void *,size_t,uint8_t*, constuint8_t*) {aka void (*)(void *, long unsigned int, unsigned char *, const unsigned char *)}’
cbc_encrypt(const void *ctx,nettle_cipher_func*f,
^
In file included fromcrypto/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]
Quoted 6 lines
ctx->alg_decrypt, ctx->niv, ctx->iv, ^In file included from
./crypto/cipher-nettle.c:24:0,
fromcrypto/cipher.c:71:/usr/include/nettle/cbc.h:54:1: note: expected ‘void (*)(const void *,size_t,uint8_t*, constuint8_t*) {aka void (*)(const void *, long unsigned int, unsigned char *, const unsigned char *)}’ but argument is of type ‘void (*)(void *,size_t,uint8_t*, constuint8_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
Quoted 2 lines · Peter Maydell
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
Quoted 8 lines · Paolo Bonzini
Quoted 2 lines · Peter Maydell
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
Quoted 2 lines · Peter Maydell
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.
Signature · 5 lines
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
Quoted 9 lines · Richard W.M. Jones
The prototypes of the {nettle_}cbc_encrypt and
cbc_decryptfunctions are:void
cbc_encrypt(const void *ctx,nettle_cipher_func*f,
size_tblock_size,uint8_t*iv,size_tlength,uint8_t*dst, constuint8_t*src);
Quoted 8 lines
void
cbc_decrypt(const void *ctx,nettle_cipher_func*f,
size_tblock_size,uint8_t*iv,size_tlength,uint8_t*dst, constuint8_t*src);Since we passed
nettle_crypt_func(instead ofnettle_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
Signature · 4 lines
|: 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 :|