本文整理匯總了Python中cryptography.exceptions._Reasons.UNSUPPORTED_ELLIPTIC_CURVE屬性的典型用法代碼示例。如果您正苦於以下問題:Python _Reasons.UNSUPPORTED_ELLIPTIC_CURVE屬性的具體用法?Python _Reasons.UNSUPPORTED_ELLIPTIC_CURVE怎麽用?Python _Reasons.UNSUPPORTED_ELLIPTIC_CURVE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類cryptography.exceptions._Reasons
的用法示例。
在下文中一共展示了_Reasons.UNSUPPORTED_ELLIPTIC_CURVE屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _elliptic_curve_to_nid
# 需要導入模塊: from cryptography.exceptions import _Reasons [as 別名]
# 或者: from cryptography.exceptions._Reasons import UNSUPPORTED_ELLIPTIC_CURVE [as 別名]
def _elliptic_curve_to_nid(self, curve):
"""
Get the NID for a curve name.
"""
curve_aliases = {
"secp192r1": "prime192v1",
"secp256r1": "prime256v1"
}
curve_name = curve_aliases.get(curve.name, curve.name)
curve_nid = self._lib.OBJ_sn2nid(curve_name.encode())
if curve_nid == self._lib.NID_undef:
raise UnsupportedAlgorithm(
"{0} is not a supported elliptic curve".format(curve.name),
_Reasons.UNSUPPORTED_ELLIPTIC_CURVE
)
return curve_nid
示例2: generate_elliptic_curve_private_key
# 需要導入模塊: from cryptography.exceptions import _Reasons [as 別名]
# 或者: from cryptography.exceptions._Reasons import UNSUPPORTED_ELLIPTIC_CURVE [as 別名]
def generate_elliptic_curve_private_key(self, curve):
"""
Generate a new private key on the named curve.
"""
if self.elliptic_curve_supported(curve):
curve_nid = self._elliptic_curve_to_nid(curve)
ec_cdata = self._lib.EC_KEY_new_by_curve_name(curve_nid)
self.openssl_assert(ec_cdata != self._ffi.NULL)
ec_cdata = self._ffi.gc(ec_cdata, self._lib.EC_KEY_free)
res = self._lib.EC_KEY_generate_key(ec_cdata)
self.openssl_assert(res == 1)
evp_pkey = self._ec_cdata_to_evp_pkey(ec_cdata)
return _EllipticCurvePrivateKey(self, ec_cdata, evp_pkey)
else:
raise UnsupportedAlgorithm(
"Backend object does not support {0}.".format(curve.name),
_Reasons.UNSUPPORTED_ELLIPTIC_CURVE
)
示例3: generate_elliptic_curve_private_key
# 需要導入模塊: from cryptography.exceptions import _Reasons [as 別名]
# 或者: from cryptography.exceptions._Reasons import UNSUPPORTED_ELLIPTIC_CURVE [as 別名]
def generate_elliptic_curve_private_key(self, curve):
"""
Generate a new private key on the named curve.
"""
if self.elliptic_curve_supported(curve):
curve_nid = self._elliptic_curve_to_nid(curve)
ec_cdata = self._lib.EC_KEY_new_by_curve_name(curve_nid)
self.openssl_assert(ec_cdata != self._ffi.NULL)
ec_cdata = self._ffi.gc(ec_cdata, self._lib.EC_KEY_free)
res = self._lib.EC_KEY_generate_key(ec_cdata)
self.openssl_assert(res == 1)
res = self._lib.EC_KEY_check_key(ec_cdata)
self.openssl_assert(res == 1)
evp_pkey = self._ec_cdata_to_evp_pkey(ec_cdata)
return _EllipticCurvePrivateKey(self, ec_cdata, evp_pkey)
else:
raise UnsupportedAlgorithm(
"Backend object does not support {0}.".format(curve.name),
_Reasons.UNSUPPORTED_ELLIPTIC_CURVE
)
示例4: generate_elliptic_curve_private_key
# 需要導入模塊: from cryptography.exceptions import _Reasons [as 別名]
# 或者: from cryptography.exceptions._Reasons import UNSUPPORTED_ELLIPTIC_CURVE [as 別名]
def generate_elliptic_curve_private_key(self, curve):
for b in self._filtered_backends(EllipticCurveBackend):
try:
return b.generate_elliptic_curve_private_key(curve)
except UnsupportedAlgorithm:
continue
raise UnsupportedAlgorithm(
"This backend does not support this elliptic curve.",
_Reasons.UNSUPPORTED_ELLIPTIC_CURVE
)
示例5: load_elliptic_curve_private_numbers
# 需要導入模塊: from cryptography.exceptions import _Reasons [as 別名]
# 或者: from cryptography.exceptions._Reasons import UNSUPPORTED_ELLIPTIC_CURVE [as 別名]
def load_elliptic_curve_private_numbers(self, numbers):
for b in self._filtered_backends(EllipticCurveBackend):
try:
return b.load_elliptic_curve_private_numbers(numbers)
except UnsupportedAlgorithm:
continue
raise UnsupportedAlgorithm(
"This backend does not support this elliptic curve.",
_Reasons.UNSUPPORTED_ELLIPTIC_CURVE
)
示例6: load_elliptic_curve_public_numbers
# 需要導入模塊: from cryptography.exceptions import _Reasons [as 別名]
# 或者: from cryptography.exceptions._Reasons import UNSUPPORTED_ELLIPTIC_CURVE [as 別名]
def load_elliptic_curve_public_numbers(self, numbers):
for b in self._filtered_backends(EllipticCurveBackend):
try:
return b.load_elliptic_curve_public_numbers(numbers)
except UnsupportedAlgorithm:
continue
raise UnsupportedAlgorithm(
"This backend does not support this elliptic curve.",
_Reasons.UNSUPPORTED_ELLIPTIC_CURVE
)