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


Python _Reasons.UNSUPPORTED_HASH属性代码示例

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


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

示例1: __init__

# 需要导入模块: from cryptography.exceptions import _Reasons [as 别名]
# 或者: from cryptography.exceptions._Reasons import UNSUPPORTED_HASH [as 别名]
def __init__(self, backend, algorithm, ctx=None):
        self._algorithm = algorithm

        self._backend = backend

        if ctx is None:
            ctx = self._backend._lib.Cryptography_EVP_MD_CTX_new()
            ctx = self._backend._ffi.gc(
                ctx, self._backend._lib.Cryptography_EVP_MD_CTX_free
            )
            evp_md = self._backend._lib.EVP_get_digestbyname(
                algorithm.name.encode("ascii"))
            if evp_md == self._backend._ffi.NULL:
                raise UnsupportedAlgorithm(
                    "{0} is not a supported hash on this backend.".format(
                        algorithm.name),
                    _Reasons.UNSUPPORTED_HASH
                )
            res = self._backend._lib.EVP_DigestInit_ex(ctx, evp_md,
                                                       self._backend._ffi.NULL)
            self._backend.openssl_assert(res != 0)

        self._ctx = ctx 
开发者ID:DirceuSilvaLabs,项目名称:noc-orchestrator,代码行数:25,代码来源:hashes.py

示例2: __init__

# 需要导入模块: from cryptography.exceptions import _Reasons [as 别名]
# 或者: from cryptography.exceptions._Reasons import UNSUPPORTED_HASH [as 别名]
def __init__(self, backend, algorithm, ctx=None):
        self._algorithm = algorithm
        self._backend = backend

        if ctx is None:
            try:
                methods = self._backend._hash_mapping[self.algorithm.name]
            except KeyError:
                raise UnsupportedAlgorithm(
                    "{0} is not a supported hash on this backend.".format(
                        algorithm.name),
                    _Reasons.UNSUPPORTED_HASH
                )
            ctx = self._backend._ffi.new(methods.ctx)
            res = methods.hash_init(ctx)
            assert res == 1

        self._ctx = ctx 
开发者ID:DirceuSilvaLabs,项目名称:noc-orchestrator,代码行数:20,代码来源:hashes.py

示例3: __init__

# 需要导入模块: from cryptography.exceptions import _Reasons [as 别名]
# 或者: from cryptography.exceptions._Reasons import UNSUPPORTED_HASH [as 别名]
def __init__(self, backend, algorithm, ctx=None):
        self._algorithm = algorithm

        self._backend = backend

        if ctx is None:
            ctx = self._backend._lib.Cryptography_EVP_MD_CTX_new()
            ctx = self._backend._ffi.gc(
                ctx, self._backend._lib.Cryptography_EVP_MD_CTX_free
            )
            name = self._backend._build_openssl_digest_name(algorithm)
            evp_md = self._backend._lib.EVP_get_digestbyname(name)
            if evp_md == self._backend._ffi.NULL:
                raise UnsupportedAlgorithm(
                    "{0} is not a supported hash on this backend.".format(
                        name),
                    _Reasons.UNSUPPORTED_HASH
                )
            res = self._backend._lib.EVP_DigestInit_ex(ctx, evp_md,
                                                       self._backend._ffi.NULL)
            self._backend.openssl_assert(res != 0)

        self._ctx = ctx 
开发者ID:lordmuffin,项目名称:aws-cfn-plex,代码行数:25,代码来源:hashes.py

示例4: __init__

