01e1152003-03-12Niels Möller /* nettle.h * * Shared declarations for the various files. */
7beff12014-05-13Martin Nilsson #if 0 static void werror(const char *format, ...) { va_list args; va_start(args, format); vfprintf(stderr, format, args); va_end(args); } #else #define werror(x) #endif
a307722015-03-20Henrik Grubbström (Grubba) #include <nettle/nettle-types.h>
01e1152003-03-12Niels Möller struct program; extern struct program *nettle_hash_program; extern struct program *hash_instance_program; extern struct program *nettle_hash_program;
a467f92004-03-20Henrik Grubbström (Grubba) #define NO_WIDE_STRING(s) do { \ if ((s)->size_shift) \
dc8a672004-01-22Martin Nilsson  Pike_error("Bad argument. Must be 8-bit string.\n"); \
a467f92004-03-20Henrik Grubbström (Grubba)  } while(0)
37f2572003-03-13Niels Möller 
e8be7c2010-11-14Jonas Walldén 
d42d732010-11-14Jonas Walldén /* Hashing methods can normally process hundreds of megabytes per second
e8be7c2010-11-14Jonas Walldén  so it's rather wasteful to enable threads during hashing of smaller data sizes. Limit is now 1 MB. */
0473d52014-05-11Henrik Grubbström (Grubba) #define HASH_THREADS_ALLOW_THRESHOLD (1024 * 1024) /* Encrypt/decrypt methods are a bit more expensive. */ #define CIPHER_THREADS_ALLOW_THRESHOLD 1024
e8be7c2010-11-14Jonas Walldén 
c17a992014-04-24Henrik Grubbström (Grubba) #ifdef HAVE_NETTLE_DSA_H #include <nettle/dsa.h> #endif
fd073e2014-06-23Henrik Grubbström (Grubba) 
c17a992014-04-24Henrik Grubbström (Grubba) #ifdef dsa_params_init /* We use the presence of the dsa_params_init remapping to detect Nettle * 3.0 or later. This is the recommended way to detect Nettle version * differences. In Nettle 3.0 length fields use size_t, where earlier
07bae92014-04-24Martin Nilsson  * it was unsigned.
4c4c702014-04-24Martin Nilsson  */ typedef size_t pike_nettle_size_t; #else typedef unsigned pike_nettle_size_t; #endif
fd073e2014-06-23Henrik Grubbström (Grubba) /* In Nettle 2.0 the nettle_*_func typedefs lost their pointers. */ #ifdef HAVE_NETTLE_CRYPT_FUNC_IS_POINTER /* Nettle 1.x */ typedef nettle_crypt_func pike_nettle_crypt_func; typedef nettle_hash_digest_func pike_nettle_hash_digest_func; typedef nettle_hash_update_func pike_nettle_hash_update_func; #else /* Nettle 2.0 */
64337a2014-11-06Martin Nilsson  #ifdef dsa_params_init /* Nettle 3.0 */ typedef nettle_cipher_func *pike_nettle_crypt_func; #else
fd073e2014-06-23Henrik Grubbström (Grubba) typedef nettle_crypt_func *pike_nettle_crypt_func;
64337a2014-11-06Martin Nilsson #endif
fd073e2014-06-23Henrik Grubbström (Grubba) typedef nettle_hash_digest_func *pike_nettle_hash_digest_func; typedef nettle_hash_update_func *pike_nettle_hash_update_func; #endif
4c4c702014-04-24Martin Nilsson 
79598b2008-12-13Martin Nilsson char *pike_crypt_md5(int pl, const char *const pw,
395c4a2012-07-25Martin Nilsson  int sl, const char *const salt, int ml, const char *const magic);
37f2572003-03-13Niels Möller 
a467f92004-03-20Henrik Grubbström (Grubba) void hash_init(void);
48f4542003-03-18Niels Möller 
a467f92004-03-20Henrik Grubbström (Grubba) void hash_exit(void);
48f4542003-03-18Niels Möller 
a467f92004-03-20Henrik Grubbström (Grubba) void cipher_init(void);
099d682004-01-30Martin Nilsson 
a467f92004-03-20Henrik Grubbström (Grubba) void cipher_exit(void);
099d682004-01-30Martin Nilsson 
a467f92004-03-20Henrik Grubbström (Grubba) void nt_init(void); void nt_exit(void);
d5f6892013-11-24Martin Nilsson  void hogweed_init(void); void hogweed_exit(void);
ee98922014-04-24Martin Nilsson  void mac_init(void); void mac_exit(void); void aead_init(void); void aead_exit(void);