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/CyberPanel/lib64/python3.10/site-packages/paramiko/__pycache__/ecdsakey.cpython-310.pyc
o

�h�-�@s�dZddlmZmZddlmZddlmZmZddl	m
Z
ddlmZm
Z
ddlmZddlmZdd	lmZdd
lmZddlmZGdd
�d
�ZGdd�d�ZGdd�de�ZdS)z
ECDSA keys
�)�InvalidSignature�UnsupportedAlgorithm)�default_backend)�hashes�
serialization)�ec)�decode_dss_signature�encode_dss_signature)�	four_byte)�Message)�PKey)�SSHException)�deflate_longc@seZdZdZdd�ZdS)�_ECDSACurvez�
    Represents a specific ECDSA Curve (nistp256, nistp384, etc).

    Handles the generation of the key format identifier and the selection of
    the proper hash function. Also grabs the proper curve from the 'ecdsa'
    package.
    cCsT||_|j|_d|j|_|jdkrtj|_n|jdkr!tj|_ntj|_||_	dS)N�ecdsa-sha2-�i�)
�	nist_name�key_size�
key_length�key_format_identifierr�SHA256�hash_object�SHA384�SHA512�curve_class)�selfrr�r�G/usr/local/CyberPanel/lib/python3.10/site-packages/paramiko/ecdsakey.py�__init__0s




z_ECDSACurve.__init__N)�__name__�
__module__�__qualname__�__doc__rrrrrr'src@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�_ECDSACurveSetz�
    A collection to hold the ECDSA curves. Allows querying by oid and by key
    format identifier. The two ways in which ECDSAKey needs to be able to look
    up curves.
    cCs
||_dS�N��ecdsa_curves)rr&rrrrI�
z_ECDSACurveSet.__init__cCsdd�|jD�S)NcSsg|]}|j�qSr)r)�.0�curverrr�
<listcomp>MszA_ECDSACurveSet.get_key_format_identifier_list.<locals>.<listcomp>r%�rrrr�get_key_format_identifier_listLsz-_ECDSACurveSet.get_key_format_identifier_listcC�"|jD]}|j|kr|SqdSr$)r&r)rrr)rrr�get_by_curve_classO�


��z!_ECDSACurveSet.get_by_curve_classcCr-r$)r&r)rrr)rrr�get_by_key_format_identifierTr/z+_ECDSACurveSet.get_by_key_format_identifiercCr-r$)r&r)rrr)rrr�get_by_key_lengthYr/z _ECDSACurveSet.get_by_key_lengthN)	rr r!r"rr,r.r0r1rrrrr#Bsr#c@seZdZdZeeejd�eejd�eej	d�g�Z
							d-dd�Zed	d
��Z
edd��Zd
d�Zdd�Zedd��Zdd�Zdd�Zdd�Zd.dd�Zdd�Zd.dd�Zd.dd �Zee��ddfd!d"��Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�ZdS)/�ECDSAKeyz\
    Representation of an ECDSA key which can be used to sign and verify SSH2
    data.
    �nistp256�nistp384�nistp521NTcCsJd|_d|_d|_|dur|�||�dS|dur!|�||�dS|dur-|dur-t|�}|durE|\|_|_|jjj}|j�	|�|_
dS|��}	d}
|	�|
�rY|	dt
|
��}	|j�|	�|_
|j��}dd�|D�}|j|||d�|��}
|
|j
jkr�td�|
���|��}ztj�|j
��|�}||_WdSty�td��w)Nz-cert-v01@openssh.comcSsg|]}d�|��qS)z{}-cert-v01@openssh.com)�format)r(�xrrrr*�s
�z%ECDSAKey.__init__.<locals>.<listcomp>)�msg�key_type�	cert_typezCan't handle curve of type {}zInvalid public key)�
verifying_key�signing_key�public_blob�_from_private_key�_from_private_key_filerr)�	__class__�
_ECDSA_CURVESr.�ecdsa_curve�get_text�endswith�lenr0r,�_check_type_and_load_certrr
r6�
get_binaryr�EllipticCurvePublicKey�from_encoded_pointr�
ValueError)rr8�data�filename�password�vals�file_obj�validate_point�c_classr9�suffix�	key_types�
cert_types�	curvename�	pointinfo�keyrrrrmsV