# 需要导入模块: from cryptography.exceptions import _Reasons [as 别名]
# 或者: from cryptography.exceptions._Reasons import UNSUPPORTED_HASH [as 别名]
def __init__(self, backend, algorithm, ctx=None):
        self._algorithm = algorithm

        self._backend = backend

        if ctx is None:
            ctx = self._backend._lib.EVP_MD_CTX_create()
            ctx = self._backend._ffi.gc(ctx,
                                        self._backend._lib.EVP_MD_CTX_destroy)
            evp_md = self._backend._lib.EVP_get_digestbyname(
                algorithm.name.encode("ascii"))
            if evp_md == self._backend._ffi.NULL:
                raise UnsupportedAlgorithm(
                    "{0} is not a supported hash on this backend.".format(
                        algorithm.name),
                    _Reasons.UNSUPPORTED_HASH
                )
            res = self._backend._lib.EVP_DigestInit_ex(ctx, evp_md,
                                                       self._backend._ffi.NULL)
            assert res != 0

        self._ctx = ctx 
开发者ID:yuxiaokui,项目名称:Intranet-Penetration,代码行数:24,代码来源:hashes.py

示例5: __init__

# 需要导入模块: from cryptography.exceptions import _Reasons [as 别名]
# 或者: from cryptography.exceptions._Reasons import UNSUPPORTED_HASH [as 别名]
def __init__(self, backend, algorithm, ctx=None):
        self._algorithm = algorithm

        self._backend = backend

        if ctx is None:
            ctx = self._backend._lib.EVP_MD_CTX_create()
            ctx = self._backend._ffi.gc(ctx,
                                        self._backend._lib.EVP_MD_CTX_destroy)
            evp_md = self._backend._lib.EVP_get_digestbyname(
                algorithm.name.encode("ascii"))
            if evp_md == self._backend._ffi.NULL:
                raise UnsupportedAlgorithm(
                    "{0} is not a supported hash on this backend.".format(
                        algorithm.name),
                    _Reasons.UNSUPPORTED_HASH
                )
            res = self._backend._lib.EVP_DigestInit_ex(ctx, evp_md,
                                                       self._backend._ffi.NULL)
            self._backend.openssl_assert(res != 0)

        self._ctx = ctx 
开发者ID:satwikkansal,项目名称:OneClickDTU,代码行数:24,代码来源:hashes.py

示例6: __init__

# 需要导入模块: from cryptography.exceptions import _Reasons [as 别名]
# 或者: from cryptography.exceptions._Reasons import UNSUPPORTED_HASH [as 别名]
def __init__(self, backend, algorithm, ctx=None):
        self._algorithm = algorithm
        self._backend = backend

        if ctx is None:
            try:
                ckm = self._backend._hash_mapping[self.algorithm.name]
            except KeyError:
                raise UnsupportedAlgorithm(
                    "{0} is not a supported hash on this backend.".format(
                        algorithm.name),
                    _Reasons.UNSUPPORTED_HASH
                )

            mech = self._backend._ffi.new("CK_MECHANISM *")
            mech.mechanism = ckm
            ctx = self._backend._session_pool.acquire_and_init(
                backend, self._backend._lib.C_DigestInit, mech
            )

        self._ctx = ctx 
开发者ID:reaperhulk,项目名称:cryptography-pkcs11,代码行数:23,代码来源:hashes.py

示例7: __init__

# 需要导入模块: from cryptography.exceptions import _Reasons [as 别名]
# 或者: from cryptography.exceptions._Reasons import UNSUPPORTED_HASH [as 别名]
def __init__(self, backend, algorithm, ctx=None):
        self._algorithm = algorithm
        self._backend = backend

        if ctx is None:
            try:
                ctx = self._backend._lib.ring_digest_context_new(
                    self._backend._hash_mapping[self.algorithm.name]()
                )
                ctx = self._backend._ffi.gc(
                    ctx, self._backend._lib.ring_digest_context_delete
                )
            except KeyError:
                raise UnsupportedAlgorithm(
                    "{0} is not a supported hash on this backend.".format(
                        algorithm.name),
                    _Reasons.UNSUPPORTED_HASH
                )

        self._ctx = ctx 
开发者ID:reaperhulk,项目名称:cryptography-ring,代码行数:22,代码来源:hashes.py

