HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/lib/python3.10/site-packages/ecdsa/__pycache__/curves.cpython-310.pyc
o

�hg>�@s�ddlmZddlmZddlmZmZmZmZddl	m
Z
mZmZddl
mZmZgd�ZdZd	ZGd
d�de�ZGdd
�d
�Zedejejdd�Zedejejdd�Zedejejdd�Zedejej dd�Z!edej"ej#dd�Z$edej%ej&dd�Z'ed ej(ej)d!d"�Z*ed#ej+ej,d$d%�Z-ed&ej.ej/d'd(�Z0ed)ej1ej2d*d+�Z3ed,ej4ej5d-d.�Z6ed/ej7ej8d0d1�Z9ed2ej:ej;d3d4�Z<ed5ej=ej>d6d7�Z?ed8ej@ejAd9d:�ZBed;ejCejDd<d=�ZEed>ejFejGd?d@�ZHedAejIejJdBdC�ZKedDejLejMdEdF�ZNedGejOejPdHdI�ZQedJejRejSdKdL�ZTedMejUejVdNdO�ZWedPejXejYdQdR�ZZedSej[ej\dTdU�Z]edVej^ej_dW�Z`edXejaejbdY�Zce$e'e*e-e0e3e6e<eBeHeNeTeZeeee!e`ece9e?eEeKeQeWe]gZddZd[�Zed\d]�Zfd^S)_�)�division)�PY2�)�der�ecdsa�
ellipticcurve�eddsa)�orderlen�number_to_string�string_to_number)�normalise_bytes�
bit_length)"�UnknownCurveErrorr	�Curve�	SECP112r1�	SECP112r2�	SECP128r1�	SECP160r1�NIST192p�NIST224p�NIST256p�NIST384p�NIST521p�curves�
find_curve�
curve_by_name�	SECP256k1�BRAINPOOLP160r1�BRAINPOOLP160t1�BRAINPOOLP192r1�BRAINPOOLP192t1�BRAINPOOLP224r1�BRAINPOOLP224t1�BRAINPOOLP256r1�BRAINPOOLP256t1�BRAINPOOLP320r1�BRAINPOOLP320t1�BRAINPOOLP384r1�BRAINPOOLP384t1�BRAINPOOLP512r1�BRAINPOOLP512t1�PRIME_FIELD_OID�CHARACTERISTIC_TWO_FIELD_OID�Ed25519�Ed448)r��H�='rr)rr/r0r1rr/c@seZdZdS)rN)�__name__�
__module__�__qualname__�r5r5�?/usr/local/CyberCP/lib/python3.10/site-packages/ecdsa/curves.pyr5src@s^eZdZddd�Zdd�Zdd�Zdd	�Zddd�Zdd
d�Ze	ddd��Z
eddd��ZdS)rNcCs�||_||_||_||_|��|_t|tj�r)t|�	��ddd|_
|j
|_nt|j�|_
dt|�	��|_d|j
|_
||_|rKtj|�|_dSdS)Nr��r/)�name�openssl_name�curve�	generator�order�
isinstancer�	CurveEdTwr
�p�baselen�verifying_key_lengthr	�signature_length�oidr�
encode_oid�encoded_oid)�selfr9r;r<rDr:r5r5r6�__init__:s

�zCurve.__init__cCs&t|t�r|j|jko|j|jkStS�N)r>rr;r<�NotImplemented�rG�otherr5r5r6�__eq__Os
�zCurve.__eq__cCs
||kSrIr5rKr5r5r6�__ne__Vs
zCurve.__ne__cCs|jSrI�r9)rGr5r5r6�__repr__YszCurve.__repr__�uncompressedcCs.|dur|jr
d}nd}|dvrtd��|dkr%|jstd��tj|j�St|jtj�r6|dks2J�td��|j�	�}t�
d�}t�tjt�t�
|��}t�t�
t|j��||��t�
t|j��||���}t�
|j�|��}t�
|j���}|||||g}	|j��r�t�
|j���}
|	�|
�tj|	�S)	a�Serialise the curve parameters to binary string.

        :param str encoding: the format to save the curve parameters in.
            Default is ``named_curve``, with fallback being the ``explicit``
            if the OID is not set for the curve.
        :param str point_encoding: the point encoding of the generator when
            explicit curve encoding is used. Ignored for ``named_curve``
            format.

        :return: DER encoded ECParameters structure
        :rtype: bytes
        N�named_curve�explicit�rRrSz5Only 'named_curve' and 'explicit' encodings supportedzJCan't encode curve using named_curve encoding without associated curve OIDz6Twisted Edwards curves don't support explicit encodingr)rD�
