1 |
commit: 371794f20c7eb2b88cae2619b6fa3444452aafb4 |
2 |
Author: Patrick McLean <patrick.mclean <AT> sony <DOT> com> |
3 |
AuthorDate: Thu Oct 25 00:06:36 2018 +0000 |
4 |
Commit: Patrick McLean <chutzpah <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Oct 25 00:06:56 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=371794f2 |
7 |
|
8 |
net-misc/openssh: Fix build with openssl-1.1 and hpn (bug #669506) |
9 |
|
10 |
Closes: https://bugs.gentoo.org/669506 |
11 |
Signed-off-by: Patrick McLean <chutzpah <AT> gentoo.org> |
12 |
Package-Manager: Portage-2.3.51, Repoman-2.3.11 |
13 |
|
14 |
.../files/openssh-7.9_p1-hpn-openssl-1.1.patch | 107 +++++++++++++++++++++ |
15 |
net-misc/openssh/openssh-7.9_p1.ebuild | 1 + |
16 |
2 files changed, 108 insertions(+) |
17 |
|
18 |
diff --git a/net-misc/openssh/files/openssh-7.9_p1-hpn-openssl-1.1.patch b/net-misc/openssh/files/openssh-7.9_p1-hpn-openssl-1.1.patch |
19 |
new file mode 100644 |
20 |
index 00000000000..524d05ad89d |
21 |
--- /dev/null |
22 |
+++ b/net-misc/openssh/files/openssh-7.9_p1-hpn-openssl-1.1.patch |
23 |
@@ -0,0 +1,107 @@ |
24 |
+--- openssh-7.9p1.orig/cipher-ctr-mt.c 2018-10-24 20:48:00.909255466 -0000 |
25 |
++++ openssh-7.9p1/cipher-ctr-mt.c 2018-10-24 20:48:17.378155144 -0000 |
26 |
+@@ -46,7 +46,7 @@ |
27 |
+ |
28 |
+ /*-------------------- TUNABLES --------------------*/ |
29 |
+ /* maximum number of threads and queues */ |
30 |
+-#define MAX_THREADS 32 |
31 |
++#define MAX_THREADS 32 |
32 |
+ #define MAX_NUMKQ (MAX_THREADS * 2) |
33 |
+ |
34 |
+ /* Number of pregen threads to use */ |
35 |
+@@ -435,7 +435,7 @@ |
36 |
+ destp.u += AES_BLOCK_SIZE; |
37 |
+ srcp.u += AES_BLOCK_SIZE; |
38 |
+ len -= AES_BLOCK_SIZE; |
39 |
+- ssh_ctr_inc(ctx->iv, AES_BLOCK_SIZE); |
40 |
++ ssh_ctr_inc(c->aes_counter, AES_BLOCK_SIZE); |
41 |
+ |
42 |
+ /* Increment read index, switch queues on rollover */ |
43 |
+ if ((ridx = (ridx + 1) % KQLEN) == 0) { |
44 |
+@@ -481,8 +481,6 @@ |
45 |
+ /* get the number of cores in the system */ |
46 |
+ /* if it's not linux it currently defaults to 2 */ |
47 |
+ /* divide by 2 to get threads for each direction (MODE_IN||MODE_OUT) */ |
48 |
+- /* NB: assigning a float to an int discards the remainder which is */ |
49 |
+- /* acceptable (and wanted) in this case */ |
50 |
+ #ifdef __linux__ |
51 |
+ cipher_threads = sysconf(_SC_NPROCESSORS_ONLN) / 2; |
52 |
+ #endif /*__linux__*/ |
53 |
+@@ -505,11 +503,12 @@ |
54 |
+ if (cipher_threads < 2) |
55 |
+ cipher_threads = 2; |
56 |
+ |
57 |
+- /* assure that we aren't trying to create more threads than we have in the struct */ |
58 |
+- /* cipher_threads is half the total of allowable threads hence the odd looking math here */ |
59 |
++ /* assure that we aren't trying to create more threads */ |
60 |
++ /* than we have in the struct. cipher_threads is half the */ |
61 |
++ /* total of allowable threads hence the odd looking math here */ |
62 |
+ if (cipher_threads * 2 > MAX_THREADS) |
63 |
+ cipher_threads = MAX_THREADS / 2; |
64 |
+- |
65 |
++ |
66 |
+ /* set the number of keystream queues */ |
67 |
+ numkq = cipher_threads * 2; |
68 |
+ |
69 |
+@@ -551,16 +550,16 @@ |
70 |
+ } |
71 |
+ |
72 |
+ if (iv != NULL) { |
73 |
+- memcpy(ctx->iv, iv, AES_BLOCK_SIZE); |
74 |
++ memcpy(c->aes_counter, iv, AES_BLOCK_SIZE); |
75 |
+ c->state |= HAVE_IV; |
76 |
+ } |
77 |
+ |
78 |
+ if (c->state == (HAVE_KEY | HAVE_IV)) { |
79 |
+ /* Clear queues */ |
80 |
+- memcpy(c->q[0].ctr, ctx->iv, AES_BLOCK_SIZE); |
81 |
++ memcpy(c->q[0].ctr, c->aes_counter, AES_BLOCK_SIZE); |
82 |
+ c->q[0].qstate = KQINIT; |
83 |
+ for (i = 1; i < numkq; i++) { |
84 |
+- memcpy(c->q[i].ctr, ctx->iv, AES_BLOCK_SIZE); |
85 |
++ memcpy(c->q[i].ctr, c->aes_counter, AES_BLOCK_SIZE); |
86 |
+ ssh_ctr_add(c->q[i].ctr, i * KQLEN, AES_BLOCK_SIZE); |
87 |
+ c->q[i].qstate = KQEMPTY; |
88 |
+ } |
89 |
+@@ -644,8 +643,22 @@ |
90 |
+ const EVP_CIPHER * |
91 |
+ evp_aes_ctr_mt(void) |
92 |
+ { |
93 |
++# if OPENSSL_VERSION_NUMBER >= 0x10100000UL |
94 |
++ static EVP_CIPHER *aes_ctr; |
95 |
++ aes_ctr = EVP_CIPHER_meth_new(NID_undef, 16/*block*/, 16/*key*/); |
96 |
++ EVP_CIPHER_meth_set_iv_length(aes_ctr, AES_BLOCK_SIZE); |
97 |
++ EVP_CIPHER_meth_set_init(aes_ctr, ssh_aes_ctr_init); |
98 |
++ EVP_CIPHER_meth_set_cleanup(aes_ctr, ssh_aes_ctr_cleanup); |
99 |
++ EVP_CIPHER_meth_set_do_cipher(aes_ctr, ssh_aes_ctr); |
100 |
++# ifndef SSH_OLD_EVP |
101 |
++ EVP_CIPHER_meth_set_flags(aes_ctr, EVP_CIPH_CBC_MODE |
102 |
++ | EVP_CIPH_VARIABLE_LENGTH |
103 |
++ | EVP_CIPH_ALWAYS_CALL_INIT |
104 |
++ | EVP_CIPH_CUSTOM_IV); |
105 |
++# endif /*SSH_OLD_EVP*/ |
106 |
++ return (aes_ctr); |
107 |
++# else /*earlier version of openssl*/ |
108 |
+ static EVP_CIPHER aes_ctr; |
109 |
+- |
110 |
+ memset(&aes_ctr, 0, sizeof(EVP_CIPHER)); |
111 |
+ aes_ctr.nid = NID_undef; |
112 |
+ aes_ctr.block_size = AES_BLOCK_SIZE; |
113 |
+@@ -654,11 +667,12 @@ |
114 |
+ aes_ctr.init = ssh_aes_ctr_init; |
115 |
+ aes_ctr.cleanup = ssh_aes_ctr_cleanup; |
116 |
+ aes_ctr.do_cipher = ssh_aes_ctr; |
117 |
+-#ifndef SSH_OLD_EVP |
118 |
+- aes_ctr.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | |
119 |
+- EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV; |
120 |
+-#endif |
121 |
+- return &aes_ctr; |
122 |
++# ifndef SSH_OLD_EVP |
123 |
++ aes_ctr.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | |
124 |
++ EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV; |
125 |
++# endif /*SSH_OLD_EVP*/ |
126 |
++ return &aes_ctr; |
127 |
++# endif /*OPENSSH_VERSION_NUMBER*/ |
128 |
+ } |
129 |
+ |
130 |
+ #endif /* defined(WITH_OPENSSL) */ |
131 |
|
132 |
diff --git a/net-misc/openssh/openssh-7.9_p1.ebuild b/net-misc/openssh/openssh-7.9_p1.ebuild |
133 |
index c38afd6020c..83ff7a4d299 100644 |
134 |
--- a/net-misc/openssh/openssh-7.9_p1.ebuild |
135 |
+++ b/net-misc/openssh/openssh-7.9_p1.ebuild |
136 |
@@ -169,6 +169,7 @@ src_prepare() { |
137 |
popd |
138 |
|
139 |
eapply "${hpn_patchdir}" |
140 |
+ eapply "${FILESDIR}/openssh-7.9_p1-hpn-openssl-1.1.patch" |
141 |
|
142 |
einfo "Patching Makefile.in for HPN patch set ..." |
143 |
sed -i \ |