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


Python _Reasons.UNSUPPORTED_ELLIPTIC_CURVE属性代码示例

本文整理汇总了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 
开发者ID:DirceuSilvaLabs,项目名称:noc-orchestrator,代码行数:21,代码来源:backend.py

示例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
            ) 
开发者ID:deNULL,项目名称:RemoteTree,代码行数:25,代码来源:backend.py

示例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
            ) 
开发者ID:DirceuSilvaLabs,项目名称:noc-orchestrator,代码行数:28,代码来源:backend.py

示例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
        ) 
开发者ID:DirceuSilvaLabs,项目名称:noc-orchestrator,代码行数:13,代码来源:multibackend.py

示例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
        ) 
开发者ID:DirceuSilvaLabs,项目名称:noc-orchestrator,代码行数:13,代码来源:multibackend.py

示例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
        ) 
开发者ID:DirceuSilvaLabs,项目名称:noc-orchestrator,代码行数:13,代码来源:multibackend.py


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