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


Python hashes.HashAlgorithm方法代码示例

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


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

示例1: __init__

# 需要导入模块: from cryptography.hazmat.primitives import hashes [as 别名]
# 或者: from cryptography.hazmat.primitives.hashes import HashAlgorithm [as 别名]
def __init__(self, key, algorithm, backend, ctx=None):
        if not isinstance(backend, HMACBackend):
            raise UnsupportedAlgorithm(
                "Backend object does not implement HMACBackend.",
                _Reasons.BACKEND_MISSING_INTERFACE
            )

        if not isinstance(algorithm, hashes.HashAlgorithm):
            raise TypeError("Expected instance of hashes.HashAlgorithm.")
        self._algorithm = algorithm

        self._backend = backend
        self._key = key
        if ctx is None:
            self._ctx = self._backend.create_hmac_ctx(key, self.algorithm)
        else:
            self._ctx = ctx 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:19,代码来源:hmac.py

示例2: sign

# 需要导入模块: from cryptography.hazmat.primitives import hashes [as 别名]
# 或者: from cryptography.hazmat.primitives.hashes import HashAlgorithm [as 别名]
def sign(self, private_key, algorithm):
        from cryptography.hazmat.backends.openssl.backend import backend
        if self._response is None:
            raise ValueError("You must add a response before signing")
        if self._responder_id is None:
            raise ValueError("You must add a responder_id before signing")

        if isinstance(private_key,
                      (ed25519.Ed25519PrivateKey, ed448.Ed448PrivateKey)):
            if algorithm is not None:
                raise ValueError(
                    "algorithm must be None when signing via ed25519 or ed448"
                )
        elif not isinstance(algorithm, hashes.HashAlgorithm):
            raise TypeError("Algorithm must be a registered hash algorithm.")

        return backend.create_ocsp_response(
            OCSPResponseStatus.SUCCESSFUL, self, private_key, algorithm
        ) 
开发者ID:tp4a,项目名称:teleport,代码行数:21,代码来源:ocsp.py

示例3: __init__

# 需要导入模块: from cryptography.hazmat.primitives import hashes [as 别名]
# 或者: from cryptography.hazmat.primitives.hashes import HashAlgorithm [as 别名]
def __init__(self, mgf, algorithm, label):
        if not isinstance(algorithm, hashes.HashAlgorithm):
            raise TypeError("Expected instance of hashes.HashAlgorithm.")

        self._mgf = mgf
        self._algorithm = algorithm
        self._label = label 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:9,代码来源:padding.py

示例4: __init__

# 需要导入模块: from cryptography.hazmat.primitives import hashes [as 别名]
# 或者: from cryptography.hazmat.primitives.hashes import HashAlgorithm [as 别名]
def __init__(self, algorithm):
        if not isinstance(algorithm, hashes.HashAlgorithm):
            raise TypeError("Expected instance of HashAlgorithm.")

        self._algorithm = algorithm
        self._digest_size = algorithm.digest_size 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:8,代码来源:utils.py

示例5: signature_hash_algorithm

# 需要导入模块: from cryptography.hazmat.primitives import hashes [as 别名]
# 或者: from cryptography.hazmat.primitives.hashes import HashAlgorithm [as 别名]
def signature_hash_algorithm(self):
        """
        Returns a HashAlgorithm corresponding to the type of the digest signed
        """ 
开发者ID:tp4a,项目名称:teleport,代码行数:6,代码来源:ocsp.py

示例6: __init__

# 需要导入模块: from cryptography.hazmat.primitives import hashes [as 别名]
# 或者: from cryptography.hazmat.primitives.hashes import HashAlgorithm [as 别名]
def __init__(self, algorithm):
        if not isinstance(algorithm, hashes.HashAlgorithm):
            raise TypeError("Expected instance of hashes.HashAlgorithm.")

        self._algorithm = algorithm 
开发者ID:tp4a,项目名称:teleport,代码行数:7,代码来源:padding.py


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