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