File: 0002_fix_FTBFS_for_openssl.patch

package info (click to toggle)
tgl 2.0.1%2Bgit20160323.ffb04cac-4
  • links: PTS
  • area: main
  • in suites: sid
  • size: 1,772 kB
  • sloc: ansic: 22,238; makefile: 98; awk: 37
file content (45 lines) | stat: -rw-r--r-- 1,982 bytes parent folder | download | duplicates (2)
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
Description: Fix FTBFS for OpenSSL
 Need to patch the source to compile with OpenSSL 1.1.0+
Author: Matthias <mail@matthiasbock.net>
Forwarded: https://github.com/vysheng/tgl/issues/129
Last-Update: 2018-12-11
Index: tgl-2.0.1+git20160323.ffb04cac/crypto/rsa_pem_openssl.c
===================================================================
--- tgl-2.0.1+git20160323.ffb04cac.orig/crypto/rsa_pem_openssl.c
+++ tgl-2.0.1+git20160323.ffb04cac/crypto/rsa_pem_openssl.c
@@ -36,18 +36,28 @@ TGLC_WRAPPER_ASSOC(rsa,RSA)
 // TODO: Refactor crucial struct-identity into its own header.
 TGLC_WRAPPER_ASSOC(bn,BIGNUM)
 
+/*
+ * Note: Since OpenSSL version 1.1.0-pre5 the RSA struct (rsa_st) is opaque,
+ * see https://wiki.openssl.org/index.php/OpenSSL_1.1.0_Changes
+ */
 TGLC_rsa *TGLC_rsa_new (unsigned long e, int n_bytes, const unsigned char *n) {
   RSA *ret = RSA_new ();
-  ret->e = unwrap_bn (TGLC_bn_new ());
-  TGLC_bn_set_word (wrap_bn (ret->e), e);
-  ret->n = unwrap_bn (TGLC_bn_bin2bn (n, n_bytes, NULL));
+  BIGNUM *ret_e = unwrap_bn (TGLC_bn_new ());
+  BIGNUM *ret_n = unwrap_bn (TGLC_bn_bin2bn (n, n_bytes, NULL));
+  RSA_set0_key (ret, ret_n, ret_e, NULL);
+  TGLC_bn_set_word (wrap_bn (ret_e), e);
   return wrap_rsa (ret);
 }
 
-#define RSA_GETTER(M)                                                          \
-  TGLC_bn *TGLC_rsa_ ## M (TGLC_rsa *key) {                                    \
-    return wrap_bn (unwrap_rsa (key)->M);                                      \
-  }                                                                            \
+#define RSA_GETTER(M)                       \
+TGLC_bn *TGLC_rsa_ ## M (TGLC_rsa *key) {   \
+    BIGNUM *rsa_n, *rsa_e, *rsa_d;          \
+    RSA_get0_key(unwrap_rsa (key),          \
+        (const BIGNUM **) &rsa_n,           \
+        (const BIGNUM **) &rsa_e,           \
+        (const BIGNUM **) &rsa_d);          \
+    return wrap_bn (rsa_ ## M);             \
+}
 
 RSA_GETTER(n);
 RSA_GETTER(e);