�
���
��zECDSAKey.__init__cCs
|j��Sr$)rAr,��clsrrr�identifiers�s
zECDSAKey.identifierscC�|��Sr$)rZrXrrr� supported_key_format_identifiers�sz)ECDSAKey.supported_key_format_identifierscCs�|j}t�}|�|jj�|�|jj�|��}|jjdd}t	|j
dd�}d|t|�|}t	|jdd�}d|t|�|}t
||}|�|�|��S)N��F)�add_sign_padding�)r;r�
add_stringrBrr�public_numbersr)rrr7rE�yr
�asbytes)rrW�m�numbers�key_size_bytes�x_bytes�y_bytes�	point_strrrrrd�s
zECDSAKey.asbytescCr[r$)rdr+rrr�__str__��zECDSAKey.__str__cCs|��|j��j|j��jfSr$)�get_namer;rbr7rcr+rrr�_fields�s

�zECDSAKey._fieldscC�|jjSr$)rBrr+rrrrm�rlzECDSAKey.get_namecCror$)rBrr+rrr�get_bits�rlzECDSAKey.get_bitscCs
|jduSr$)r<r+rrr�can_sign�r'zECDSAKey.can_signcCsTt�|j���}|j�||�}t|�\}}t�}|�|jj	�|�|�
||��|Sr$)r�ECDSArBrr<�signrrrar�
_sigencode)rrK�	algorithm�ecdsa�sig�r�srerrr�
sign_ssh_data�szECDSAKey.sign_ssh_datacCsl|��|jjkr
dS|��}|�|�\}}t||�}z|j�||t�	|j�
���WdSty5YdSw)NFT)rCrBrrG�
_sigdecoder	r;�verifyrrrrr)rrKr8rw�sigR�sigS�	signaturerrr�verify_ssh_sig�s
���zECDSAKey.verify_ssh_sigcC�|j||jtjj|d�dS�N)rM)�_write_private_key_filer<r�
PrivateFormat�TraditionalOpenSSL)rrLrMrrr�write_private_key_file��
�zECDSAKey.write_private_key_filecCr�r�)�_write_private_keyr<rr�r�)rrOrMrrr�write_private_key�r�zECDSAKey.write_private_keycCsT|dur|j�|�}|durtd�|���|��}tj|t�d�}t||�	�fd�S)a
        Generate a new private ECDSA key.  This factory function can be used to
        generate a new host key or authentication key.

        :param progress_func: Not used for this type of key.
        :returns: A new private key (`.ECDSAKey`) object
        NzUnsupported key length: {:d})�backend)rN)
rAr1rJr6rr�generate_private_keyrr2�
public_key)rYr)�
progress_func�bits�private_keyrrr�generates	zECDSAKey.generatecC�|�d||�}|�|�dS�N�EC)�_read_private_key_file�_decode_key)rrLrMrKrrrr?�zECDSAKey._from_private_key_filecCr�r�)�_read_private_keyr�)rrOrMrKrrrr>r�zECDSAKey._from_private_keycCs|\}}||jkr+ztj|dt�d�}Wn_ttttfy*}ztt	|���d}~ww||j
kroz,t|�}|��}|�
�}|��}d|}	|j�|	�}
|
sQtd��t�||
��t��}Wntyn}ztt	|���d}~ww|�|�||_|��|_|jj}|j�|�|_dS)N)rMr�rzInvalid key curve identifier)�_PRIVATE_KEY_FORMAT_ORIGINALr�load_der_private_keyrrJ�AssertionError�	TypeErrorrr
�str�_PRIVATE_KEY_FORMAT_OPENSSHrrCrG�	get_mpintrAr0r�derive_private_keyr�	Exception�_got_bad_key_format_idr<r�r;r)r@r.rB)rrK�pkformatrW�er8�
curve_name�verkey�sigkey�namer)rrrrr�"sJ

����
���

zECDSAKey._decode_keycCs"t�}|�|�|�|�|��Sr$)r�	add_mpintrd)rrxryr8rrrrtIs

zECDSAKey._sigencodecCs t|�}|��}|��}||fSr$)rr�)rrwr8rxryrrrr{OszECDSAKey._sigdecode)NNNNNNTr$) rr r!r"r#rr�	SECP256R1�	SECP384R1�	SECP521R1rAr�classmethodrZr\rdrk�propertyrnrmrprqrzr�r�r�r�r?r>r�rtr{rrrrr2_sL


��

�>






'r2N)r"�cryptography.exceptionsrr�cryptography.hazmat.backendsr�cryptography.hazmat.primitivesrr�)cryptography.hazmat.primitives.asymmetricr�/cryptography.hazmat.primitives.asymmetric.utilsrr	�paramiko.commonr
�paramiko.messager�
paramiko.pkeyr�paramiko.ssh_exceptionr
�
paramiko.utilrrr#r2rrrr�<module>s