当前位置: 首页>>代码示例>>Python>>正文


Python ffi.NULL属性代码示例

本文整理汇总了Python中cryptography.hazmat.bindings._openssl.ffi.NULL属性的典型用法代码示例。如果您正苦于以下问题:Python ffi.NULL属性的具体用法?Python ffi.NULL怎么用?Python ffi.NULL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在cryptography.hazmat.bindings._openssl.ffi的用法示例。


在下文中一共展示了ffi.NULL属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _openssl_assert

# 需要导入模块: from cryptography.hazmat.bindings._openssl import ffi [as 别名]
# 或者: from cryptography.hazmat.bindings._openssl.ffi import NULL [as 别名]
def _openssl_assert(lib, ok):
    if not ok:
        errors = _consume_errors(lib)
        errors_with_text = []
        for err in errors:
            err_text_reason = ffi.string(
                lib.ERR_error_string(err.code, ffi.NULL)
            )
            errors_with_text.append(
                _OpenSSLErrorWithText(
                    err.code, err.lib, err.func, err.reason, err_text_reason
                )
            )

        raise InternalError(
            "Unknown OpenSSL error. This error is commonly encountered when "
            "another library is not cleaning up the OpenSSL error stack. If "
            "you are using cryptography with another library that uses "
            "OpenSSL try disabling it before reporting a bug. Otherwise "
            "please file an issue at https://github.com/pyca/cryptography/"
            "issues with information on how to reproduce "
            "this. ({0!r})".format(errors_with_text),
            errors_with_text
        ) 
开发者ID:DirceuSilvaLabs,项目名称:noc-orchestrator,代码行数:26,代码来源:binding.py

示例2: _register_osrandom_engine

# 需要导入模块: from cryptography.hazmat.bindings._openssl import ffi [as 别名]
# 或者: from cryptography.hazmat.bindings._openssl.ffi import NULL [as 别名]
def _register_osrandom_engine(cls):
        _openssl_assert(cls.lib, cls.lib.ERR_peek_error() == 0)

        engine = cls.lib.ENGINE_new()
        _openssl_assert(cls.lib, engine != cls.ffi.NULL)
        try:
            result = cls.lib.ENGINE_set_id(engine, cls._osrandom_engine_id)
            _openssl_assert(cls.lib, result == 1)
            result = cls.lib.ENGINE_set_name(engine, cls._osrandom_engine_name)
            _openssl_assert(cls.lib, result == 1)
            result = cls.lib.ENGINE_set_RAND(engine, cls._osrandom_method)
            _openssl_assert(cls.lib, result == 1)
            result = cls.lib.ENGINE_add(engine)
            if result != 1:
                errors = _consume_errors(cls.lib)
                _openssl_assert(
                    cls.lib,
                    errors[0].reason == cls.lib.ENGINE_R_CONFLICTING_ENGINE_ID
                )

        finally:
            result = cls.lib.ENGINE_free(engine)
            _openssl_assert(cls.lib, result == 1) 
开发者ID:DirceuSilvaLabs,项目名称:noc-orchestrator,代码行数:25,代码来源:binding.py

示例3: init_static_locks

# 需要导入模块: from cryptography.hazmat.bindings._openssl import ffi [as 别名]
# 或者: from cryptography.hazmat.bindings._openssl.ffi import NULL [as 别名]
def init_static_locks(cls):
        with cls._lock_init_lock:
            cls._ensure_ffi_initialized()

            if not cls._lock_cb_handle:
                wrapper = ffi_callback(
                    "void(int, int, const char *, int)",
                    name="Cryptography_locking_cb",
                )
                cls._lock_cb_handle = wrapper(cls._lock_cb)

            # Use Python's implementation if available, importing _ssl triggers
            # the setup for this.
            __import__("_ssl")

            if cls.lib.CRYPTO_get_locking_callback() != cls.ffi.NULL:
                return

            # If nothing else has setup a locking callback already, we set up
            # our own
            num_locks = cls.lib.CRYPTO_num_locks()
            cls._locks = [threading.Lock() for n in range(num_locks)]

            cls.lib.CRYPTO_set_locking_callback(cls._lock_cb_handle) 
开发者ID:DirceuSilvaLabs,项目名称:noc-orchestrator,代码行数:26,代码来源:binding.py

示例4: init_static_locks

# 需要导入模块: from cryptography.hazmat.bindings._openssl import ffi [as 别名]
# 或者: from cryptography.hazmat.bindings._openssl.ffi import NULL [as 别名]
def init_static_locks(cls):
        with cls._lock_init_lock:
            cls._ensure_ffi_initialized()
            # Use Python's implementation if available, importing _ssl triggers
            # the setup for this.
            __import__("_ssl")

            if cls.lib.CRYPTO_get_locking_callback() != cls.ffi.NULL:
                return

            # If nothing else has setup a locking callback already, we set up
            # our own
            res = lib._setup_ssl_threads()
            _openssl_assert(cls.lib, res == 1)


# OpenSSL is not thread safe until the locks are initialized. We call this
# method in module scope so that it executes with the import lock. On
# Pythons < 3.4 this import lock is a global lock, which can prevent a race
# condition registering the OpenSSL locks. On Python 3.4+ the import lock
# is per module so this approach will not work. 
开发者ID:deNULL,项目名称:RemoteTree,代码行数:23,代码来源:binding.py

示例5: init_static_locks

# 需要导入模块: from cryptography.hazmat.bindings._openssl import ffi [as 别名]
# 或者: from cryptography.hazmat.bindings._openssl.ffi import NULL [as 别名]
def init_static_locks(cls):
        with cls._lock_init_lock:
            cls._ensure_ffi_initialized()
            # Use Python's implementation if available, importing _ssl triggers
            # the setup for this.
            __import__("_ssl")

            if cls.lib.CRYPTO_get_locking_callback() != cls.ffi.NULL:
                return

            # If nothing else has setup a locking callback already, we set up
            # our own
            res = lib._setup_ssl_threads()
            _openssl_assert(cls.lib, res == 1) 
开发者ID:lordmuffin,项目名称:aws-cfn-plex,代码行数:16,代码来源:binding.py


注:本文中的cryptography.hazmat.bindings._openssl.ffi.NULL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。