def _get_openssl_libraries(platform): if os.environ.get("CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS", None): return [] # OpenSSL goes by a different library name on different operating systems. if platform == "win32" and compiler_type() == "msvc": return [ "libssl", "libcrypto", "advapi32", "crypt32", "gdi32", "user32", "ws2_32", ] else: # darwin, linux, mingw all use this path # In some circumstances, the order in which these libs are # specified on the linker command-line is significant; # libssl must come before libcrypto # (https://marc.info/?l=openssl-users&m=135361825921871) # -lpthread required due to usage of pthread an potential # existance of a static part containing e.g. pthread_atfork # (https://github.com/pyca/cryptography/issues/5084) if sys.platform == "zos": return ["ssl", "crypto"] else: return ["ssl", "crypto", "pthread"]
def _get_openssl_libraries(platform): if os.environ.get("CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS", None): return [] # OpenSSL goes by a different library name on different operating systems. if platform == "win32" and compiler_type() == "msvc": windows_link_legacy_openssl = os.environ.get( "CRYPTOGRAPHY_WINDOWS_LINK_LEGACY_OPENSSL", None ) if windows_link_legacy_openssl is None: # Link against the 1.1.0 names # CRYPTOGRAPHY_OPENSSL_110_OR_GREATER libs = ["libssl", "libcrypto"] else: # Link against the 1.0.2 and lower names libs = ["libeay32", "ssleay32"] return libs + ["advapi32", "crypt32", "gdi32", "user32", "ws2_32"] else: # darwin, linux, mingw all use this path # In some circumstances, the order in which these libs are # specified on the linker command-line is significant; # libssl must come before libcrypto # (https://marc.info/?l=openssl-users&m=135361825921871) # -lpthread required due to usage of pthread an potential # existance of a static part containing e.g. pthread_atfork # (https://github.com/pyca/cryptography/issues/5084) return ["ssl", "crypto", "pthread"]
def _get_openssl_libraries(platform): # OpenSSL goes by a different library name on different operating systems. if platform == "darwin": return _osx_libraries(os.environ.get("CRYPTOGRAPHY_OSX_NO_LINK_FLAGS")) elif platform == "win32": if compiler_type() == "msvc": libs = ["libeay32", "ssleay32"] else: libs = ["ssl", "crypto"] return libs + ["advapi32", "crypt32", "gdi32", "user32", "ws2_32"] else: # In some circumstances, the order in which these libs are # specified on the linker command-line is significant; # libssl must come before libcrypto # (http://marc.info/?l=openssl-users&m=135361825921871) return ["ssl", "crypto"]
def _get_openssl_libraries(platform): # OpenSSL goes by a different library name on different operating systems. if platform == "darwin": return _osx_libraries( os.environ.get("CRYPTOGRAPHY_OSX_NO_LINK_FLAGS") ) elif platform == "win32": if compiler_type() == "msvc": libs = ["libeay32", "ssleay32"] else: libs = ["ssl", "crypto"] return libs + ["advapi32", "crypt32", "gdi32", "user32", "ws2_32"] else: # In some circumstances, the order in which these libs are # specified on the linker command-line is significant; # libssl must come before libcrypto # (http://marc.info/?l=openssl-users&m=135361825921871) return ["ssl", "crypto"]
def _get_openssl_libraries(platform): if os.environ.get("CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS", None): return [] # OpenSSL goes by a different library name on different operating systems. if platform == "win32" and compiler_type() == "msvc": windows_link_legacy_openssl = os.environ.get( "CRYPTOGRAPHY_WINDOWS_LINK_LEGACY_OPENSSL", None) if windows_link_legacy_openssl is None: # Link against the 1.1.0 names libs = ["libssl", "libcrypto"] else: # Link against the 1.0.2 and lower names libs = ["libeay32", "ssleay32"] return libs + ["advapi32", "crypt32", "gdi32", "user32", "ws2_32"] else: # darwin, linux, mingw all use this path # In some circumstances, the order in which these libs are # specified on the linker command-line is significant; # libssl must come before libcrypto # (http://marc.info/?l=openssl-users&m=135361825921871) return ["ssl", "crypto"]
def _get_openssl_libraries(platform): if os.environ.get("CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS", None): return [] # OpenSSL goes by a different library name on different operating systems. if platform == "win32" and compiler_type() == "msvc": windows_link_legacy_openssl = os.environ.get( "CRYPTOGRAPHY_WINDOWS_LINK_LEGACY_OPENSSL", None ) if windows_link_legacy_openssl is None: # Link against the 1.1.0 names libs = ["libssl", "libcrypto"] else: # Link against the 1.0.2 and lower names libs = ["libeay32", "ssleay32"] return libs + ["advapi32", "crypt32", "gdi32", "user32", "ws2_32"] else: # darwin, linux, mingw all use this path # In some circumstances, the order in which these libs are # specified on the linker command-line is significant; # libssl must come before libcrypto # (http://marc.info/?l=openssl-users&m=135361825921871) return ["ssl", "crypto"]
def _get_openssl_libraries(platform): # OpenSSL goes by a different library name on different operating systems. if platform == "darwin": return _osx_libraries(os.environ.get("CRYPTOGRAPHY_OSX_NO_LINK_FLAGS")) elif platform == "win32": windows_link_openssl110 = os.environ.get( "CRYPTOGRAPHY_WINDOWS_LINK_OPENSSL110", None) if compiler_type() == "msvc": if windows_link_openssl110 is not None: # Link against the 1.1.0 names libs = ["libssl", "libcrypto"] else: # Link against the 1.0.2 and lower names libs = ["libeay32", "ssleay32"] else: # Support mingw, which behaves unix-like and prefixes "lib" libs = ["ssl", "crypto"] return libs + ["advapi32", "crypt32", "gdi32", "user32", "ws2_32"] else: # In some circumstances, the order in which these libs are # specified on the linker command-line is significant; # libssl must come before libcrypto # (http://marc.info/?l=openssl-users&m=135361825921871) return ["ssl", "crypto"]
"conf", "crypto", "dh", "dsa", "ec", "ecdh", "ecdsa", "engine", "err", "evp", "hmac", "nid", "objects", "ocsp", "opensslv", "pem", "pkcs12", "rand", "rsa", "ssl", "x509", "x509name", "x509v3", "x509_vfy", "pkcs7", "callbacks", ], libraries=_get_openssl_libraries(sys.platform), extra_link_args=extra_link_args(compiler_type()), )
"fips", "hmac", "nid", "objects", "ocsp", "opensslv", "osrandom_engine", "pem", "pkcs12", "rand", "rsa", "ssl", "x509", "x509name", "x509v3", "x509_vfy", "pkcs7", "callbacks", ], libraries=_get_openssl_libraries(sys.platform), # These args are passed here so that we only do Wconversion checks on the # code we're compiling and not on cffi itself (as passing -Wconversion in # CFLAGS would do). We set no error on sign convesrion because some # function signatures in OpenSSL have changed from long -> unsigned long # in the past. Since that isn't a precision issue we don't care. # When we drop support for CRYPTOGRAPHY_OPENSSL_LESS_THAN_110 we can # revisit this. extra_compile_args=_extra_compile_args(sys.platform), extra_link_args=extra_link_args(compiler_type()), )
# This file is dual licensed under the terms of the Apache License, Version # 2.0, and the BSD License. See the LICENSE file in the root of this repository # for complete details. from __future__ import absolute_import, division, print_function import os from _cffi_src.utils import build_ffi, compiler_type, extra_link_args with open(os.path.join(os.path.dirname(__file__), "hazmat_src/padding.h")) as f: types = f.read() with open(os.path.join(os.path.dirname(__file__), "hazmat_src/padding.c")) as f: functions = f.read() ffi = build_ffi( module_name="_padding", cdef_source=types, verify_source=functions, extra_link_args=extra_link_args(compiler_type()) )