示例8: derive_pbkdf2_hmac

# 需要导入模块: from cryptography.exceptions import _Reasons [as 别名]
# 或者: from cryptography.exceptions._Reasons import UNSUPPORTED_HASH [as 别名]
def derive_pbkdf2_hmac(self, algorithm, length, salt, iterations,
                           key_material):
        buf = self._ffi.new("char[]", length)
        if self._lib.Cryptography_HAS_PBKDF2_HMAC:
            evp_md = self._lib.EVP_get_digestbyname(
                algorithm.name.encode("ascii"))
            self.openssl_assert(evp_md != self._ffi.NULL)
            res = self._lib.PKCS5_PBKDF2_HMAC(
                key_material,
                len(key_material),
                salt,
                len(salt),
                iterations,
                evp_md,
                length,
                buf
            )
            self.openssl_assert(res == 1)
        else:
            if not isinstance(algorithm, hashes.SHA1):
                raise UnsupportedAlgorithm(
                    "This version of OpenSSL only supports PBKDF2HMAC with "
                    "SHA1.",
                    _Reasons.UNSUPPORTED_HASH
                )
            res = self._lib.PKCS5_PBKDF2_HMAC_SHA1(
                key_material,
                len(key_material),
                salt,
                len(salt),
                iterations,
                length,
                buf
            )
            self.openssl_assert(res == 1)

        return self._ffi.buffer(buf)[:] 
开发者ID:DirceuSilvaLabs,项目名称:noc-orchestrator,代码行数:39,代码来源:backend.py

示例9: create_hash_ctx

# 需要导入模块: from cryptography.exceptions import _Reasons [as 别名]
# 或者: from cryptography.exceptions._Reasons import UNSUPPORTED_HASH [as 别名]
def create_hash_ctx(self, algorithm):
        for b in self._filtered_backends(HashBackend):
            try:
                return b.create_hash_ctx(algorithm)
            except UnsupportedAlgorithm:
                pass
        raise UnsupportedAlgorithm(
            "{0} is not a supported hash on this backend.".format(
                algorithm.name),
            _Reasons.UNSUPPORTED_HASH
        ) 
开发者ID:DirceuSilvaLabs,项目名称:noc-orchestrator,代码行数:13,代码来源:multibackend.py

示例10: create_hmac_ctx

# 需要导入模块: from cryptography.exceptions import _Reasons [as 别名]
# 或者: from cryptography.exceptions._Reasons import UNSUPPORTED_HASH [as 别名]
def create_hmac_ctx(self, key, algorithm):
        for b in self._filtered_backends(HMACBackend):
            try:
                return b.create_hmac_ctx(key, algorithm)
            except UnsupportedAlgorithm:
                pass
        raise UnsupportedAlgorithm(
            "{0} is not a supported hash on this backend.".format(
                algorithm.name),
            _Reasons.UNSUPPORTED_HASH
        ) 
开发者ID:DirceuSilvaLabs,项目名称:noc-orchestrator,代码行数:13,代码来源:multibackend.py

示例11: derive_pbkdf2_hmac

# 需要导入模块: from cryptography.exceptions import _Reasons [as 别名]
# 或者: from cryptography.exceptions._Reasons import UNSUPPORTED_HASH [as 别名]
def derive_pbkdf2_hmac(self, algorithm, length, salt, iterations,
                           key_material):
        for b in self._filtered_backends(PBKDF2HMACBackend):
            try:
                return b.derive_pbkdf2_hmac(
                    algorithm, length, salt, iterations, key_material
                )
            except UnsupportedAlgorithm:
                pass
        raise UnsupportedAlgorithm(
            "{0} is not a supported hash on this backend.".format(
                algorithm.name),
            _Reasons.UNSUPPORTED_HASH
        ) 
开发者ID:lordmuffin,项目名称:aws-cfn-plex,代码行数:16,代码来源:multibackend.py


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