Compare commits
1
Commits
master
...
libtorrent
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21060634c1 |
@@ -0,0 +1,13 @@
|
||||
TERMUX_PKG_HOMEPAGE=http://rakshasa.github.io/rtorrent/
|
||||
TERMUX_PKG_DESCRIPTION="BitTorrent library with a focus on high performance and good code"
|
||||
TERMUX_PKG_LICENSE="GPL-2.0"
|
||||
TERMUX_PKG_MAINTAINER="Leonid Plyushch <leonid.plyushch@gmail.com>"
|
||||
TERMUX_PKG_VERSION=0.13.7
|
||||
TERMUX_PKG_SRCURL=https://github.com/rakshasa/rtorrent/releases/download/v0.9.${TERMUX_PKG_VERSION##*.}/libtorrent-$TERMUX_PKG_VERSION.tar.gz
|
||||
TERMUX_PKG_SHA256=c738f60f4d7b6879cd2745fb4310bf24c9287219c1fd619706a9d5499ca7ecc1
|
||||
TERMUX_PKG_DEPENDS="openssl"
|
||||
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="--enable-aligned --without-kqueue --disable-debug"
|
||||
|
||||
termux_step_pre_configure() {
|
||||
autoreconf -fi
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
From 4607bbf78040789dee29266878ce109136b984ef Mon Sep 17 00:00:00 2001
|
||||
From: rakshasa <sundell.software@gmail.com>
|
||||
Date: Tue, 20 Dec 2016 19:51:02 +0900
|
||||
Subject: [PATCH] Added support for openssl 1.1.
|
||||
|
||||
---
|
||||
configure.ac | 4 ++++
|
||||
src/utils/diffie_hellman.cc | 36 ++++++++++++++++++++++++++++++++++--
|
||||
2 files changed, 38 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 65e34872..27e33570 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -69,12 +69,15 @@ AC_ARG_ENABLE(openssl,
|
||||
[ --disable-openssl Don't use OpenSSL's SHA1 implementation.],
|
||||
[
|
||||
if test "$enableval" = "yes"; then
|
||||
+dnl move to scripts.
|
||||
PKG_CHECK_MODULES(OPENSSL, libcrypto,
|
||||
CXXFLAGS="$CXXFLAGS $OPENSSL_CFLAGS";
|
||||
LIBS="$LIBS $OPENSSL_LIBS")
|
||||
|
||||
AC_DEFINE(USE_OPENSSL, 1, Using OpenSSL.)
|
||||
AC_DEFINE(USE_OPENSSL_SHA, 1, Using OpenSSL's SHA1 implementation.)
|
||||
+ AC_CHECK_LIB([crypto], [DH_set0_pqg], [AC_DEFINE(USE_OPENSSL_1_1, 1, Using OpenSSL 1.1.)])
|
||||
+
|
||||
else
|
||||
AC_DEFINE(USE_NSS_SHA, 1, Using Mozilla's SHA1 implementation.)
|
||||
fi
|
||||
@@ -85,6 +88,7 @@ AC_ARG_ENABLE(openssl,
|
||||
|
||||
AC_DEFINE(USE_OPENSSL, 1, Using OpenSSL.)
|
||||
AC_DEFINE(USE_OPENSSL_SHA, 1, Using OpenSSL's SHA1 implementation.)
|
||||
+ AC_CHECK_LIB([crypto], [DH_set0_pqg], [AC_DEFINE(USE_OPENSSL_1_1, 1, Using OpenSSL 1.1.)])
|
||||
]
|
||||
)
|
||||
|
||||
diff --git a/src/utils/diffie_hellman.cc b/src/utils/diffie_hellman.cc
|
||||
index aa653d45..7ec13165 100644
|
||||
--- a/src/utils/diffie_hellman.cc
|
||||
+++ b/src/utils/diffie_hellman.cc
|
||||
@@ -54,11 +54,23 @@ DiffieHellman::DiffieHellman(const unsigned char *prime, int primeLength,
|
||||
m_secret(NULL), m_size(0) {
|
||||
|
||||
#ifdef USE_OPENSSL
|
||||
+
|
||||
m_dh = DH_new();
|
||||
+
|
||||
+#ifdef USE_OPENSSL_1_1
|
||||
+ 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");
|
||||
+#else
|
||||
m_dh->p = BN_bin2bn(prime, primeLength, NULL);
|
||||
m_dh->g = BN_bin2bn(generator, generatorLength, NULL);
|
||||
+#endif
|
||||
|
||||
DH_generate_key(m_dh);
|
||||
+
|
||||
#else
|
||||
throw internal_error("Compiled without encryption support.");
|
||||
#endif
|
||||
@@ -74,7 +86,19 @@ DiffieHellman::~DiffieHellman() {
|
||||
bool
|
||||
DiffieHellman::is_valid() const {
|
||||
#ifdef USE_OPENSSL
|
||||
+ if (m_dh == NULL)
|
||||
+ return false;
|
||||
+
|
||||
+#ifdef USE_OPENSSL_1_1
|
||||
+ const BIGNUM *pub_key;
|
||||
+
|
||||
+ DH_get0_key(m_dh, &pub_key, NULL);
|
||||
+
|
||||
+ return pub_key != NULL;
|
||||
+#else
|
||||
return m_dh != NULL && m_dh->pub_key != NULL;
|
||||
+#endif
|
||||
+
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
@@ -103,8 +127,16 @@ 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;
|
||||
+
|
||||
+#ifdef USE_OPENSSL_1_1
|
||||
+ DH_get0_key(m_dh, &pub_key, NULL);
|
||||
+#else
|
||||
+ pub_key = m_dh->pub_key;
|
||||
+#endif
|
||||
+
|
||||
+ if ((int)length >= BN_num_bytes(pub_key))
|
||||
+ BN_bn2bin(pub_key, dest + length - BN_num_bytes(pub_key));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
diff -uNr libtorrent-0.13.7/scripts/common.m4 libtorrent-0.13.7.mod/scripts/common.m4
|
||||
--- libtorrent-0.13.7/scripts/common.m4 2018-06-07 07:24:43.000000000 +0300
|
||||
+++ libtorrent-0.13.7.mod/scripts/common.m4 2019-07-03 20:56:25.477890400 +0300
|
||||
@@ -150,21 +150,6 @@
|
||||
])
|
||||
])
|
||||
|
||||
-AC_DEFUN([TORRENT_CHECK_EXECINFO], [
|
||||
- AC_MSG_CHECKING(for execinfo.h)
|
||||
-
|
||||
- AC_RUN_IFELSE([AC_LANG_SOURCE([
|
||||
- #include <execinfo.h>
|
||||
- int main() { backtrace((void**)0, 0); backtrace_symbols((char**)0, 0); return 0;}
|
||||
- ])],
|
||||
- [
|
||||
- AC_MSG_RESULT(yes)
|
||||
- AC_DEFINE(USE_EXECINFO, 1, Use execinfo.h)
|
||||
- ], [
|
||||
- AC_MSG_RESULT(no)
|
||||
- ])
|
||||
-])
|
||||
-
|
||||
AC_DEFUN([TORRENT_CHECK_ALIGNED], [
|
||||
AC_MSG_CHECKING(the byte alignment)
|
||||
|
||||
Reference in New Issue
Block a user