Gentoo Archives: gentoo-commits

From: Craig Andrews <candrews@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-perl/Crypt-OpenSSL-ECDSA/files/, dev-perl/Crypt-OpenSSL-ECDSA/
Date: Wed, 09 Jan 2019 22:29:29
Message-Id: 1547072949.42aba792ddaaa6ce3608d232993078e01d9e7c4f.candrews@gentoo
1 commit: 42aba792ddaaa6ce3608d232993078e01d9e7c4f
2 Author: Craig Andrews <candrews <AT> gentoo <DOT> org>
3 AuthorDate: Wed Jan 9 15:45:50 2019 +0000
4 Commit: Craig Andrews <candrews <AT> gentoo <DOT> org>
5 CommitDate: Wed Jan 9 22:29:09 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=42aba792
7
8 dev-perl/Crypt-OpenSSL-ECDSA: OpenSSL 1.1 support
9
10 Closes: https://bugs.gentoo.org/674238
11 Package-Manager: Portage-2.3.54, Repoman-2.3.12
12 Signed-off-by: Craig Andrews <candrews <AT> gentoo.org>
13
14 .../Crypt-OpenSSL-ECDSA-0.80.0-r1.ebuild | 26 +++
15 ...L-ECDSA-0.80.0-0001-Port-to-OpenSSL-1.1.0.patch | 193 +++++++++++++++++++++
16 2 files changed, 219 insertions(+)
17
18 diff --git a/dev-perl/Crypt-OpenSSL-ECDSA/Crypt-OpenSSL-ECDSA-0.80.0-r1.ebuild b/dev-perl/Crypt-OpenSSL-ECDSA/Crypt-OpenSSL-ECDSA-0.80.0-r1.ebuild
19 new file mode 100644
20 index 00000000000..fbb5956d64c
21 --- /dev/null
22 +++ b/dev-perl/Crypt-OpenSSL-ECDSA/Crypt-OpenSSL-ECDSA-0.80.0-r1.ebuild
23 @@ -0,0 +1,26 @@
24 +# Copyright 1999-2019 Gentoo Authors
25 +# Distributed under the terms of the GNU General Public License v2
26 +
27 +EAPI=6
28 +
29 +DIST_AUTHOR=MIKEM
30 +DIST_VERSION=0.08
31 +inherit perl-module
32 +
33 +DESCRIPTION="OpenSSL ECDSA (Elliptic Curve Digital Signature Algorithm) Perl extension"
34 +SLOT="0"
35 +KEYWORDS="~amd64 ~x86"
36 +IUSE="libressl"
37 +
38 +RDEPEND="
39 + >=dev-perl/Crypt-OpenSSL-EC-0.50.0
40 + !libressl? ( dev-libs/openssl:0 )
41 + libressl? ( dev-libs/libressl )
42 +"
43 +DEPEND="${RDEPEND}
44 + virtual/perl-ExtUtils-MakeMaker
45 +"
46 +
47 +PATCHES=(
48 + "${FILESDIR}/${P}-0001-Port-to-OpenSSL-1.1.0.patch"
49 +)
50
51 diff --git a/dev-perl/Crypt-OpenSSL-ECDSA/files/Crypt-OpenSSL-ECDSA-0.80.0-0001-Port-to-OpenSSL-1.1.0.patch b/dev-perl/Crypt-OpenSSL-ECDSA/files/Crypt-OpenSSL-ECDSA-0.80.0-0001-Port-to-OpenSSL-1.1.0.patch
52 new file mode 100644
53 index 00000000000..071e60caefd
54 --- /dev/null
55 +++ b/dev-perl/Crypt-OpenSSL-ECDSA/files/Crypt-OpenSSL-ECDSA-0.80.0-0001-Port-to-OpenSSL-1.1.0.patch
56 @@ -0,0 +1,193 @@
57 +From 7a707a2bb0b0c6de1eb98cef74a5d1016f0e8c9a Mon Sep 17 00:00:00 2001
58 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@××××××.com>
59 +Date: Tue, 11 Oct 2016 16:15:43 +0200
60 +Subject: [PATCH] Port to OpenSSL 1.1.0
61 +MIME-Version: 1.0
62 +Content-Type: text/plain; charset=UTF-8
63 +Content-Transfer-Encoding: 8bit
64 +
65 +OpenSSL 1.1.0 hid ECDSA structure internals and provided methods
66 +instead.
67 +
68 +This patch uses the methods and provides their copies in the case of
69 +older OpenSSL. Because the new OpenSSL API, ECDSA_SIG_set0(), cannot
70 +set curve parameters individually and ECDSA_SIG_get0() returns yet
71 +another reference, it's necessary to duplicate the other unchanged
72 +paramater when calling set_r() or set_s().
73 +
74 +This patch also stops exporting ECDSA_METHOD functions that were
75 +removed from the new OpenSSL.
76 +
77 +CPAN RT#118330
78 +
79 +Signed-off-by: Petr Písař <ppisar@××××××.com>
80 +---
81 + ECDSA.xs | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++--------------
82 + 1 file changed, 61 insertions(+), 17 deletions(-)
83 +
84 +diff --git a/ECDSA.xs b/ECDSA.xs
85 +index 4016368..648303e 100644
86 +--- a/ECDSA.xs
87 ++++ b/ECDSA.xs
88 +@@ -7,9 +7,34 @@
89 +
90 + #include <openssl/ecdsa.h>
91 + #include <openssl/err.h>
92 ++#include <openssl/bn.h>
93 +
94 + #include "const-c.inc"
95 +
96 ++
97 ++#if (OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)) || LIBRESSL_VERSION_NUMBER >= 0x2070000fL
98 ++#include <openssl/ec.h>
99 ++#else
100 ++static void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr,
101 ++ const BIGNUM **ps) {
102 ++ if (pr != NULL)
103 ++ *pr = sig->r;
104 ++ if (ps != NULL)
105 ++ *ps = sig->s;
106 ++}
107 ++
108 ++static int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s)
109 ++{
110 ++ if (r == NULL || s == NULL)
111 ++ return 0;
112 ++ BN_clear_free(sig->r);
113 ++ BN_clear_free(sig->s);
114 ++ sig->r = r;
115 ++ sig->s = s;
116 ++ return 1;
117 ++}
118 ++#endif
119 ++
120 + MODULE = Crypt::OpenSSL::ECDSA PACKAGE = Crypt::OpenSSL::ECDSA
121 +
122 + PROTOTYPES: ENABLE
123 +@@ -17,7 +42,9 @@ INCLUDE: const-xs.inc
124 +
125 + BOOT:
126 + ERR_load_crypto_strings();
127 ++#if OPENSSL_VERSION_NUMBER >= 0x10002000L && OPENSSL_VERSION_NUMBER < 0x10100000L
128 + ERR_load_ECDSA_strings();
129 ++#endif
130 +
131 + #ECDSA_SIG *
132 + #ECDSA_SIG_new()
133 +@@ -61,10 +88,16 @@ ECDSA_do_verify(const unsigned char *dgst, const ECDSA_SIG *sig, EC_KEY* eckey);
134 + OUTPUT:
135 + RETVAL
136 +
137 +-# These ECDSA_METHOD functions only became available in 1.0.2
138 ++# These ECDSA_METHOD functions only became available in 1.0.2,
139 ++# but some of them removed again in 1.1.0.
140 +
141 + #if OPENSSL_VERSION_NUMBER >= 0x10002000L
142 +
143 ++int
144 ++ECDSA_size(const EC_KEY *eckey)
145 ++
146 ++#if OPENSSL_VERSION_NUMBER < 0x10100000L
147 ++
148 + const ECDSA_METHOD *
149 + ECDSA_OpenSSL()
150 +
151 +@@ -77,9 +110,6 @@ ECDSA_get_default_method()
152 + int
153 + ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth)
154 +
155 +-int
156 +-ECDSA_size(const EC_KEY *eckey)
157 +-
158 + ECDSA_METHOD *
159 + ECDSA_METHOD_new(ECDSA_METHOD *ecdsa_method=0)
160 +
161 +@@ -95,7 +125,7 @@ ECDSA_METHOD_set_name(ECDSA_METHOD *ecdsa_method, char *name)
162 + void
163 + ERR_load_ECDSA_strings()
164 +
165 +-
166 ++#endif
167 + #endif
168 +
169 +
170 +@@ -135,11 +165,13 @@ SV *
171 + get_r(ecdsa_sig)
172 + ECDSA_SIG *ecdsa_sig
173 + PREINIT:
174 ++ const BIGNUM *r;
175 + unsigned char *to;
176 + STRLEN len;
177 + CODE:
178 + to = malloc(sizeof(char) * 128);
179 +- len = BN_bn2bin(ecdsa_sig->r, to);
180 ++ ECDSA_SIG_get0(ecdsa_sig, &r, NULL);
181 ++ len = BN_bn2bin(r, to);
182 + RETVAL = newSVpvn((const char*)to, len);
183 + free(to);
184 + OUTPUT:
185 +@@ -149,11 +181,13 @@ SV *
186 + get_s(ecdsa_sig)
187 + ECDSA_SIG *ecdsa_sig
188 + PREINIT:
189 ++ const BIGNUM *s;
190 + unsigned char *to;
191 + STRLEN len;
192 + CODE:
193 + to = malloc(sizeof(char) * 128);
194 +- len = BN_bn2bin(ecdsa_sig->s, to);
195 ++ ECDSA_SIG_get0(ecdsa_sig, NULL, &s);
196 ++ len = BN_bn2bin(s, to);
197 + RETVAL = newSVpvn((const char*)to, len);
198 + free(to);
199 + OUTPUT:
200 +@@ -164,26 +198,36 @@ set_r(ecdsa_sig, r_SV)
201 + ECDSA_SIG *ecdsa_sig
202 + SV * r_SV
203 + PREINIT:
204 +- char *s;
205 ++ char *string;
206 + STRLEN len;
207 ++ BIGNUM *r;
208 ++ BIGNUM *s;
209 + CODE:
210 +- s = SvPV(r_SV, len);
211 +- if (ecdsa_sig->r)
212 +- BN_free(ecdsa_sig->r);
213 +- ecdsa_sig->r = BN_bin2bn((const unsigned char *)s, len, NULL);
214 ++ string = SvPV(r_SV, len);
215 ++ r = BN_bin2bn((const unsigned char *)string, len, NULL);
216 ++ ECDSA_SIG_get0(ecdsa_sig, NULL, (const BIGNUM**)&s);
217 ++ s = BN_dup(s);
218 ++ if (NULL == s)
219 ++ croak("Could not duplicate unchanged ECDSA paramater");
220 ++ ECDSA_SIG_set0(ecdsa_sig, r, s);
221 +
222 + void
223 + set_s(ecdsa_sig, s_SV)
224 + ECDSA_SIG *ecdsa_sig
225 + SV * s_SV
226 + PREINIT:
227 +- char *s;
228 ++ char *string;
229 + STRLEN len;
230 ++ BIGNUM *r;
231 ++ BIGNUM *s;
232 + CODE:
233 +- s = SvPV(s_SV, len);
234 +- if (ecdsa_sig->s)
235 +- BN_free(ecdsa_sig->s);
236 +- ecdsa_sig->s = BN_bin2bn((const unsigned char *)s, len, NULL);
237 ++ string = SvPV(s_SV, len);
238 ++ s = BN_bin2bn((const unsigned char *)string, len, NULL);
239 ++ ECDSA_SIG_get0(ecdsa_sig, (const BIGNUM**)&r, NULL);
240 ++ r = BN_dup(r);
241 ++ if (NULL == r)
242 ++ croak("Could not duplicate unchanged ECDSA paramater");
243 ++ ECDSA_SIG_set0(ecdsa_sig, r, s);
244 +
245 +
246 +
247 +--
248 +2.7.4
249 +