diff --git a/arcfour-meta.c b/arcfour-meta.c index af988ce49921d4500ac31e898a31ce3ea62e8fa5..d5f14679d14e50a7d23a2512f94c5bceaa3e12bc 100644 --- a/arcfour-meta.c +++ b/arcfour-meta.c @@ -31,8 +31,8 @@ const struct nettle_cipher nettle_arcfour128 = { "arcfour128", sizeof(struct arcfour_ctx), 0, 16, - (nettle_set_key_func) arcfour_set_key, - (nettle_set_key_func) arcfour_set_key, - (nettle_crypt_func) arcfour_crypt, - (nettle_crypt_func) arcfour_crypt + (nettle_set_key_func *) arcfour_set_key, + (nettle_set_key_func *) arcfour_set_key, + (nettle_crypt_func *) arcfour_crypt, + (nettle_crypt_func *) arcfour_crypt }; diff --git a/cbc.h b/cbc.h index 13bf8dd8aef6a4e7843f2acd955ba43183ce2563..81a052503a782eefcfdb4d5724786ce30ea40dcd 100644 --- a/cbc.h +++ b/cbc.h @@ -57,14 +57,14 @@ memcpy((ctx)->iv, (data), sizeof((ctx)->iv)) #define CBC_ENCRYPT(self, f, length, dst, src) \ (0 ? ((f)(&(self)->ctx, 0, NULL, NULL)) \ : cbc_encrypt((void *) &(self)->ctx, \ - (nettle_crypt_func) (f), \ + (nettle_crypt_func *) (f), \ sizeof((self)->iv), (self)->iv, \ (length), (dst), (src))) #define CBC_DECRYPT(self, f, length, dst, src) \ (0 ? ((f)(&(self)->ctx, 0, NULL, NULL)) \ : cbc_decrypt((void *) &(self)->ctx, \ - (nettle_crypt_func) (f), \ + (nettle_crypt_func *) (f), \ sizeof((self)->iv), (self)->iv, \ (length), (dst), (src))) diff --git a/des-compat.c b/des-compat.c index 1b8ae9141c27b49ecd0abe47141f4ba0f4354c80..26dda967a379fcb2df06ee728bb0b83962134dda 100644 --- a/des-compat.c +++ b/des-compat.c @@ -113,13 +113,13 @@ des_ncbc_encrypt(const_des_cblock *src, des_cblock *dst, long length, switch (enc) { case DES_ENCRYPT: - nettle_cbc_encrypt(ctx, (nettle_crypt_func) des_encrypt, + nettle_cbc_encrypt(ctx, (nettle_crypt_func *) des_encrypt, DES_BLOCK_SIZE, *iv, length, *dst, *src); break; case DES_DECRYPT: nettle_cbc_decrypt(ctx, - (nettle_crypt_func) des_decrypt, + (nettle_crypt_func *) des_decrypt, DES_BLOCK_SIZE, *iv, length, *dst, *src); break; @@ -166,12 +166,12 @@ des_ede3_cbc_encrypt(const_des_cblock *src, des_cblock *dst, long length, switch (enc) { case DES_ENCRYPT: - nettle_cbc_encrypt(&keys, (nettle_crypt_func) des_compat_des3_encrypt, + nettle_cbc_encrypt(&keys, (nettle_crypt_func *) des_compat_des3_encrypt, DES_BLOCK_SIZE, *iv, length, *dst, *src); break; case DES_DECRYPT: - nettle_cbc_decrypt(&keys, (nettle_crypt_func) des_compat_des3_decrypt, + nettle_cbc_decrypt(&keys, (nettle_crypt_func *) des_compat_des3_decrypt, DES_BLOCK_SIZE, *iv, length, *dst, *src); break; diff --git a/examples/nettle-benchmark.c b/examples/nettle-benchmark.c index e4463ae0fe3245a667b045883b0ff86e71cb0b6e..f6eb7acc2f6c193649bc6e97077f23f236f18d16 100644 --- a/examples/nettle-benchmark.c +++ b/examples/nettle-benchmark.c @@ -86,7 +86,7 @@ time_function(void (*f)(void *arg), void *arg) struct bench_hash_info { void *ctx; - nettle_hash_update_func update; + nettle_hash_update_func *update; const uint8_t *data; }; @@ -100,7 +100,7 @@ bench_hash(void *arg) struct bench_cipher_info { void *ctx; - nettle_crypt_func crypt; + nettle_crypt_func *crypt; uint8_t *data; }; @@ -114,7 +114,7 @@ bench_cipher(void *arg) struct bench_cbc_info { void *ctx; - nettle_crypt_func crypt; + nettle_crypt_func *crypt; uint8_t *data; diff --git a/examples/nettle-openssl.c b/examples/nettle-openssl.c index b65decb337f0e70839523f531220e8cd8fa2c300..5f5f2b1f9faddd8599c704dfbe2bff4f5172b856 100644 --- a/examples/nettle-openssl.c +++ b/examples/nettle-openssl.c @@ -50,20 +50,21 @@ /* AES */ - +static nettle_set_key_func openssl_aes_set_encrypt_key; static void openssl_aes_set_encrypt_key(void *ctx, unsigned length, const uint8_t *key) { AES_set_encrypt_key(key, length * 8, ctx); } +static nettle_set_key_func openssl_aes_set_decrypt_key; static void openssl_aes_set_decrypt_key(void *ctx, unsigned length, const uint8_t *key) { AES_set_decrypt_key(key, length * 8, ctx); } - +static nettle_crypt_func openssl_aes_encrypt; static void openssl_aes_encrypt(void *ctx, unsigned length, uint8_t *dst, const uint8_t *src) @@ -78,6 +79,7 @@ openssl_aes_encrypt(void *ctx, unsigned length, } } +static nettle_crypt_func openssl_aes_decrypt; static void openssl_aes_decrypt(void *ctx, unsigned length, uint8_t *dst, const uint8_t *src) @@ -123,14 +125,14 @@ nettle_openssl_aes256 = { }; /* Arcfour */ - +static nettle_set_key_func openssl_arcfour_set_key; static void openssl_arcfour_set_key(void *ctx, unsigned length, const uint8_t *key) { RC4_set_key(ctx, length, key); } - +static nettle_crypt_func openssl_arcfour_crypt; static void openssl_arcfour_crypt(void *ctx, unsigned length, uint8_t *dst, const uint8_t *src) @@ -147,13 +149,14 @@ nettle_openssl_arcfour128 = { }; /* Blowfish */ +static nettle_set_key_func openssl_bf_set_key; static void openssl_bf_set_key(void *ctx, unsigned length, const uint8_t *key) { BF_set_key(ctx, length, key); } - +static nettle_crypt_func openssl_bf_encrypt; static void openssl_bf_encrypt(void *ctx, unsigned length, uint8_t *dst, const uint8_t *src) @@ -168,6 +171,7 @@ openssl_bf_encrypt(void *ctx, unsigned length, } } +static nettle_crypt_func openssl_bf_decrypt; static void openssl_bf_decrypt(void *ctx, unsigned length, uint8_t *dst, const uint8_t *src) @@ -192,6 +196,7 @@ nettle_openssl_blowfish128 = { /* DES */ +static nettle_set_key_func openssl_des_set_key; static void openssl_des_set_key(void *ctx, unsigned length, const uint8_t *key) { @@ -205,6 +210,7 @@ openssl_des_set_key(void *ctx, unsigned length, const uint8_t *key) #define DES_BLOCK_SIZE 8 +static nettle_crypt_func openssl_des_encrypt; static void openssl_des_encrypt(void *ctx, unsigned length, uint8_t *dst, const uint8_t *src) @@ -219,6 +225,7 @@ openssl_des_encrypt(void *ctx, unsigned length, } } +static nettle_crypt_func openssl_des_decrypt; static void openssl_des_decrypt(void *ctx, unsigned length, uint8_t *dst, const uint8_t *src) @@ -243,12 +250,14 @@ nettle_openssl_des = { /* Cast128 */ +static nettle_set_key_func openssl_cast_set_key; static void openssl_cast_set_key(void *ctx, unsigned length, const uint8_t *key) { CAST_set_key(ctx, length, key); } +static nettle_crypt_func openssl_cast_encrypt; static void openssl_cast_encrypt(void *ctx, unsigned length, uint8_t *dst, const uint8_t *src) @@ -263,6 +272,7 @@ openssl_cast_encrypt(void *ctx, unsigned length, } } +static nettle_crypt_func openssl_cast_decrypt; static void openssl_cast_decrypt(void *ctx, unsigned length, uint8_t *dst, const uint8_t *src) @@ -288,13 +298,14 @@ nettle_openssl_cast128 = { /* Hash functions */ /* md5 */ - +static nettle_hash_init_func openssl_md5_init; static void openssl_md5_init(void *ctx) { MD5_Init(ctx); } +static nettle_hash_update_func openssl_md5_update; static void openssl_md5_update(void *ctx, unsigned length, @@ -303,6 +314,7 @@ openssl_md5_update(void *ctx, MD5_Update(ctx, src, length); } +static nettle_hash_digest_func openssl_md5_digest; static void openssl_md5_digest(void *ctx, unsigned length, uint8_t *dst) @@ -322,13 +334,14 @@ nettle_openssl_md5 = { }; /* sha1 */ - +static nettle_hash_init_func openssl_sha1_init; static void openssl_sha1_init(void *ctx) { SHA1_Init(ctx); } +static nettle_hash_update_func openssl_sha1_update; static void openssl_sha1_update(void *ctx, unsigned length, @@ -337,6 +350,7 @@ openssl_sha1_update(void *ctx, SHA1_Update(ctx, src, length); } +static nettle_hash_digest_func openssl_sha1_digest; static void openssl_sha1_digest(void *ctx, unsigned length, uint8_t *dst) diff --git a/examples/rsa-encrypt.c b/examples/rsa-encrypt.c index 7bfb6f97547a872a7a95da0e16f42b4dcaf96085..e87dcb6039aa0b0a9ef46f1d1f259d057d012d10 100644 --- a/examples/rsa-encrypt.c +++ b/examples/rsa-encrypt.c @@ -220,7 +220,7 @@ main(int argc, char **argv) mpz_init(x); if (!rsa_encrypt(&key, - &ctx.yarrow, (nettle_random_func) yarrow256_random, + &ctx.yarrow, (nettle_random_func *) yarrow256_random, sizeof(info.key), info.key, x)) { diff --git a/examples/rsa-keygen.c b/examples/rsa-keygen.c index b9d4ff9d13a7803041cd512b21c6d91b0b01414f..2f70e556bef039a4a6072fe57f583a8001f23266 100644 --- a/examples/rsa-keygen.c +++ b/examples/rsa-keygen.c @@ -113,7 +113,7 @@ main(int argc, char **argv) if (!rsa_generate_keypair (&pub, &priv, - (void *) &yarrow, (nettle_random_func) yarrow256_random, + (void *) &yarrow, (nettle_random_func *) yarrow256_random, NULL, progress, KEYSIZE, ESIZE)) { diff --git a/nettle-internal.c b/nettle-internal.c index 2ed7cf12de7d84f1ffdcfa4d3df785c593fc552a..a4817fae0e4628e5a1cace52ed7520121863ac6d 100644 --- a/nettle-internal.c +++ b/nettle-internal.c @@ -66,8 +66,8 @@ nettle_des = { "des", sizeof(struct des_ctx), DES_BLOCK_SIZE, DES_KEY_SIZE, des_set_key_hack, des_set_key_hack, - (nettle_crypt_func) des_encrypt, - (nettle_crypt_func) des_decrypt + (nettle_crypt_func *) des_encrypt, + (nettle_crypt_func *) des_decrypt }; const struct nettle_cipher @@ -75,8 +75,8 @@ nettle_des3 = { "des3", sizeof(struct des3_ctx), DES3_BLOCK_SIZE, DES3_KEY_SIZE, des3_set_key_hack, des3_set_key_hack, - (nettle_crypt_func) des3_encrypt, - (nettle_crypt_func) des3_decrypt + (nettle_crypt_func *) des3_encrypt, + (nettle_crypt_func *) des3_decrypt }; /* NOTE: This is not as nice as one might think, as it will crash if diff --git a/nettle-meta.h b/nettle-meta.h index 05afb36f584b04d4cf9cd7376eee8cd6f04ffa00..15c32dc16eca9ef6c8de474d8c3c3e27ae809a48 100644 --- a/nettle-meta.h +++ b/nettle-meta.h @@ -32,19 +32,6 @@ extern "C" { #endif -/* Randomness. Used by key generation and dsa signature creation. */ -typedef void (*nettle_random_func)(void *ctx, - unsigned length, uint8_t *dst); - -/* Progress report function, mainly for key generation. */ -typedef void (*nettle_progress_func)(void *ctx, - int c); - -/* Ciphers */ -typedef void (*nettle_set_key_func)(void *ctx, - unsigned length, - const uint8_t *key); - struct nettle_cipher { @@ -58,11 +45,11 @@ struct nettle_cipher /* Suggested key size; other sizes are sometimes possible. */ unsigned key_size; - nettle_set_key_func set_encrypt_key; - nettle_set_key_func set_decrypt_key; + nettle_set_key_func *set_encrypt_key; + nettle_set_key_func *set_decrypt_key; - nettle_crypt_func encrypt; - nettle_crypt_func decrypt; + nettle_crypt_func *encrypt; + nettle_crypt_func *decrypt; }; #define _NETTLE_CIPHER(name, NAME, keysize) { \ @@ -70,32 +57,32 @@ struct nettle_cipher sizeof(struct name##_ctx), \ NAME##_BLOCK_SIZE, \ keysize / 8, \ - (nettle_set_key_func) name##_set_key, \ - (nettle_set_key_func) name##_set_key, \ - (nettle_crypt_func) name##_encrypt, \ - (nettle_crypt_func) name##_decrypt, \ + (nettle_set_key_func *) name##_set_key, \ + (nettle_set_key_func *) name##_set_key, \ + (nettle_crypt_func *) name##_encrypt, \ + (nettle_crypt_func *) name##_decrypt, \ } #define _NETTLE_CIPHER_SEP(name, NAME, keysize) { \ - #name #keysize, \ - sizeof(struct name##_ctx), \ - NAME##_BLOCK_SIZE, \ - keysize / 8, \ - (nettle_set_key_func) name##_set_encrypt_key, \ - (nettle_set_key_func) name##_set_decrypt_key, \ - (nettle_crypt_func) name##_encrypt, \ - (nettle_crypt_func) name##_decrypt, \ + #name #keysize, \ + sizeof(struct name##_ctx), \ + NAME##_BLOCK_SIZE, \ + keysize / 8, \ + (nettle_set_key_func *) name##_set_encrypt_key, \ + (nettle_set_key_func *) name##_set_decrypt_key, \ + (nettle_crypt_func *) name##_encrypt, \ + (nettle_crypt_func *) name##_decrypt, \ } #define _NETTLE_CIPHER_FIX(name, NAME, keysize) { \ - #name, \ - sizeof(struct name##_ctx), \ - NAME##_BLOCK_SIZE, \ - keysize / 8, \ - (nettle_set_key_func) name##_set_key, \ - (nettle_set_key_func) name##_set_key, \ - (nettle_crypt_func) name##_encrypt, \ - (nettle_crypt_func) name##_decrypt, \ + #name, \ + sizeof(struct name##_ctx), \ + NAME##_BLOCK_SIZE, \ + keysize / 8, \ + (nettle_set_key_func *) name##_set_key, \ + (nettle_set_key_func *) name##_set_key, \ + (nettle_crypt_func *) name##_encrypt, \ + (nettle_crypt_func *) name##_decrypt, \ } extern const struct nettle_cipher nettle_aes128; @@ -118,15 +105,6 @@ extern const struct nettle_cipher nettle_arctwo64; extern const struct nettle_cipher nettle_arctwo128; extern const struct nettle_cipher nettle_arctwo_gutmann128; - -/* Hash algorithms */ -typedef void (*nettle_hash_init_func)(void *ctx); -typedef void (*nettle_hash_update_func)(void *ctx, - unsigned length, - const uint8_t *src); -typedef void (*nettle_hash_digest_func)(void *ctx, - unsigned length, uint8_t *dst); - struct nettle_hash { const char *name; @@ -140,9 +118,9 @@ struct nettle_hash /* Internal block size */ unsigned block_size; - nettle_hash_init_func init; - nettle_hash_update_func update; - nettle_hash_digest_func digest; + nettle_hash_init_func *init; + nettle_hash_update_func *update; + nettle_hash_digest_func *digest; }; #define _NETTLE_HASH(name, NAME) { \ @@ -150,9 +128,9 @@ struct nettle_hash sizeof(struct name##_ctx), \ NAME##_DIGEST_SIZE, \ NAME##_DATA_SIZE, \ - (nettle_hash_init_func) name##_init, \ - (nettle_hash_update_func) name##_update, \ - (nettle_hash_digest_func) name##_digest \ + (nettle_hash_init_func *) name##_init, \ + (nettle_hash_update_func *) name##_update, \ + (nettle_hash_digest_func *) name##_digest \ } extern const struct nettle_hash nettle_md2; @@ -161,27 +139,6 @@ extern const struct nettle_hash nettle_md5; extern const struct nettle_hash nettle_sha1; extern const struct nettle_hash nettle_sha256; - -/* ASCII armor codecs. NOTE: Experimental and subject to change. */ - -typedef unsigned (*nettle_armor_length_func)(unsigned length); -typedef void (*nettle_armor_init_func)(void *ctx); - -typedef unsigned (*nettle_armor_encode_update_func)(void *ctx, - uint8_t *dst, - unsigned src_length, - const uint8_t *src); - -typedef unsigned (*nettle_armor_encode_final_func)(void *ctx, uint8_t *dst); - -typedef int (*nettle_armor_decode_update_func)(void *ctx, - unsigned *dst_length, - uint8_t *dst, - unsigned src_length, - const uint8_t *src); - -typedef int (*nettle_armor_decode_final_func)(void *ctx); - struct nettle_armor { const char *name; @@ -190,15 +147,15 @@ struct nettle_armor unsigned encode_final_length; - nettle_armor_init_func encode_init; - nettle_armor_length_func encode_length; - nettle_armor_encode_update_func encode_update; - nettle_armor_encode_final_func encode_final; + nettle_armor_init_func *encode_init; + nettle_armor_length_func *encode_length; + nettle_armor_encode_update_func *encode_update; + nettle_armor_encode_final_func *encode_final; - nettle_armor_init_func decode_init; - nettle_armor_length_func decode_length; - nettle_armor_decode_update_func decode_update; - nettle_armor_decode_final_func decode_final; + nettle_armor_init_func *decode_init; + nettle_armor_length_func *decode_length; + nettle_armor_decode_update_func *decode_update; + nettle_armor_decode_final_func *decode_final; }; #define _NETTLE_ARMOR(name, NAME) { \ @@ -206,14 +163,14 @@ struct nettle_armor sizeof(struct name##_encode_ctx), \ sizeof(struct name##_decode_ctx), \ NAME##_ENCODE_FINAL_LENGTH, \ - (nettle_armor_init_func) name##_encode_init, \ - (nettle_armor_length_func) name##_encode_length, \ - (nettle_armor_encode_update_func) name##_encode_update, \ - (nettle_armor_encode_final_func) name##_encode_final, \ - (nettle_armor_init_func) name##_decode_init, \ - (nettle_armor_length_func) name##_decode_length, \ - (nettle_armor_decode_update_func) name##_decode_update, \ - (nettle_armor_decode_final_func) name##_decode_final, \ + (nettle_armor_init_func *) name##_encode_init, \ + (nettle_armor_length_func *) name##_encode_length, \ + (nettle_armor_encode_update_func *) name##_encode_update, \ + (nettle_armor_encode_final_func *) name##_encode_final, \ + (nettle_armor_init_func *) name##_decode_init, \ + (nettle_armor_length_func *) name##_decode_length, \ + (nettle_armor_decode_update_func *) name##_decode_update, \ + (nettle_armor_decode_final_func *) name##_decode_final, \ } #define _NETTLE_ARMOR_0(name, NAME) { \ @@ -221,17 +178,16 @@ struct nettle_armor 0, \ sizeof(struct name##_decode_ctx), \ NAME##_ENCODE_FINAL_LENGTH, \ - (nettle_armor_init_func) name##_encode_init, \ - (nettle_armor_length_func) name##_encode_length, \ - (nettle_armor_encode_update_func) name##_encode_update, \ - (nettle_armor_encode_final_func) name##_encode_final, \ - (nettle_armor_init_func) name##_decode_init, \ - (nettle_armor_length_func) name##_decode_length, \ - (nettle_armor_decode_update_func) name##_decode_update, \ - (nettle_armor_decode_final_func) name##_decode_final, \ + (nettle_armor_init_func *) name##_encode_init, \ + (nettle_armor_length_func *) name##_encode_length, \ + (nettle_armor_encode_update_func *) name##_encode_update, \ + (nettle_armor_encode_final_func *) name##_encode_final, \ + (nettle_armor_init_func *) name##_decode_init, \ + (nettle_armor_length_func *) name##_decode_length, \ + (nettle_armor_decode_update_func *) name##_decode_update, \ + (nettle_armor_decode_final_func *) name##_decode_final, \ } - extern const struct nettle_armor nettle_base64; extern const struct nettle_armor nettle_base16; diff --git a/nettle-types.h b/nettle-types.h index 7b982517411eecf55477f344af72c171405231e2..2a9771523389468d625266ed168111e8c32a1ad5 100644 --- a/nettle-types.h +++ b/nettle-types.h @@ -29,17 +29,56 @@ extern "C" { #endif +/* Randomness. Used by key generation and dsa signature creation. */ +typedef void (nettle_random_func)(void *ctx, + unsigned length, uint8_t *dst); + +/* Progress report function, mainly for key generation. */ +typedef void (nettle_progress_func)(void *ctx, + int c); + +/* Ciphers */ +typedef void (nettle_set_key_func)(void *ctx, + unsigned length, + const uint8_t *key); + /* Uses a void * for cipher contexts. For block ciphers it would make sense with a const void * for the context, but we use the same typedef for stream ciphers where the internal state changes during the encryption. */ -typedef void (*nettle_crypt_func)(void *ctx, - unsigned length, uint8_t *dst, - const uint8_t *src); +typedef void (nettle_crypt_func)(void *ctx, + unsigned length, uint8_t *dst, + const uint8_t *src); + +/* Hash algorithms */ +typedef void (nettle_hash_init_func)(void *ctx); +typedef void (nettle_hash_update_func)(void *ctx, + unsigned length, + const uint8_t *src); +typedef void (nettle_hash_digest_func)(void *ctx, + unsigned length, uint8_t *dst); + +/* ASCII armor codecs. NOTE: Experimental and subject to change. */ + +typedef unsigned (nettle_armor_length_func)(unsigned length); +typedef void (nettle_armor_init_func)(void *ctx); + +typedef unsigned (nettle_armor_encode_update_func)(void *ctx, + uint8_t *dst, + unsigned src_length, + const uint8_t *src); + +typedef unsigned (nettle_armor_encode_final_func)(void *ctx, uint8_t *dst); + +typedef int (nettle_armor_decode_update_func)(void *ctx, + unsigned *dst_length, + uint8_t *dst, + unsigned src_length, + const uint8_t *src); -/* FIXME: Move more of the typedefs to this file? */ +typedef int (nettle_armor_decode_final_func)(void *ctx); #ifdef __cplusplus } diff --git a/testsuite/dsa-keygen-test.c b/testsuite/dsa-keygen-test.c index 60d94ae46fec792a4a6ede85aa1d77144caae962..1d813620846a426cffe8b830d69a5d2cacceb815 100644 --- a/testsuite/dsa-keygen-test.c +++ b/testsuite/dsa-keygen-test.c @@ -23,7 +23,7 @@ test_main(void) knuth_lfib_init(&lfib, 13); if (!dsa_generate_keypair(&pub, &key, - &lfib, (nettle_random_func) knuth_lfib_random, + &lfib, (nettle_random_func *) knuth_lfib_random, NULL, verbose ? progress : NULL, 1024)) FAIL(); diff --git a/testsuite/rsa-encrypt-test.c b/testsuite/rsa-encrypt-test.c index 4bd15f35a135ac79eed876622452a48d6fa68937..c009b75aaf18dd6f6a98e31427b4e8c9c39f26ed 100644 --- a/testsuite/rsa-encrypt-test.c +++ b/testsuite/rsa-encrypt-test.c @@ -32,7 +32,7 @@ test_main(void) fprintf(stderr, "msg: `%s', length = %d\n", msg, msg_length); ASSERT(rsa_encrypt(&pub, - &lfib, (nettle_random_func) knuth_lfib_random, + &lfib, (nettle_random_func *) knuth_lfib_random, msg_length, msg, gibberish)); diff --git a/testsuite/rsa-keygen-test.c b/testsuite/rsa-keygen-test.c index 14539e035cadd1a7dac6923e0dae0c835882476b..ccd1345be7e2b917fadf2ee0265b9b2b2ebc5169 100644 --- a/testsuite/rsa-keygen-test.c +++ b/testsuite/rsa-keygen-test.c @@ -27,7 +27,7 @@ test_main(void) knuth_lfib_init(&lfib, 13); if (!rsa_generate_keypair(&pub, &key, - &lfib, (nettle_random_func) knuth_lfib_random, + &lfib, (nettle_random_func *) knuth_lfib_random, NULL, verbose ? progress : NULL, 1024, 50)) FAIL(); @@ -49,7 +49,7 @@ test_main(void) mpz_set_ui(pub.e, 17); if (!rsa_generate_keypair(&pub, &key, - &lfib, (nettle_random_func) knuth_lfib_random, + &lfib, (nettle_random_func *) knuth_lfib_random, NULL, verbose ? progress : NULL, 2000, 0)) FAIL(); diff --git a/testsuite/testutils.c b/testsuite/testutils.c index 68d27fc1713d4aaeb3913a921a081fb8779821d9..0f2594e478ff062966c99000e7338832112625a1 100644 --- a/testsuite/testutils.c +++ b/testsuite/testutils.c @@ -175,13 +175,30 @@ test_cipher(const struct nettle_cipher *cipher, cipher->encrypt(ctx, length, data, cleartext); if (!MEMEQ(length, data, ciphertext)) - FAIL(); - + { + fprintf(stderr, "Encrypt failed:\nInput:"); + print_hex(length, cleartext); + fprintf(stderr, "\nOutput: "); + print_hex(length, data); + fprintf(stderr, "\nExpected:"); + print_hex(length, ciphertext); + fprintf(stderr, "\n"); + FAIL(); + } cipher->set_decrypt_key(ctx, key_length, key); cipher->decrypt(ctx, length, data, data); if (!MEMEQ(length, data, cleartext)) - FAIL(); + { + fprintf(stderr, "Decrypt failed:\nInput:"); + print_hex(length, ciphertext); + fprintf(stderr, "\nOutput: "); + print_hex(length, data); + fprintf(stderr, "\nExpected:"); + print_hex(length, cleartext); + fprintf(stderr, "\n"); + FAIL(); + } free(ctx); free(data); @@ -760,7 +777,7 @@ test_dsa(const struct dsa_public_key *pub, sha1_update(&sha1, LDATA("The magic words are squeamish ossifrage")); dsa_sign(pub, key, - &lfib, (nettle_random_func) knuth_lfib_random, + &lfib, (nettle_random_func *) knuth_lfib_random, &sha1, &signature); if (verbose)