本文整理汇总了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
)
示例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
)
示例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)
示例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.")