ValueErrorrrrEr>r;rr?r@�encode_integer�encode_sequencer+�encode_octet_stringr
�a�br<�to_bytesr=�cofactor�append)rG�encoding�point_encoding�curve_p�version�field_idr;�baser=�seq_elementsr\r5r5r6�to_der\sN
���

����


zCurve.to_dercCst�|�||�d�S)a
        Serialise the curve parameters to the :term:`PEM` format.

        :param str encoding: the format to save the curve parameters in.
            Default is ``named_curve``, with fallback being the ``explicit``
            if the OID is not set for the curve.
        :param str point_encoding: the point encoding of the generator when
            explicit curve encoding is used. Ignored for ``named_curve``
            format.

        :return: PEM encoded ECParameters structure
        :rtype: str
        z
EC PARAMETERS)r�topemre)rGr^r_r5r5r6�to_pem�s�zCurve.to_pemcCs�|std�}tdd�|D��std��t|�}t�|�s7d|vr%t�d��t�|�\}}|r3t�d��t|�Sd|vr@t�d	��t�	|�\}}|rNt�d
��t�
|�\}}|dkr^t�d��t�	|�\}}t�	|�\}}t�|�\}	}t�
|�\}
}d
}|r�t�
|�\}}t�|�\}
}|
tkr�t
d��|
tkr�t
d�|
���t�
|�\}}|r�t�d��t�|�\}}t�|�\}}t|�}t|�}t�||||�}tjj||	d|
dd�}td||d
�}tD]
}||kr�|Sq�|S)a�Decode the curve parameters from DER file.

        :param data: the binary string to decode the parameters from
        :type data: :term:`bytes-like object`
        :param valid_encodings: set of names of allowed encodings, by default
            all (set by passing ``None``), supported ones are ``named_curve``
            and ``explicit``
        :type valid_encodings: :term:`set-like object`
        rTcss�|]}|dvVqdS)rTNr5)�.0�ir5r5r6�	<genexpr>�s�z!Curve.from_der.<locals>.<genexpr>z1Only named_curve and explicit encodings supportedrRz(named_curve curve parameters not allowedzUnexpected data after OIDrSz%explicit curve parameters not allowedz,Unexpected data after ECParameters structurerz!Unknown parameter encoding formatNz#Characteristic 2 curves unsupportedzUnknown field type: {0}z:Unexpected data after ECParameters.fieldID.Prime-p element)rQ�
compressed�hybridT)�valid_encodingsr=r<�unknown)�set�allrUrr�is_sequence�
UnexpectedDER�
remove_objectr�remove_sequence�remove_integer�remove_octet_stringr,rr+�formatrr�CurveFp�PointJacobi�
from_bytesrr)�datarmrD�empty�seqra�restrbr;�
base_bytesr=r\�_�
field_type�prime�
curve_a_bytes�
curve_b_bytes�curve_a�curve_b�curve_fprc�	tmp_curverir5r5r6�from_der�s~�
�

�
����zCurve.from_dercCsLtst|t�r|��}|�d�}|dkrt�d��|�t�||d��|�S)amDecode the curve parameters from PEM file.

        :param str string: the text string to decode the parameters from
        :param valid_encodings: set of names of allowed encodings, by default
            all (set by passing ``None``), supported ones are ``named_curve``
            and ``explicit``
        :type valid_encodings: :term:`set-like object`
        s-----BEGIN EC PARAMETERS-----���z"EC PARAMETERS PEM header not foundN)	rr>�str�encode�findrrrr��unpem)�cls�stringrm�ec_param_indexr5r5r6�from_pems


�zCurve.from_pemrI)NrQ)
r2r3r4rHrMrNrPrerg�staticmethodr��classmethodr�r5r5r5r6r9s


