diff options
author | Edward Hervey <bilboed@bilboed.com> | 2014-10-09 11:00:54 +0200 |
---|---|---|
committer | Edward Hervey <bilboed@bilboed.com> | 2014-10-09 11:01:31 +0200 |
commit | d922b952918cb13e1081c3b3e092c07675880d8a (patch) | |
tree | 7f67e0bd8feb3aadb9fdc31df905eb531ba821d9 | |
parent | d412a4a77651cd9aac9dc328ab069b2fc3dee131 (diff) |
librtmp.recipe: Fix build with new gnutlsrtmpfix
-rw-r--r-- | recipes/librtmp/0002-Don-t-use-non-public-gnutls-functions.patch | 102 | ||||
-rw-r--r-- | recipes/librtmp/librtmp.recipe | 3 |
2 files changed, 104 insertions, 1 deletions
diff --git a/recipes/librtmp/0002-Don-t-use-non-public-gnutls-functions.patch b/recipes/librtmp/0002-Don-t-use-non-public-gnutls-functions.patch new file mode 100644 index 00000000..d993e299 --- /dev/null +++ b/recipes/librtmp/0002-Don-t-use-non-public-gnutls-functions.patch @@ -0,0 +1,102 @@ +From 8e3064207fa7535baad07fd06b65630ec8b31a08 Mon Sep 17 00:00:00 2001 +From: Martin Storsjo <martin@martin.st> +Date: Fri, 19 Jul 2013 15:40:25 +0300 +Subject: [PATCH 01/14] Don't use non-public gnutls functions + +The internal functions gnutls_calc_dh_secret and gnutls_calc_dh_key +have changed signature in recent gnutls versions - don't use them +but manually do roughly the same as what they used to do before +using only public API functions. +--- + librtmp/dh.h | 64 +++++++++++++++++++++++++++++++++++++++++++++++++----------- + 1 file changed, 53 insertions(+), 11 deletions(-) + +diff --git a/librtmp/dh.h b/librtmp/dh.h +index e29587b..5fc3f32 100644 +--- a/librtmp/dh.h ++++ b/librtmp/dh.h +@@ -79,6 +79,7 @@ static int MDH_compute_key(uint8_t *secret, size_t len, MP_t pub, MDH *dh) + #elif defined(USE_GNUTLS) + #include <gmp.h> + #include <nettle/bignum.h> ++#include <gnutls/crypto.h> + typedef mpz_ptr MP_t; + #define MP_new(m) m = malloc(sizeof(*m)); mpz_init2(m, 1) + #define MP_set_w(mpi, w) mpz_set_ui(mpi, w) +@@ -104,21 +105,62 @@ typedef struct MDH { + #define MDH_new() calloc(1,sizeof(MDH)) + #define MDH_free(dh) do {MP_free(((MDH*)(dh))->p); MP_free(((MDH*)(dh))->g); MP_free(((MDH*)(dh))->pub_key); MP_free(((MDH*)(dh))->priv_key); free(dh);} while(0) + +-extern MP_t gnutls_calc_dh_secret(MP_t *priv, MP_t g, MP_t p); +-extern MP_t gnutls_calc_dh_key(MP_t y, MP_t x, MP_t p); ++static int MDH_generate_key(MDH *dh) ++{ ++ int num_bytes; ++ uint32_t seed; ++ gmp_randstate_t rs; ++ ++ num_bytes = (mpz_sizeinbase(dh->p, 2) + 7) / 8 - 1; ++ if (num_bytes <= 0 || num_bytes > 18000) ++ return 0; ++ ++ dh->priv_key = calloc(1, sizeof(*dh->priv_key)); ++ if (!dh->priv_key) ++ return 0; ++ mpz_init2(dh->priv_key, 1); ++ gnutls_rnd(GNUTLS_RND_RANDOM, &seed, sizeof(seed)); ++ gmp_randinit_mt(rs); ++ gmp_randseed_ui(rs, seed); ++ mpz_urandomb(dh->priv_key, rs, num_bytes); ++ gmp_randclear(rs); ++ ++ dh->pub_key = calloc(1, sizeof(*dh->pub_key)); ++ if (!dh->pub_key) ++ return 0; ++ mpz_init2(dh->pub_key, 1); ++ if (!dh->pub_key) { ++ mpz_clear(dh->priv_key); ++ free(dh->priv_key); ++ return 0; ++ } ++ ++ mpz_powm(dh->pub_key, dh->g, dh->priv_key, dh->p); ++ ++ return 1; ++} + +-#define MDH_generate_key(dh) (dh->pub_key = gnutls_calc_dh_secret(&dh->priv_key, dh->g, dh->p)) + static int MDH_compute_key(uint8_t *secret, size_t len, MP_t pub, MDH *dh) + { +- MP_t sec = gnutls_calc_dh_key(pub, dh->priv_key, dh->p); +- if (sec) +- { +- MP_setbin(sec, secret, len); +- MP_free(sec); +- return 0; +- } +- else ++ mpz_ptr k; ++ int num_bytes; ++ ++ num_bytes = (mpz_sizeinbase(dh->p, 2) + 7) / 8; ++ if (num_bytes <= 0 || num_bytes > 18000) ++ return -1; ++ ++ k = calloc(1, sizeof(*k)); ++ if (!k) + return -1; ++ mpz_init2(k, 1); ++ ++ mpz_powm(k, pub, dh->priv_key, dh->p); ++ nettle_mpz_get_str_256(len, secret, k); ++ mpz_clear(k); ++ free(k); ++ ++ /* return the length of the shared secret key like DH_compute_key */ ++ return len; + } + + #else /* USE_OPENSSL */ +-- +2.1.0 + diff --git a/recipes/librtmp/librtmp.recipe b/recipes/librtmp/librtmp.recipe index f6d81f2c..a1c61eb3 100644 --- a/recipes/librtmp/librtmp.recipe +++ b/recipes/librtmp/librtmp.recipe @@ -11,7 +11,8 @@ class Recipe(recipe.Recipe): licenses = [License.LGPLv2_1] srcdir = 'librtmp' tarball_dirname = 'rtmpdump-%(version)s' - patches = ['0001-Fix-Makefiles-to-support-several-platforms.patch'] + patches = ['0001-Fix-Makefiles-to-support-several-platforms.patch', + '0002-Don-t-use-non-public-gnutls-functions.patch'] deps = ['gnutls', 'libgcrypt'] files_libs = ['librtmp'] files_devel = ['include/librtmp/', 'lib/pkgconfig/librtmp.pc' ] |