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


Python _Reasons.UNSUPPORTED_CIPHER属性代码示例

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


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

示例1: create_symmetric_encryption_ctx

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

示例2: create_symmetric_decryption_ctx

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

示例3: create_cmac_ctx

# 需要导入模块: from cryptography.exceptions import _Reasons [as 别名]
# 或者: from cryptography.exceptions._Reasons import UNSUPPORTED_CIPHER [as 别名]
def create_cmac_ctx(self, algorithm):
        for b in self._filtered_backends(CMACBackend):
            try:
                return b.create_cmac_ctx(algorithm)
            except UnsupportedAlgorithm:
                pass
        raise UnsupportedAlgorithm("This backend does not support CMAC.",
                                   _Reasons.UNSUPPORTED_CIPHER) 
开发者ID:DirceuSilvaLabs,项目名称:noc-orchestrator,代码行数:10,代码来源:multibackend.py

示例4: _handle_key_loading_error

# 需要导入模块: from cryptography.exceptions import _Reasons [as 别名]
# 或者: from cryptography.exceptions._Reasons import UNSUPPORTED_CIPHER [as 别名]
def _handle_key_loading_error(self):
        errors = self._consume_errors()

        if not errors:
            raise ValueError("Could not unserialize key data.")

        elif errors[0][1:] in (
            (
                self._lib.ERR_LIB_EVP,
                self._lib.EVP_F_EVP_DECRYPTFINAL_EX,
                self._lib.EVP_R_BAD_DECRYPT
            ),
            (
                self._lib.ERR_LIB_PKCS12,
                self._lib.PKCS12_F_PKCS12_PBE_CRYPT,
                self._lib.PKCS12_R_PKCS12_CIPHERFINAL_ERROR,
            )
        ):
            raise ValueError("Bad decrypt. Incorrect password?")

        elif errors[0][1:] in (
            (
                self._lib.ERR_LIB_PEM,
                self._lib.PEM_F_PEM_GET_EVP_CIPHER_INFO,
                self._lib.PEM_R_UNSUPPORTED_ENCRYPTION
            ),

            (
                self._lib.ERR_LIB_EVP,
                self._lib.EVP_F_EVP_PBE_CIPHERINIT,
                self._lib.EVP_R_UNKNOWN_PBE_ALGORITHM
            )
        ):
            raise UnsupportedAlgorithm(
                "PEM data is encrypted with an unsupported cipher",
                _Reasons.UNSUPPORTED_CIPHER
            )

        elif any(
            error[1:] == (
                self._lib.ERR_LIB_EVP,
                self._lib.EVP_F_EVP_PKCS82PKEY,
                self._lib.EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM
            )
            for error in errors
        ):
            raise UnsupportedAlgorithm(
                "Unsupported public key algorithm.",
                _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM
            )

        else:
            assert errors[0][1] in (
                self._lib.ERR_LIB_EVP,
                self._lib.ERR_LIB_PEM,
                self._lib.ERR_LIB_ASN1,
            )
            raise ValueError("Could not unserialize key data.") 
开发者ID:DirceuSilvaLabs,项目名称:noc-orchestrator,代码行数:60,代码来源:backend.py


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