| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
from __future__ import absolute_import, division, print_function |
| 6 |
|
| 7 |
import os |
| 8 |
import sys |
| 9 |
|
| 10 |
from _cffi_src.utils import ( |
| 11 |
build_ffi_for_binding, compiler_type, extra_link_args |
| 12 |
) |
| 13 |
|
| 14 |
|
| 15 |
def _get_openssl_libraries(platform): |
| 16 |
if os.environ.get("CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS", None): |
| 17 |
return [] |
| 18 |
|
| 19 |
if platform == "win32" and compiler_type() == "msvc": |
| 20 |
windows_link_legacy_openssl = os.environ.get( |
| 21 |
"CRYPTOGRAPHY_WINDOWS_LINK_LEGACY_OPENSSL", None |
| 22 |
) |
| 23 |
if windows_link_legacy_openssl is None: |
| 24 |
|
| 25 |
libs = ["libssl", "libcrypto"] |
| 26 |
else: |
| 27 |
|
| 28 |
libs = ["libeay32", "ssleay32"] |
| 29 |
return libs + ["advapi32", "crypt32", "gdi32", "user32", "ws2_32"] |
| 30 |
else: |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
return ["ssl", "crypto"] |
| 37 |
|
| 38 |
|
| 39 |
def _extra_compile_args(platform): |
| 40 |
""" |
| 41 |
We set -Wconversion args here so that we only do Wconversion checks on the |
| 42 |
code we're compiling and not on cffi itself (as passing -Wconversion in |
| 43 |
CFLAGS would do). We set no error on sign conversion because some |
| 44 |
function signatures in OpenSSL have changed from long -> unsigned long |
| 45 |
in the past. Since that isn't a precision issue we don't care. |
| 46 |
When we drop support for CRYPTOGRAPHY_OPENSSL_LESS_THAN_110 we can |
| 47 |
revisit this. |
| 48 |
""" |
| 49 |
if platform not in ["win32", "hp-ux11", "sunos5"]: |
| 50 |
return ["-Wconversion", "-Wno-error=sign-conversion"] |
| 51 |
else: |
| 52 |
return [] |
| 53 |
|
| 54 |
|
| 55 |
ffi = build_ffi_for_binding( |
| 56 |
module_name="_openssl", |
| 57 |
module_prefix="_cffi_src.openssl.", |
| 58 |
modules=[ |
| 59 |
|
| 60 |
"cryptography", |
| 61 |
|
| 62 |
|
| 63 |
"provider", |
| 64 |
"asn1", |
| 65 |
"bignum", |
| 66 |
"bio", |
| 67 |
"cmac", |
| 68 |
"crypto", |
| 69 |
"ct", |
| 70 |
"dh", |
| 71 |
"dsa", |
| 72 |
"ec", |
| 73 |
"ecdh", |
| 74 |
"ecdsa", |
| 75 |
"engine", |
| 76 |
"err", |
| 77 |
"evp", |
| 78 |
"fips", |
| 79 |
"hmac", |
| 80 |
"nid", |
| 81 |
"objects", |
| 82 |
"ocsp", |
| 83 |
"opensslv", |
| 84 |
"pem", |
| 85 |
"pkcs12", |
| 86 |
"rand", |
| 87 |
"rsa", |
| 88 |
"ssl", |
| 89 |
"x509", |
| 90 |
"x509name", |
| 91 |
"x509v3", |
| 92 |
"x509_vfy", |
| 93 |
"pkcs7", |
| 94 |
"callbacks", |
| 95 |
], |
| 96 |
libraries=_get_openssl_libraries(sys.platform), |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
extra_compile_args=_extra_compile_args(sys.platform), |
| 105 |
extra_link_args=extra_link_args(compiler_type()), |
| 106 |
) |