<[rr)r��r��	secp112r1r)rr�r�rr7�	secp112r2r)rr�r�r��	secp128r1r)rr�r�rr8�	secp160r1r)rr/r0r1r�rr�
prime192v1r)rr�r�r�!�	secp224r1r)rr/r0r1r�rr7�
prime256v1r)rr�r�r�"�	secp384r1r)rr�r�r�#�	secp521r1r)rr�r�r�
�	secp256k1r)
rr��$r�r�r/r8rrr�brainpoolP160r1r)
rr�r�r�r�r/r8rrr/�brainpoolP160t1r)
rr�r�r�r�r/r8rrr��brainpoolP192r1r )
rr�r�r�r�r/r8rr��brainpoolP192t1r!)
rr�r�r�r�r/r8rr��brainpoolP224r1r")
rr�r�r�r�r/r8rrr��brainpoolP224t1r#)
rr�r�r�r�r/r8rrr7�brainpoolP256r1r$)
rr�r�r�r�r/r8rrr8�brainpoolP256t1r%)
rr�r�r�r�r/r8rr�	�brainpoolP320r1r&)
rr�r�r�r�r/r8rrr��brainpoolP320t1r')
rr�r�r�r�r/r8rr��brainpoolP384r1r()
rr�r�r�r�r/r8rr��brainpoolP384t1r))
rr�r�r�r�r/r8rr�
�brainpoolP512r1r*)
rr�r�r�r�r/r8rr��brainpoolP512t1r-)rr��e�pr.)rr�r��qcCs6tD]}|j|kr
|Sqtd|dd�tD�f��)a9Select a curve based on its OID

    :param tuple[int,...] oid_curve: ASN.1 Object Identifier of the
        curve to return, like ``(1, 2, 840, 10045, 3, 1, 7)`` for ``NIST256p``.

    :raises UnknownCurveError: When the oid doesn't match any of the supported
        curves

    :rtype: ~ecdsa.curves.Curve
    zDI don't know about the curve with oid %s.I only know about these: %scS�g|]}|j�qSr5rO�rh�cr5r5r6�
<listcomp>5�zfind_curve.<locals>.<listcomp>)rrDr)�	oid_curver�r5r5r6r%s
���rcCsFtD]}||jks|jr||jkr|Sqtd�|dd�tD����)a{Select a curve based on its name.

    Returns a :py:class:`~ecdsa.curves.Curve` object with a ``name`` name.
    Note that ``name`` is case-sensitve.

    :param str name: Name of the curve to return, like ``NIST256p`` or
        ``prime256v1``

    :raises UnknownCurveError: When the name doesn't match any of the supported
        curves

    :rtype: ~ecdsa.curves.Curve
    z9Curve with name {0!r} unknown, only curves supported: {1}cSr�r5rOr�r5r5r6r�Lr�z!curve_by_name.<locals>.<listcomp>)rr9r:rrw)r9r�r5r5r6r9s���rN)g�
__future__r�sixr�rrrr�utilr	r
r�_compatrr
�__all__r+r,�	Exceptionrr�curve_112r1�generator_112r1r�curve_112r2�generator_112r2r�curve_128r1�generator_128r1r�curve_160r1�generator_160r1r�	curve_192�
generator_192r�	curve_224�
generator_224r�	curve_256�
generator_256r�	curve_384�
generator_384r�	curve_521�
generator_521r�curve_secp256k1�generator_secp256k1r�curve_brainpoolp160r1�generator_brainpoolp160r1r�curve_brainpoolp160t1�generator_brainpoolp160t1r�curve_brainpoolp192r1�generator_brainpoolp192r1r�curve_brainpoolp192t1�generator_brainpoolp192t1r �curve_brainpoolp224r1�generator_brainpoolp224r1r!�curve_brainpoolp224t1�generator_brainpoolp224t1r"�curve_brainpoolp256r1�generator_brainpoolp256r1r#�curve_brainpoolp256t1�generator_brainpoolp256t1r$�curve_brainpoolp320r1�generator_brainpoolp320r1r%�curve_brainpoolp320t1�generator_brainpoolp320t1r&�curve_brainpoolp384r1�generator_brainpoolp384r1r'�curve_brainpoolp384t1�generator_brainpoolp384t1r(�curve_brainpoolp512r1�generator_brainpoolp512r1r)�curve_brainpoolp512t1�generator_brainpoolp512t1r*�
curve_ed25519�generator_ed25519r-�curve_ed448�generator_ed448r.rrrr5r5r5r6�<module>s�&e�	�	�	�
�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	��
