Gentoo Archives: gentoo-commits

From: Quentin Retornaz <gentoo@××××××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/proj/libressl:master commit in: dev-python/cryptography/, dev-python/cryptography/files/
Date: Sun, 29 Aug 2021 00:20:41
Message-Id: 1630196119.55a857913c2023e09e176db34d0178794d2f3ca7.quentin@gentoo
1 commit: 55a857913c2023e09e176db34d0178794d2f3ca7
2 Author: orbea <orbea <AT> riseup <DOT> net>
3 AuthorDate: Tue Aug 24 16:20:22 2021 +0000
4 Commit: Quentin Retornaz <gentoo <AT> retornaz <DOT> com>
5 CommitDate: Sun Aug 29 00:15:19 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/proj/libressl.git/commit/?id=55a85791
7
8 dev-python/cryptography: new package
9
10 Signed-off-by: orbea <orbea <AT> riseup.net>
11 Closes: https://github.com/gentoo/libressl/pull/349
12 Signed-off-by: Quentin Retornaz <gentoo <AT> retornaz.com>
13
14 .../cryptography/cryptography-3.4.7-r2.ebuild | 77 ++++++
15 .../files/cryptography-3.4.7-libressl.patch | 155 +++++++++++
16 .../files/cryptography-3.4.7-py310.patch | 301 +++++++++++++++++++++
17 3 files changed, 533 insertions(+)
18
19 diff --git a/dev-python/cryptography/cryptography-3.4.7-r2.ebuild b/dev-python/cryptography/cryptography-3.4.7-r2.ebuild
20 new file mode 100644
21 index 0000000..b3d9bc1
22 --- /dev/null
23 +++ b/dev-python/cryptography/cryptography-3.4.7-r2.ebuild
24 @@ -0,0 +1,77 @@
25 +# Copyright 1999-2021 Gentoo Authors
26 +# Distributed under the terms of the GNU General Public License v2
27 +
28 +EAPI=7
29 +
30 +PYTHON_COMPAT=( python3_{7..10} pypy3 )
31 +PYTHON_REQ_USE="threads(+)"
32 +
33 +inherit distutils-r1 multiprocessing
34 +
35 +VEC_P=cryptography_vectors-${PV}
36 +DESCRIPTION="Library providing cryptographic recipes and primitives"
37 +HOMEPAGE="https://github.com/pyca/cryptography/ https://pypi.org/project/cryptography/"
38 +SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz
39 + test? ( mirror://pypi/c/cryptography_vectors/${VEC_P}.tar.gz )"
40 +
41 +LICENSE="|| ( Apache-2.0 BSD )"
42 +SLOT="0"
43 +KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~m68k ~mips ppc ppc64 ~riscv sparc x86"
44 +
45 +RDEPEND="
46 + $(python_gen_cond_dep '
47 + >=dev-python/cffi-1.8:=[${PYTHON_USEDEP}]
48 + ' 'python*')
49 + "
50 +BDEPEND="
51 + test? (
52 + >=dev-python/hypothesis-1.11.4[${PYTHON_USEDEP}]
53 + dev-python/iso8601[${PYTHON_USEDEP}]
54 + dev-python/pretend[${PYTHON_USEDEP}]
55 + dev-python/pyasn1-modules[${PYTHON_USEDEP}]
56 + dev-python/pytz[${PYTHON_USEDEP}]
57 + dev-python/pytest-subtests[${PYTHON_USEDEP}]
58 + dev-python/pytest-xdist[${PYTHON_USEDEP}]
59 + )"
60 +
61 +distutils_enable_tests pytest
62 +
63 +DEPEND="
64 + >=dev-libs/openssl-1.0.2o-r6:0=
65 + "
66 +RDEPEND+=${DEPEND}
67 +
68 +PATCHES=(
69 + "${FILESDIR}/${P}-py310.patch"
70 + "${FILESDIR}/${P}-libressl.patch"
71 +)
72 +
73 +src_prepare() {
74 + default
75 +
76 + # avoid automagic dependency on dev-libs/openssl[sslv3]
77 + # https://bugs.gentoo.org/789450
78 + export CPPFLAGS="${CPPFLAGS} -DOPENSSL_NO_SSL3_METHOD=1"
79 +
80 + # work around availability macros not supported in GCC (yet)
81 + if [[ ${CHOST} == *-darwin* ]] ; then
82 + local darwinok=0
83 + if [[ ${CHOST##*-darwin} -ge 16 ]] ; then
84 + darwinok=1
85 + fi
86 + sed -i -e 's/__builtin_available(macOS 10\.12, \*)/'"${darwinok}"'/' \
87 + src/_cffi_src/openssl/src/osrandom_engine.c || die
88 + fi
89 +
90 + # this version does not really use Rust, it just creates a dummy
91 + # extension to break stuff
92 + export CRYPTOGRAPHY_DONT_BUILD_RUST=1
93 + sed -e 's:from setuptools_rust import RustExtension:pass:' \
94 + -e '/setup_requires/d' \
95 + -i setup.py || die
96 +}
97 +
98 +python_test() {
99 + local -x PYTHONPATH=${PYTHONPATH}:${WORKDIR}/${VEC_P}
100 + epytest -n "$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")"
101 +}
102
103 diff --git a/dev-python/cryptography/files/cryptography-3.4.7-libressl.patch b/dev-python/cryptography/files/cryptography-3.4.7-libressl.patch
104 new file mode 100644
105 index 0000000..abbb149
106 --- /dev/null
107 +++ b/dev-python/cryptography/files/cryptography-3.4.7-libressl.patch
108 @@ -0,0 +1,155 @@
109 +From e540d3285f92d1e8d7d6249b8a6e36948e619fe4 Mon Sep 17 00:00:00 2001
110 +From: Charlie Li <git@×××××××.info>
111 +Date: Mon, 19 Apr 2021 17:25:22 -0400
112 +Subject: [PATCH 1/4] LibreSSL 3.3.2 supports SSL_OP_NO_DTLS*
113 +
114 +While here, bump CI
115 +---
116 + src/_cffi_src/openssl/cryptography.py | 9 +++++++++
117 + src/_cffi_src/openssl/ssl.py | 2 +-
118 + 2 files changed, 10 insertions(+), 1 deletions(-)
119 +
120 +diff --git a/src/_cffi_src/openssl/cryptography.py b/src/_cffi_src/openssl/cryptography.py
121 +index e2b5a13235a..ab296343906 100644
122 +--- a/src/_cffi_src/openssl/cryptography.py
123 ++++ b/src/_cffi_src/openssl/cryptography.py
124 +@@ -32,6 +32,13 @@
125 + #include <Winsock2.h>
126 + #endif
127 +
128 ++#if CRYPTOGRAPHY_IS_LIBRESSL
129 ++ #define CRYPTOGRAPHY_LIBRESSL_332_OR_GREATER \
130 ++ (LIBRESSL_VERSION_NUMBER >= 0x3030200f)
131 ++#else
132 ++#define CRYPTOGRAPHY_LIBRESSL_332_OR_GREATER (0)
133 ++#endif
134 ++
135 + #define CRYPTOGRAPHY_OPENSSL_110F_OR_GREATER \
136 + (OPENSSL_VERSION_NUMBER >= 0x1010006f && !CRYPTOGRAPHY_IS_LIBRESSL)
137 +
138 +@@ -59,6 +66,8 @@
139 + static const int CRYPTOGRAPHY_NEEDS_OSRANDOM_ENGINE;
140 +
141 + static const int CRYPTOGRAPHY_IS_LIBRESSL;
142 ++
143 ++static const int CRYPTOGRAPHY_LIBRESSL_332_OR_GREATER;
144 + """
145 +
146 + FUNCTIONS = """
147 +diff --git a/src/_cffi_src/openssl/ssl.py b/src/_cffi_src/openssl/ssl.py
148 +index 11a7d63a961..23cbc5ff425 100644
149 +--- a/src/_cffi_src/openssl/ssl.py
150 ++++ b/src/_cffi_src/openssl/ssl.py
151 +@@ -585,7 +585,7 @@
152 + static const long TLS_ST_OK = 0;
153 + #endif
154 +
155 +-#if CRYPTOGRAPHY_IS_LIBRESSL
156 ++#if CRYPTOGRAPHY_IS_LIBRESSL && !CRYPTOGRAPHY_LIBRESSL_332_OR_GREATER
157 + static const long SSL_OP_NO_DTLSv1 = 0;
158 + static const long SSL_OP_NO_DTLSv1_2 = 0;
159 + long (*DTLS_set_link_mtu)(SSL *, long) = NULL;
160 +
161 +From ec2a1701a34a28783e2353befb9c5c057f65d782 Mon Sep 17 00:00:00 2001
162 +From: Charlie Li <git@×××××××.info>
163 +Date: Mon, 19 Apr 2021 17:41:33 -0400
164 +Subject: [PATCH 2/4] Fix preprocessor guards for LibreSSL's SSL_OP_NO_DTLS*
165 +
166 +DTLS_set_link_mtu and DTLS_get_link_min_mtu are not part of 3.3.2
167 +---
168 + src/_cffi_src/openssl/ssl.py | 4 +++-
169 + 1 file changed, 3 insertions(+), 1 deletion(-)
170 +
171 +diff --git a/src/_cffi_src/openssl/ssl.py b/src/_cffi_src/openssl/ssl.py
172 +index 23cbc5ff425..a0b1641454e 100644
173 +--- a/src/_cffi_src/openssl/ssl.py
174 ++++ b/src/_cffi_src/openssl/ssl.py
175 +@@ -585,9 +585,11 @@
176 + static const long TLS_ST_OK = 0;
177 + #endif
178 +
179 +-#if CRYPTOGRAPHY_IS_LIBRESSL && !CRYPTOGRAPHY_LIBRESSL_332_OR_GREATER
180 ++#if CRYPTOGRAPHY_IS_LIBRESSL
181 ++#if !CRYPTOGRAPHY_LIBRESSL_332_OR_GREATER
182 + static const long SSL_OP_NO_DTLSv1 = 0;
183 + static const long SSL_OP_NO_DTLSv1_2 = 0;
184 ++#endif
185 + long (*DTLS_set_link_mtu)(SSL *, long) = NULL;
186 + long (*DTLS_get_link_min_mtu)(SSL *) = NULL;
187 + #endif
188 +
189 +From 7d03d4477b4f06a3e1ec412afa0f2e4edb4e3893 Mon Sep 17 00:00:00 2001
190 +From: Charlie Li <git@×××××××.info>
191 +Date: Mon, 19 Apr 2021 18:16:14 -0400
192 +Subject: [PATCH 3/4] Switch to LESS_THAN context for LibreSSL 3.3.2
193 +
194 +While here, fix indents
195 +---
196 + src/_cffi_src/openssl/cryptography.py | 8 ++++----
197 + src/_cffi_src/openssl/ssl.py | 2 +-
198 + 2 files changed, 5 insertions(+), 5 deletions(-)
199 +
200 +diff --git a/src/_cffi_src/openssl/cryptography.py b/src/_cffi_src/openssl/cryptography.py
201 +index ab296343906..0b468c8d719 100644
202 +--- a/src/_cffi_src/openssl/cryptography.py
203 ++++ b/src/_cffi_src/openssl/cryptography.py
204 +@@ -33,10 +33,10 @@
205 + #endif
206 +
207 + #if CRYPTOGRAPHY_IS_LIBRESSL
208 +- #define CRYPTOGRAPHY_LIBRESSL_332_OR_GREATER \
209 +- (LIBRESSL_VERSION_NUMBER >= 0x3030200f)
210 ++#define CRYPTOGRAPHY_LIBRESSL_LESS_THAN_332 \
211 ++ (LIBRESSL_VERSION_NUMBER < 0x3030200f)
212 + #else
213 +-#define CRYPTOGRAPHY_LIBRESSL_332_OR_GREATER (0)
214 ++#define CRYPTOGRAPHY_LIBRESSL_LESS_THAN_332 (0)
215 + #endif
216 +
217 + #define CRYPTOGRAPHY_OPENSSL_110F_OR_GREATER \
218 +@@ -67,7 +67,7 @@
219 +
220 + static const int CRYPTOGRAPHY_IS_LIBRESSL;
221 +
222 +-static const int CRYPTOGRAPHY_LIBRESSL_332_OR_GREATER;
223 ++static const int CRYPTOGRAPHY_LIBRESSL_LESS_THAN_332;
224 + """
225 +
226 + FUNCTIONS = """
227 +diff --git a/src/_cffi_src/openssl/ssl.py b/src/_cffi_src/openssl/ssl.py
228 +index a0b1641454e..081ef041fa3 100644
229 +--- a/src/_cffi_src/openssl/ssl.py
230 ++++ b/src/_cffi_src/openssl/ssl.py
231 +@@ -586,7 +586,7 @@
232 + #endif
233 +
234 + #if CRYPTOGRAPHY_IS_LIBRESSL
235 +-#if !CRYPTOGRAPHY_LIBRESSL_332_OR_GREATER
236 ++#if CRYPTOGRAPHY_LIBRESSL_LESS_THAN_332
237 + static const long SSL_OP_NO_DTLSv1 = 0;
238 + static const long SSL_OP_NO_DTLSv1_2 = 0;
239 + #endif
240 +
241 +From 843ef2dbfff33ea3018b04d926ccd6d1b629ef87 Mon Sep 17 00:00:00 2001
242 +From: Charlie Li <git@×××××××.info>
243 +Date: Mon, 19 Apr 2021 18:22:20 -0400
244 +Subject: [PATCH 4/4] Remove extra C variable declaration
245 +
246 +The variable is not actually used from Python
247 +---
248 + src/_cffi_src/openssl/cryptography.py | 2 --
249 + 1 file changed, 2 deletions(-)
250 +
251 +diff --git a/src/_cffi_src/openssl/cryptography.py b/src/_cffi_src/openssl/cryptography.py
252 +index 0b468c8d719..b9c7a793b3b 100644
253 +--- a/src/_cffi_src/openssl/cryptography.py
254 ++++ b/src/_cffi_src/openssl/cryptography.py
255 +@@ -66,8 +66,6 @@
256 + static const int CRYPTOGRAPHY_NEEDS_OSRANDOM_ENGINE;
257 +
258 + static const int CRYPTOGRAPHY_IS_LIBRESSL;
259 +-
260 +-static const int CRYPTOGRAPHY_LIBRESSL_LESS_THAN_332;
261 + """
262 +
263 + FUNCTIONS = """
264
265 diff --git a/dev-python/cryptography/files/cryptography-3.4.7-py310.patch b/dev-python/cryptography/files/cryptography-3.4.7-py310.patch
266 new file mode 100644
267 index 0000000..d961af8
268 --- /dev/null
269 +++ b/dev-python/cryptography/files/cryptography-3.4.7-py310.patch
270 @@ -0,0 +1,301 @@
271 +diff --git a/src/cryptography/exceptions.py b/src/cryptography/exceptions.py
272 +index f5860590..3bd98d82 100644
273 +--- a/src/cryptography/exceptions.py
274 ++++ b/src/cryptography/exceptions.py
275 +@@ -3,10 +3,10 @@
276 + # for complete details.
277 +
278 +
279 +-from enum import Enum
280 ++from cryptography import utils
281 +
282 +
283 +-class _Reasons(Enum):
284 ++class _Reasons(utils.Enum):
285 + BACKEND_MISSING_INTERFACE = 0
286 + UNSUPPORTED_HASH = 1
287 + UNSUPPORTED_CIPHER = 2
288 +diff --git a/src/cryptography/hazmat/primitives/_serialization.py b/src/cryptography/hazmat/primitives/_serialization.py
289 +index 96a5ed9b..160a6b89 100644
290 +--- a/src/cryptography/hazmat/primitives/_serialization.py
291 ++++ b/src/cryptography/hazmat/primitives/_serialization.py
292 +@@ -3,13 +3,14 @@
293 + # for complete details.
294 +
295 + import abc
296 +-from enum import Enum
297 ++
298 ++from cryptography import utils
299 +
300 + # This exists to break an import cycle. These classes are normally accessible
301 + # from the serialization module.
302 +
303 +
304 +-class Encoding(Enum):
305 ++class Encoding(utils.Enum):
306 + PEM = "PEM"
307 + DER = "DER"
308 + OpenSSH = "OpenSSH"
309 +@@ -18,14 +19,14 @@ class Encoding(Enum):
310 + SMIME = "S/MIME"
311 +
312 +
313 +-class PrivateFormat(Enum):
314 ++class PrivateFormat(utils.Enum):
315 + PKCS8 = "PKCS8"
316 + TraditionalOpenSSL = "TraditionalOpenSSL"
317 + Raw = "Raw"
318 + OpenSSH = "OpenSSH"
319 +
320 +
321 +-class PublicFormat(Enum):
322 ++class PublicFormat(utils.Enum):
323 + SubjectPublicKeyInfo = "X.509 subjectPublicKeyInfo with PKCS#1"
324 + PKCS1 = "Raw PKCS#1"
325 + OpenSSH = "OpenSSH"
326 +@@ -34,7 +35,7 @@ class PublicFormat(Enum):
327 + UncompressedPoint = "X9.62 Uncompressed Point"
328 +
329 +
330 +-class ParameterFormat(Enum):
331 ++class ParameterFormat(utils.Enum):
332 + PKCS3 = "PKCS3"
333 +
334 +
335 +diff --git a/src/cryptography/hazmat/primitives/kdf/kbkdf.py b/src/cryptography/hazmat/primitives/kdf/kbkdf.py
336 +index ac36474f..75fe7d51 100644
337 +--- a/src/cryptography/hazmat/primitives/kdf/kbkdf.py
338 ++++ b/src/cryptography/hazmat/primitives/kdf/kbkdf.py
339 +@@ -4,7 +4,6 @@
340 +
341 +
342 + import typing
343 +-from enum import Enum
344 +
345 + from cryptography import utils
346 + from cryptography.exceptions import (
347 +@@ -19,11 +18,11 @@ from cryptography.hazmat.primitives import constant_time, hashes, hmac
348 + from cryptography.hazmat.primitives.kdf import KeyDerivationFunction
349 +
350 +
351 +-class Mode(Enum):
352 ++class Mode(utils.Enum):
353 + CounterMode = "ctr"
354 +
355 +
356 +-class CounterLocation(Enum):
357 ++class CounterLocation(utils.Enum):
358 + BeforeFixed = "before_fixed"
359 + AfterFixed = "after_fixed"
360 +
361 +diff --git a/src/cryptography/hazmat/primitives/serialization/pkcs7.py b/src/cryptography/hazmat/primitives/serialization/pkcs7.py
362 +index bcd9e330..57aac7e3 100644
363 +--- a/src/cryptography/hazmat/primitives/serialization/pkcs7.py
364 ++++ b/src/cryptography/hazmat/primitives/serialization/pkcs7.py
365 +@@ -3,8 +3,8 @@
366 + # for complete details.
367 +
368 + import typing
369 +-from enum import Enum
370 +
371 ++from cryptography import utils
372 + from cryptography import x509
373 + from cryptography.hazmat.backends import _get_backend
374 + from cryptography.hazmat.primitives import hashes, serialization
375 +@@ -35,7 +35,7 @@ _ALLOWED_PRIVATE_KEY_TYPES = typing.Union[
376 + ]
377 +
378 +
379 +-class PKCS7Options(Enum):
380 ++class PKCS7Options(utils.Enum):
381 + Text = "Add text/plain MIME type"
382 + Binary = "Don't translate input data into canonical MIME format"
383 + DetachedSignature = "Don't embed data in the PKCS7 structure"
384 +diff --git a/src/cryptography/utils.py b/src/cryptography/utils.py
385 +index ef0fc443..9e571cfd 100644
386 +--- a/src/cryptography/utils.py
387 ++++ b/src/cryptography/utils.py
388 +@@ -4,6 +4,7 @@
389 +
390 +
391 + import abc
392 ++import enum
393 + import inspect
394 + import sys
395 + import typing
396 +@@ -162,3 +163,13 @@ int_from_bytes = deprecated(
397 + "int_from_bytes is deprecated, use int.from_bytes instead",
398 + DeprecatedIn34,
399 + )
400 ++
401 ++
402 ++# Python 3.10 changed representation of enums. We use well-defined object
403 ++# representation and string representation from Python 3.9.
404 ++class Enum(enum.Enum):
405 ++ def __repr__(self):
406 ++ return f"<{self.__class__.__name__}.{self._name_}: {self._value_!r}>"
407 ++
408 ++ def __str__(self):
409 ++ return f"{self.__class__.__name__}.{self._name_}"
410 +diff --git a/src/cryptography/x509/base.py b/src/cryptography/x509/base.py
411 +index 5505fa3b..e3846c33 100644
412 +--- a/src/cryptography/x509/base.py
413 ++++ b/src/cryptography/x509/base.py
414 +@@ -7,9 +7,9 @@ import abc
415 + import datetime
416 + import os
417 + import typing
418 +-from enum import Enum
419 +
420 + from cryptography.hazmat._types import _PRIVATE_KEY_TYPES, _PUBLIC_KEY_TYPES
421 ++from cryptography import utils
422 + from cryptography.hazmat.backends import _get_backend
423 + from cryptography.hazmat.primitives import hashes, serialization
424 + from cryptography.hazmat.primitives.asymmetric import (
425 +@@ -66,7 +66,7 @@ def _convert_to_naive_utc_time(time: datetime.datetime) -> datetime.datetime:
426 + return time
427 +
428 +
429 +-class Version(Enum):
430 ++class Version(utils.Enum):
431 + v1 = 0
432 + v3 = 2
433 +
434 +diff --git a/src/cryptography/x509/certificate_transparency.py b/src/cryptography/x509/certificate_transparency.py
435 +index d51bee92..d80f051a 100644
436 +--- a/src/cryptography/x509/certificate_transparency.py
437 ++++ b/src/cryptography/x509/certificate_transparency.py
438 +@@ -5,15 +5,16 @@
439 +
440 + import abc
441 + import datetime
442 +-from enum import Enum
443 +
444 ++from cryptography import utils
445 +
446 +-class LogEntryType(Enum):
447 ++
448 ++class LogEntryType(utils.Enum):
449 + X509_CERTIFICATE = 0
450 + PRE_CERTIFICATE = 1
451 +
452 +
453 +-class Version(Enum):
454 ++class Version(utils.Enum):
455 + v1 = 0
456 +
457 +
458 +diff --git a/src/cryptography/x509/extensions.py b/src/cryptography/x509/extensions.py
459 +index 6cae016a..742f1fa2 100644
460 +--- a/src/cryptography/x509/extensions.py
461 ++++ b/src/cryptography/x509/extensions.py
462 +@@ -8,7 +8,6 @@ import datetime
463 + import hashlib
464 + import ipaddress
465 + import typing
466 +-from enum import Enum
467 +
468 + from cryptography import utils
469 + from cryptography.hazmat._der import (
470 +@@ -634,7 +633,7 @@ class DistributionPoint(object):
471 + crl_issuer = utils.read_only_property("_crl_issuer")
472 +
473 +
474 +-class ReasonFlags(Enum):
475 ++class ReasonFlags(utils.Enum):
476 + unspecified = "unspecified"
477 + key_compromise = "keyCompromise"
478 + ca_compromise = "cACompromise"
479 +@@ -978,7 +977,7 @@ class TLSFeature(ExtensionType):
480 + return hash(tuple(self._features))
481 +
482 +
483 +-class TLSFeatureType(Enum):
484 ++class TLSFeatureType(utils.Enum):
485 + # status_request is defined in RFC 6066 and is used for what is commonly
486 + # called OCSP Must-Staple when present in the TLS Feature extension in an
487 + # X.509 certificate.
488 +diff --git a/src/cryptography/x509/name.py b/src/cryptography/x509/name.py
489 +index a579aa21..9069a9f4 100644
490 +--- a/src/cryptography/x509/name.py
491 ++++ b/src/cryptography/x509/name.py
492 +@@ -3,14 +3,13 @@
493 + # for complete details.
494 +
495 + import typing
496 +-from enum import Enum
497 +
498 + from cryptography import utils
499 + from cryptography.hazmat.backends import _get_backend
500 + from cryptography.x509.oid import NameOID, ObjectIdentifier
501 +
502 +
503 +-class _ASN1Type(Enum):
504 ++class _ASN1Type(utils.Enum):
505 + UTF8String = 12
506 + NumericString = 18
507 + PrintableString = 19
508 +diff --git a/src/cryptography/x509/ocsp.py b/src/cryptography/x509/ocsp.py
509 +index 1c5de73e..bcf210c1 100644
510 +--- a/src/cryptography/x509/ocsp.py
511 ++++ b/src/cryptography/x509/ocsp.py
512 +@@ -6,8 +6,8 @@
513 + import abc
514 + import datetime
515 + import typing
516 +-from enum import Enum
517 +
518 ++from cryptography import utils
519 + from cryptography import x509
520 + from cryptography.hazmat.primitives import hashes, serialization
521 + from cryptography.x509.base import (
522 +@@ -27,12 +27,12 @@ _OIDS_TO_HASH = {
523 + }
524 +
525 +
526 +-class OCSPResponderEncoding(Enum):
527 ++class OCSPResponderEncoding(utils.Enum):
528 + HASH = "By Hash"
529 + NAME = "By Name"
530 +
531 +
532 +-class OCSPResponseStatus(Enum):
533 ++class OCSPResponseStatus(utils.Enum):
534 + SUCCESSFUL = 0
535 + MALFORMED_REQUEST = 1
536 + INTERNAL_ERROR = 2
537 +@@ -58,7 +58,7 @@ def _verify_algorithm(algorithm):
538 + )
539 +
540 +
541 +-class OCSPCertStatus(Enum):
542 ++class OCSPCertStatus(utils.Enum):
543 + GOOD = 0
544 + REVOKED = 1
545 + UNKNOWN = 2
546 +diff --git a/tests/test_cryptography_utils.py b/tests/test_cryptography_utils.py
547 +index 6b795e0c..803997ac 100644
548 +--- a/tests/test_cryptography_utils.py
549 ++++ b/tests/test_cryptography_utils.py
550 +@@ -2,6 +2,7 @@
551 + # 2.0, and the BSD License. See the LICENSE file in the root of this repository
552 + # for complete details.
553 +
554 ++import enum
555 + import typing
556 +
557 + import pytest
558 +@@ -51,3 +52,13 @@ class TestCachedProperty(object):
559 + assert len(accesses) == 1
560 + assert t.t == 14
561 + assert len(accesses) == 1
562 ++
563 ++
564 ++def test_enum():
565 ++ class TestEnum(utils.Enum):
566 ++ value = "something"
567 ++
568 ++ assert issubclass(TestEnum, enum.Enum)
569 ++ assert isinstance(TestEnum.value, enum.Enum)
570 ++ assert repr(TestEnum.value) == "<TestEnum.value: 'something'>"
571 ++ assert str(TestEnum.value) == "TestEnum.value"