From 8c856e0c7683144d20796051a2baf2fff949953c Mon Sep 17 00:00:00 2001 From: Sergei Reznikov Date: Sat, 13 Jun 2020 11:54:06 +0000 Subject: [PATCH] libtorrent: fix build with openssl 1.1 --- net-libs/libtorrent/libtorrent-0.13.7.recipe | 7 ++- net-libs/libtorrent/patches/OpenSSL-1.1.patch | 58 +++++++++++++++++++ 2 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 net-libs/libtorrent/patches/OpenSSL-1.1.patch diff --git a/net-libs/libtorrent/libtorrent-0.13.7.recipe b/net-libs/libtorrent/libtorrent-0.13.7.recipe index 3c1f8b704..1716b40cf 100644 --- a/net-libs/libtorrent/libtorrent-0.13.7.recipe +++ b/net-libs/libtorrent/libtorrent-0.13.7.recipe @@ -4,10 +4,13 @@ with the goals of being efficient and easy to use." HOMEPAGE="http://libtorrent.rakshasa.no/" COPYRIGHT="2005-2018 Jari Sundell" LICENSE="GNU LGPL v2" -REVISION="3" +REVISION="4" SOURCE_URI="https://github.com/rakshasa/rtorrent/releases/download/v0.9.7/libtorrent-$portVersion.tar.gz" CHECKSUM_SHA256="c738f60f4d7b6879cd2745fb4310bf24c9287219c1fd619706a9d5499ca7ecc1" -PATCHES="libtorrent-$portVersion.patchset" +PATCHES=" + libtorrent-$portVersion.patchset + OpenSSL-1.1.patch + " ARCHITECTURES="x86 ?x86_gcc2 x86_64" SECONDARY_ARCHITECTURES="x86" diff --git a/net-libs/libtorrent/patches/OpenSSL-1.1.patch b/net-libs/libtorrent/patches/OpenSSL-1.1.patch new file mode 100644 index 000000000..cf4f52eff --- /dev/null +++ b/net-libs/libtorrent/patches/OpenSSL-1.1.patch @@ -0,0 +1,58 @@ +From 472dd5d7a868130b94212d4a9ec5b6167d36fc71 Mon Sep 17 00:00:00 2001 +From: Peter Pentchev +Date: Mon, 28 Nov 2016 00:17:40 +0200 +Subject: [PATCH] Fix the DH parameters generation with OpenSSL 1.1. + +The DH structure is now opaque, so the parameters must be stored there +through an accessor function. +--- + src/utils/diffie_hellman.cc | 19 ++++++++++++++----- + 1 file changed, 14 insertions(+), 5 deletions(-) + +diff --git a/src/utils/diffie_hellman.cc b/src/utils/diffie_hellman.cc +index aa653d45..701ec90c 100644 +--- a/src/utils/diffie_hellman.cc ++++ b/src/utils/diffie_hellman.cc +@@ -55,8 +55,11 @@ DiffieHellman::DiffieHellman(const unsigned char *prime, int primeLength, + + #ifdef USE_OPENSSL + m_dh = DH_new(); +- m_dh->p = BN_bin2bn(prime, primeLength, NULL); +- m_dh->g = BN_bin2bn(generator, generatorLength, NULL); ++ BIGNUM * const dh_p = BN_bin2bn(prime, primeLength, NULL); ++ BIGNUM * const dh_g = BN_bin2bn(generator, generatorLength, NULL); ++ if (dh_p == NULL || dh_g == NULL || ++ !DH_set0_pqg(m_dh, dh_p, NULL, dh_g)) ++ throw internal_error("Could not generate Diffie-Hellman parameters"); + + DH_generate_key(m_dh); + #else +@@ -74,7 +77,11 @@ DiffieHellman::~DiffieHellman() { + bool + DiffieHellman::is_valid() const { + #ifdef USE_OPENSSL +- return m_dh != NULL && m_dh->pub_key != NULL; ++ if (m_dh == NULL) ++ return false; ++ const BIGNUM *pub_key; ++ DH_get0_key(m_dh, &pub_key, NULL); ++ return pub_key != NULL; + #else + return false; + #endif +@@ -103,8 +110,10 @@ DiffieHellman::store_pub_key(unsigned char* dest, unsigned int length) { + #ifdef USE_OPENSSL + std::memset(dest, 0, length); + +- if ((int)length >= BN_num_bytes(m_dh->pub_key)) +- BN_bn2bin(m_dh->pub_key, dest + length - BN_num_bytes(m_dh->pub_key)); ++ const BIGNUM *pub_key; ++ DH_get0_key(m_dh, &pub_key, NULL); ++ if ((int)length >= BN_num_bytes(pub_key)) ++ BN_bn2bin(pub_key, dest + length - BN_num_bytes(pub_key)); + #endif + } + +-- +2.11.0 +