From 7aa40f6d2c50abed003ef471b2c5b700f73af4e3 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sat, 8 Feb 2014 18:34:49 +0000 Subject: [PATCH] libratbox/gnutls: add gnutls v3 api compatibility without breaking v2 --- libratbox/src/gnutls.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/libratbox/src/gnutls.c b/libratbox/src/gnutls.c index 03231815..f87fe891 100644 --- a/libratbox/src/gnutls.c +++ b/libratbox/src/gnutls.c @@ -31,7 +31,11 @@ #include #include -#include +#include + +#if GNUTLS_VERSION_MAJOR < 3 +# include +#endif static gnutls_certificate_credentials x509; static gnutls_dh_params dh_params; @@ -246,7 +250,9 @@ rb_ssl_write(rb_fde_t *F, const void *buf, size_t count) static void rb_gcry_random_seed(void *unused) { +#if GNUTLS_VERSION_MAJOR < 3 gcry_fast_random_poll(); +#endif } int @@ -527,21 +533,31 @@ rb_ssl_start_connected(rb_fde_t *F, CNCB * callback, void *data, int timeout) int rb_init_prng(const char *path, prng_seed_t seed_type) { +#if GNUTLS_VERSION_MAJOR < 3 gcry_fast_random_poll(); +#endif return 1; } int rb_get_random(void *buf, size_t length) { +#if GNUTLS_VERSION_MAJOR < 3 gcry_randomize(buf, length, GCRY_STRONG_RANDOM); +#else + gnutls_rnd(GNUTLS_RND_KEY, buf, length); +#endif return 1; } int rb_get_pseudo_random(void *buf, size_t length) { +#if GNUTLS_VERSION_MAJOR < 3 gcry_randomize(buf, length, GCRY_WEAK_RANDOM); +#else + gnutls_rnd(GNUTLS_RND_RANDOM, buf, length); +#endif return 1; }