1From bb3da0e32be4f2260940edf3ee0f88103dfd0dcc Mon Sep 17 00:00:00 2001
2From: Eneas U de Queiroz <cote2004-github@yahoo.com>
3Date: Tue, 5 Feb 2019 01:12:19 +0200
4Subject: [PATCH] adb: added patch for openssl 1.1.0 compatibility
5
6Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
7
8[Vadim: took only adb related part from
9https://github.com/lede-project/source/commit/f63f20fb93c7e67775cb01d97fc88b5b29452b81]
10Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
11---
12 core/adb/adb_auth_host.c | 10 ++++++++++
13 1 file changed, 10 insertions(+)
14
15diff --git a/core/adb/adb_auth_host.c b/core/adb/adb_auth_host.c
16index 9039d42..debd2ef 100644
17--- a/core/adb/adb_auth_host.c
18+++ b/core/adb/adb_auth_host.c
19@@ -79,7 +79,13 @@ static int RSA_to_RSAPublicKey(RSA *rsa, RSAPublicKey *pkey)
20     }
21
22     BN_set_bit(r32, 32);
23+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
24+    const BIGNUM *rsa_n, *rsa_e;
25+    RSA_get0_key(rsa, &rsa_n, &rsa_e, NULL);
26+    BN_copy(n, rsa_n);
27+#else
28     BN_copy(n, rsa->n);
29+#endif
30     BN_set_bit(r, RSANUMWORDS * 32);
31     BN_mod_sqr(rr, r, n, ctx);
32     BN_div(NULL, rem, n, r32, ctx);
33@@ -93,7 +99,11 @@ static int RSA_to_RSAPublicKey(RSA *rsa, RSAPublicKey *pkey)
34         BN_div(n, rem, n, r32, ctx);
35         pkey->n[i] = BN_get_word(rem);
36     }
37+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
38+    pkey->exponent = BN_get_word(rsa_e);
39+#else
40     pkey->exponent = BN_get_word(rsa->e);
41+#endif
42
43 out:
44     BN_free(n0inv);
45--
462.14.1
47
48