1 From f91cf5ad8c677b61ceb0bf5877b87f9e93256dd7 Mon Sep 17 00:00:00 2001
2 From: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
3 Date: Mon, 5 Sep 2016 21:49:07 +0000
4 Subject: [PATCH] transmission: build against openssl 1.1.0
6 Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
8 libtransmission/crypto-utils-openssl.c | 73 ++++++++++++++++++++++++++++++++--
9 1 file changed, 69 insertions(+), 4 deletions(-)
11 diff --git a/libtransmission/crypto-utils-openssl.c b/libtransmission/crypto-utils-openssl.c
12 index c4539dc..972e24a 100644
13 --- a/libtransmission/crypto-utils-openssl.c
14 +++ b/libtransmission/crypto-utils-openssl.c
15 @@ -229,6 +229,61 @@ tr_rc4_process (tr_rc4_ctx_t handle,
19 +#if OPENSSL_VERSION_NUMBER < 0x10100000
21 +DH_set0_pqg (DH * dh,
26 + /* If the fields p and g in d are NULL, the corresponding input
27 + * parameters MUST be non-NULL. q may remain NULL.
29 + if ((dh->p == NULL && p == NULL)
30 + || (dh->g == NULL && g == NULL))
47 + dh->length = BN_num_bits (q);
54 +DH_set_length (DH * dh,
57 + dh->length = length;
62 +DH_get0_key(const DH * dh,
63 + const BIGNUM ** pub_key,
64 + const BIGNUM ** priv_key)
66 + if (pub_key != NULL)
67 + *pub_key = dh->pub_key;
68 + if (priv_key != NULL)
69 + *priv_key = dh->priv_key;
75 tr_dh_new (const uint8_t * prime_num,
76 size_t prime_num_length,
77 @@ -236,13 +291,19 @@ tr_dh_new (const uint8_t * prime_num,
78 size_t generator_num_length)
80 DH * handle = DH_new ();
83 assert (prime_num != NULL);
84 assert (generator_num != NULL);
85 + p = BN_bin2bn (prime_num, prime_num_length, NULL);
86 + g = BN_bin2bn (generator_num, generator_num_length, NULL);
88 - if (!check_pointer (handle->p = BN_bin2bn (prime_num, prime_num_length, NULL)) ||
89 - !check_pointer (handle->g = BN_bin2bn (generator_num, generator_num_length, NULL)))
90 + if (!check_pointer (p) ||
91 + !check_pointer (g) ||
92 + !DH_set0_pqg (handle, p, NULL, g))
99 @@ -267,16 +328,20 @@ tr_dh_make_key (tr_dh_ctx_t raw_handle,
101 DH * handle = raw_handle;
102 int dh_size, my_public_key_length;
103 + const BIGNUM * hand_pub_key;
105 assert (handle != NULL);
106 assert (public_key != NULL);
108 - handle->length = private_key_length * 8;
110 + DH_set_length(handle, private_key_length * 8);
112 if (!check_result (DH_generate_key (handle)))
115 - my_public_key_length = BN_bn2bin (handle->pub_key, public_key);
116 + DH_get0_key (handle, &hand_pub_key, NULL);
118 + my_public_key_length = BN_bn2bin (hand_pub_key, public_key);
119 dh_size = DH_size (handle);
121 tr_dh_align_key (public_key, my_public_key_length, dh_size);
122 From 8c8386a7f3f482a9c917f51d28e0042e55f56b3e Mon Sep 17 00:00:00 2001
123 From: Mike Gelfand <mikedld@mikedld.com>
124 Date: Wed, 7 Sep 2016 01:09:04 +0300
125 Subject: [PATCH] Fix coding style and building with !TR_LIGHTWEIGHT
128 libtransmission/crypto-utils-openssl.c | 60 +++++++++++++++++++---------------
129 1 file changed, 33 insertions(+), 27 deletions(-)
131 diff --git a/libtransmission/crypto-utils-openssl.c b/libtransmission/crypto-utils-openssl.c
132 index 972e24a..9fd2c58 100644
133 --- a/libtransmission/crypto-utils-openssl.c
134 +++ b/libtransmission/crypto-utils-openssl.c
138 #include <openssl/bn.h>
139 +#include <openssl/crypto.h>
140 #include <openssl/dh.h>
141 #include <openssl/err.h>
142 #include <openssl/evp.h>
143 @@ -48,7 +49,12 @@ log_openssl_error (const char * file,
144 static bool strings_loaded = false;
147 +#if OPENSSL_VERSION_NUMBER < 0x10100000
148 ERR_load_crypto_strings ();
150 + OPENSSL_init_crypto (OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
153 strings_loaded = true;
156 @@ -230,6 +236,7 @@ tr_rc4_process (tr_rc4_ctx_t handle,
159 #if OPENSSL_VERSION_NUMBER < 0x10100000
162 DH_set0_pqg (DH * dh,
164 @@ -237,28 +244,29 @@ DH_set0_pqg (DH * dh,
167 /* If the fields p and g in d are NULL, the corresponding input
168 - * parameters MUST be non-NULL. q may remain NULL.
169 + * parameters MUST be non-NULL. q may remain NULL.
171 - if ((dh->p == NULL && p == NULL)
172 - || (dh->g == NULL && g == NULL))
173 + if ((dh->p == NULL && p == NULL) || (dh->g == NULL && g == NULL))
207 dh->length = BN_num_bits (q);
212 @@ -267,8 +275,8 @@ static inline int
213 DH_set_length (DH * dh,
216 - dh->length = length;
218 + dh->length = length;
223 @@ -295,12 +303,11 @@ tr_dh_new (const uint8_t * prime_num,
225 assert (prime_num != NULL);
226 assert (generator_num != NULL);
228 p = BN_bin2bn (prime_num, prime_num_length, NULL);
229 g = BN_bin2bn (generator_num, generator_num_length, NULL);
231 - if (!check_pointer (p) ||
232 - !check_pointer (g) ||
233 - !DH_set0_pqg (handle, p, NULL, g))
234 + if (!check_pointer (p) || !check_pointer (g) || !DH_set0_pqg (handle, p, NULL, g))
238 @@ -328,20 +335,19 @@ tr_dh_make_key (tr_dh_ctx_t raw_handle,
240 DH * handle = raw_handle;
241 int dh_size, my_public_key_length;
242 - const BIGNUM * hand_pub_key;
243 + const BIGNUM * my_public_key;
245 assert (handle != NULL);
246 assert (public_key != NULL);
249 DH_set_length(handle, private_key_length * 8);
251 if (!check_result (DH_generate_key (handle)))
254 - DH_get0_key (handle, &hand_pub_key, NULL);
255 + DH_get0_key (handle, &my_public_key, NULL);
257 - my_public_key_length = BN_bn2bin (hand_pub_key, public_key);
258 + my_public_key_length = BN_bn2bin (my_public_key, public_key);
259 dh_size = DH_size (handle);
261 tr_dh_align_key (public_key, my_public_key_length, dh_size);