本文整理匯總了Python中cryptography.hazmat.bindings.openssl.binding.Binding方法的典型用法代碼示例。如果您正苦於以下問題:Python binding.Binding方法的具體用法?Python binding.Binding怎麽用?Python binding.Binding使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cryptography.hazmat.bindings.openssl.binding
的用法示例。
在下文中一共展示了binding.Binding方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _openssl_get_supported_curves
# 需要導入模塊: from cryptography.hazmat.bindings.openssl import binding [as 別名]
# 或者: from cryptography.hazmat.bindings.openssl.binding import Binding [as 別名]
def _openssl_get_supported_curves():
if hasattr(_openssl_get_supported_curves, '_curves'):
return _openssl_get_supported_curves._curves
# use cryptography's cffi bindings to get an array of curve names
b = Binding()
cn = b.lib.EC_get_builtin_curves(b.ffi.NULL, 0)
cs = b.ffi.new('EC_builtin_curve[]', cn)
b.lib.EC_get_builtin_curves(cs, cn)
# store the result so we don't have to do all of this every time
curves = { b.ffi.string(b.lib.OBJ_nid2sn(c.nid)).decode('utf-8') for c in cs }
# Ed25519 and X25519 are always present in cryptography>=2.6
# The python cryptography lib provides a different interface for these curves,
# so they are handled differently in the ECDHPriv/Pub and EdDSAPriv/Pub classes
curves |= {'X25519', 'ed25519'}
_openssl_get_supported_curves._curves = curves
return curves
示例2: __init__
# 需要導入模塊: from cryptography.hazmat.bindings.openssl import binding [as 別名]
# 或者: from cryptography.hazmat.bindings.openssl.binding import Binding [as 別名]
def __init__(self):
self._binding = binding.Binding()
self._ffi = self._binding.ffi
self._lib = self._binding.lib
# Set the default string mask for encoding ASN1 strings to UTF8. This
# is the default for newer OpenSSLs for several years and is
# recommended in RFC 2459.
res = self._lib.ASN1_STRING_set_default_mask_asc(b"utf8only")
self.openssl_assert(res == 1)
self._cipher_registry = {}
self._register_default_ciphers()
self.activate_osrandom_engine()
示例3: __init__
# 需要導入模塊: from cryptography.hazmat.bindings.openssl import binding [as 別名]
# 或者: from cryptography.hazmat.bindings.openssl.binding import Binding [as 別名]
def __init__(self):
self._binding = binding.Binding()
self._ffi = self._binding.ffi
self._lib = self._binding.lib
self._cipher_registry = {}
self._register_default_ciphers()
self.activate_osrandom_engine()
self._dh_types = [self._lib.EVP_PKEY_DH]
if self._lib.Cryptography_HAS_EVP_PKEY_DHX:
self._dh_types.append(self._lib.EVP_PKEY_DHX)