本文整理汇总了Python中cryptography.exceptions._Reasons.UNSUPPORTED_SERIALIZATION属性的典型用法代码示例。如果您正苦于以下问题:Python _Reasons.UNSUPPORTED_SERIALIZATION属性的具体用法?Python _Reasons.UNSUPPORTED_SERIALIZATION怎么用?Python _Reasons.UNSUPPORTED_SERIALIZATION使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类cryptography.exceptions._Reasons
的用法示例。
在下文中一共展示了_Reasons.UNSUPPORTED_SERIALIZATION属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: private_bytes
# 需要导入模块: from cryptography.exceptions import _Reasons [as 别名]
# 或者: from cryptography.exceptions._Reasons import UNSUPPORTED_SERIALIZATION [as 别名]
def private_bytes(self, encoding, format, encryption_algorithm):
if format is not serialization.PrivateFormat.PKCS8:
raise ValueError(
"DH private keys support only PKCS8 serialization"
)
if not self._backend._lib.Cryptography_HAS_EVP_PKEY_DHX:
q = self._backend._ffi.new("BIGNUM **")
self._backend._lib.DH_get0_pqg(self._dh_cdata,
self._backend._ffi.NULL,
q,
self._backend._ffi.NULL)
if q[0] != self._backend._ffi.NULL:
raise UnsupportedAlgorithm(
"DH X9.42 serialization is not supported",
_Reasons.UNSUPPORTED_SERIALIZATION)
return self._backend._private_key_bytes(
encoding,
format,
encryption_algorithm,
self._evp_pkey,
self._dh_cdata
)
示例2: public_bytes
# 需要导入模块: from cryptography.exceptions import _Reasons [as 别名]
# 或者: from cryptography.exceptions._Reasons import UNSUPPORTED_SERIALIZATION [as 别名]
def public_bytes(self, encoding, format):
if format is not serialization.PublicFormat.SubjectPublicKeyInfo:
raise ValueError(
"DH public keys support only "
"SubjectPublicKeyInfo serialization"
)
if not self._backend._lib.Cryptography_HAS_EVP_PKEY_DHX:
q = self._backend._ffi.new("BIGNUM **")
self._backend._lib.DH_get0_pqg(self._dh_cdata,
self._backend._ffi.NULL,
q,
self._backend._ffi.NULL)
if q[0] != self._backend._ffi.NULL:
raise UnsupportedAlgorithm(
"DH X9.42 serialization is not supported",
_Reasons.UNSUPPORTED_SERIALIZATION)
return self._backend._public_key_bytes(
encoding,
format,
self,
self._evp_pkey,
None
)
示例3: parameter_bytes
# 需要导入模块: from cryptography.exceptions import _Reasons [as 别名]
# 或者: from cryptography.exceptions._Reasons import UNSUPPORTED_SERIALIZATION [as 别名]
def parameter_bytes(self, encoding, format):
if format is not serialization.ParameterFormat.PKCS3:
raise ValueError(
"Only PKCS3 serialization is supported"
)
if not self._backend._lib.Cryptography_HAS_EVP_PKEY_DHX:
q = self._backend._ffi.new("BIGNUM **")
self._backend._lib.DH_get0_pqg(self._dh_cdata,
self._backend._ffi.NULL,
q,
self._backend._ffi.NULL)
if q[0] != self._backend._ffi.NULL:
raise UnsupportedAlgorithm(
"DH X9.42 serialization is not supported",
_Reasons.UNSUPPORTED_SERIALIZATION)
return self._backend._parameter_bytes(
encoding,
format,
self._dh_cdata
)
示例4: load_pem_private_key
# 需要导入模块: from cryptography.exceptions import _Reasons [as 别名]
# 或者: from cryptography.exceptions._Reasons import UNSUPPORTED_SERIALIZATION [as 别名]
def load_pem_private_key(self, data, password):
for b in self._filtered_backends(PEMSerializationBackend):
return b.load_pem_private_key(data, password)
raise UnsupportedAlgorithm(
"This backend does not support this key serialization.",
_Reasons.UNSUPPORTED_SERIALIZATION
)
示例5: load_pem_public_key
# 需要导入模块: from cryptography.exceptions import _Reasons [as 别名]
# 或者: from cryptography.exceptions._Reasons import UNSUPPORTED_SERIALIZATION [as 别名]
def load_pem_public_key(self, data):
for b in self._filtered_backends(PEMSerializationBackend):
return b.load_pem_public_key(data)
raise UnsupportedAlgorithm(
"This backend does not support this key serialization.",
_Reasons.UNSUPPORTED_SERIALIZATION
)
示例6: load_der_private_key
# 需要导入模块: from cryptography.exceptions import _Reasons [as 别名]
# 或者: from cryptography.exceptions._Reasons import UNSUPPORTED_SERIALIZATION [as 别名]
def load_der_private_key(self, data, password):
for b in self._filtered_backends(DERSerializationBackend):
return b.load_der_private_key(data, password)
raise UnsupportedAlgorithm(
"This backend does not support this key serialization.",
_Reasons.UNSUPPORTED_SERIALIZATION
)
示例7: load_der_public_key
# 需要导入模块: from cryptography.exceptions import _Reasons [as 别名]
# 或者: from cryptography.exceptions._Reasons import UNSUPPORTED_SERIALIZATION [as 别名]
def load_der_public_key(self, data):
for b in self._filtered_backends(DERSerializationBackend):
return b.load_der_public_key(data)
raise UnsupportedAlgorithm(
"This backend does not support this key serialization.",
_Reasons.UNSUPPORTED_SERIALIZATION
)