%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/paramiko/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/paramiko/__pycache__/ecdsakey.cpython-312.pyc

�

�ec�,����dZddlmZmZddlmZddlmZmZddl	m
Z
ddlmZm
Z
ddlmZddlmZdd	lmZdd
lmZddlmZGd�d
e�ZGd�de�ZGd�de�Zy)z
ECDSA keys
�)�InvalidSignature�UnsupportedAlgorithm)�default_backend)�hashes�
serialization)�ec)�decode_dss_signature�encode_dss_signature)�	four_byte)�Message)�PKey)�SSHException)�deflate_longc��eZdZdZd�Zy)�_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.
    c�D�||_|j|_d|jz|_|jdkrtj
|_||_	y|jdkrtj|_||_	ytj|_||_	y)N�ecdsa-sha2-�i�)
�	nist_name�key_size�
key_length�key_format_identifierr�SHA256�hash_object�SHA384�SHA512�curve_class)�selfrrs   �3/usr/lib/python3/dist-packages/paramiko/ecdsakey.py�__init__z_ECDSACurve.__init__0s���"���%�.�.���&3�T�^�^�%C��"��?�?�c�!�%�}�}�D��'����_�_��
#�%�}�}�D��'��� &�}�}�D��&���N)�__name__�
__module__�__qualname__�__doc__r �r!rrr's���'r!rc�.�eZdZdZd�Zd�Zd�Zd�Zd�Zy)�_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.
    c��||_y�N)�ecdsa_curves)rr+s  rr z_ECDSACurveSet.__init__Is
��(��r!c�T�|jD�cgc]}|j��c}Scc}wr*�r+r)r�curves  r�get_key_format_identifier_listz-_ECDSACurveSet.get_key_format_identifier_listLs"��9=�9J�9J�K���+�+�K�K��Ks�%c�L�|jD]}|j|k(s�|cSyr*)r+r)rrr.s   r�get_by_curve_classz!_ECDSACurveSet.get_by_curve_classOs*���&�&�	�E�� � �K�/���	r!c�L�|jD]}|j|k(s�|cSyr*r-)rrr.s   r�get_by_key_format_identifierz+_ECDSACurveSet.get_by_key_format_identifierTs+���&�&�	�E��*�*�.C�C���	r!c�L�|jD]}|j|k(s�|cSyr*)r+r)rrr.s   r�get_by_key_lengthz _ECDSACurveSet.get_by_key_lengthYs*���&�&�	�E����:�-���	r!N)	r"r#r$r%r r/r1r3r5r&r!rr(r(Bs!���)�L��
�
r!r(c�R�eZdZdZeeejd�eejd�eejd�g�Z
							dd�Zed��Z
d�Zd	�Zed
��Zd�Zd�Zd
�Zdd�Zd�Zdd�Zdd�Zeej�ddfd��Zd�Zd�Zd�Zd�Zd�Zy)�ECDSAKeyz\
    Representation of an ECDSA key which can be used to sign and verify SSH2
    data.
    �nistp256�nistp384�nistp521Nc���d|_d|_d|_|�|j||�y|�|j	||�y|�
|�t|�}|�P|\|_|_|jjj}|jj|�|_
y|j�}	d}
|	j|
�r|	dt|
�}	|jj|	�|_
|jj�}|D�cgc]}dj!|���}
}|j#|||
��|j�}||jj$k7rt'dj!|���|j)�}	t*j,j/|jj1�|�}||_ycc}w#t2$rt'd��wxYw)Nz-cert-v01@openssh.comz{}-cert-v01@openssh.com)�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_filerr.�	__class__�
_ECDSA_CURVESr1�ecdsa_curve�get_text�endswith�lenr3r/�format�_check_type_and_load_certrr�
get_binaryr�EllipticCurvePublicKey�from_encoded_pointr�
ValueError)rr<�data�filename�password�vals�file_obj�validate_point�c_classr=�suffix�	key_types�x�
cert_types�	curvename�	pointinfo�keys                 rr zECDSAKey.__init__ms���"������������"�"�8�X�6�����'�'��(�;���K�d�.��$�-�C���37�0�D��d�0��&�&�,�,�6�6�G�#�1�1�D�D�W�M�D���|�|�~�H�
-�F�� � ��(�#�N�s�6�{�l�3��#�1�1�N�N�� �D���*�*�I�I�K�I�=F��89�)�0�0��3��J��
�*�*��)�z�
+�
�����I��D�,�,�6�6�6�"�3�:�:�9�E������(�I�
9��/�/�B�B��$�$�0�0�2�I���&)��"��#��$�
9�"�#7�8�8�
9�s�G�?G�G-c�6�|jj�Sr*)rEr/)�clss r� supported_key_format_identifiersz)ECDSAKey.supported_key_format_identifiers�s��� � �?�?�A�Ar!c� �|j}t�}|j|jj�|j|jj
�|j
�}|jjdzdz}t|jd��}d|t|�z
z|z}t|jd��}d|t|�z
z|z}t|z|z}|j|�|j�S)N��F)�add_sign_padding�)r?r�
add_stringrFrr�public_numbersr.rrrYrI�yr�asbytes)rr]�m�numbers�key_size_bytes�x_bytes�y_bytes�	point_strs        rrizECDSAKey.asbytes�s���� � ���I��	���T�%�%�;�;�<�	���T�%�%�/�/�0��$�$�&���)�)�,�,�q�0�Q�6���w�y�y�5�A���^�c�'�l�:�;�g�E���w�y�y�5�A���^�c�'�l�:�;�g�E����'�'�1�	�	���Y���y�y�{�r!c�"�|j�Sr*)ri�rs r�__str__zECDSAKey.__str__�s���|�|�~�r!c��|j�|jj�j|jj�jfSr*)�get_namer?rgrYrhrqs r�_fieldszECDSAKey._fields�sG��
�M�M�O����-�-�/�1�1����-�-�/�1�1�
�	
r!c�.�|jjSr*)rFrrqs rrtzECDSAKey.get_name�s�����5�5�5r!c�.�|jjSr*)rFrrqs r�get_bitszECDSAKey.get_bits�s�����*�*�*r!c��|jduSr*)r@rqs r�can_signzECDSAKey.can_sign�s�����t�+�+r!c�T�tj|jj��}|jj||�}t
|�\}}t�}|j|jj�|j|j||��|Sr*)r�ECDSArFrr@�signr	rrfr�
_sigencode)rrP�	algorithm�ecdsa�sig�r�srjs        r�
sign_ssh_datazECDSAKey.sign_ssh_data�s�������)�)�5�5�7�8�����#�#�D�%�0��#�C�(���1��I��	���T�%�%�;�;�<�	���T�_�_�Q��*�+��r!c�d�|j�|jjk7ry|j�}|j	|�\}}t||�}	|jj||tj|jj���y#t$rYywxYw)NFT)rGrFrrL�
_sigdecoder
r?�verifyrr|rr)rrPr<r��sigR�sigS�	signatures       r�verify_ssh_sigzECDSAKey.verify_ssh_sig�s����<�<�>�T�-�-�C�C�C���n�n����_�_�S�)�
��d�(��t�4�	�	����%�%��4����$�*:�*:�*F�*F�*H�!I�
��� �	��	�s�AB#�#	B/�.B/c�r�|j||jtjj|��y�N)rR)�_write_private_key_filer@r�
PrivateFormat�TraditionalOpenSSL)rrQrRs   r�write_private_key_filezECDSAKey.write_private_key_file�s3���$�$������'�'�:�:��		%�	
r!c�r�|j||jtjj|��yr�)�_write_private_keyr@rr�r�)rrTrRs   r�write_private_keyzECDSAKey.write_private_key�s3����������'�'�:�:��		 �	
r!c�
�|�G|jj|�}|�tdj|���|j	�}tj|t���}t||j�f��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
        zUnsupported key length: {:d})�backend)rS)
rEr5rOrJrr�generate_private_keyrr7�
public_key)r_r.�
progress_func�bits�private_keys     r�generatezECDSAKey.generatesx�����%�%�7�7��=�E��}� �!?�!F�!F�t�!L�M�M��%�%�'�E��-�-�e�_�=N�O���k�;�+A�+A�+C�D�E�Er!c�L�|jd||�}|j|�y�N�EC)�_read_private_key_file�_decode_key)rrQrRrPs    rrCzECDSAKey._from_private_key_files$���*�*�4��8�D������r!c�L�|jd||�}|j|�yr�)�_read_private_keyr�)rrTrRrPs    rrBzECDSAKey._from_private_keys$���%�%�d�H�h�?������r!c�6�|\}}||jk(r"	tj|dt���}n�||jk(r�	t|�}|j�}|j�}|j�}d|z}	|jj!|	�}
|
std��t#j$||
j'�t��}n|j+|�|_|j/�|_|j2j4}|jj7|�|_y#tt
ttf$r}tt|���d}~wwxYw#t($r}tt|���d}~wwxYw)N)rRr�rzInvalid key curve identifier)�_PRIVATE_KEY_FORMAT_ORIGINALr�load_der_private_keyrrO�AssertionError�	TypeErrorrr�str�_PRIVATE_KEY_FORMAT_OPENSSHrrGrL�	get_mpintrEr3r�derive_private_keyr�	Exception�_got_bad_key_format_idr@r�r?r.rDr1rF)rrP�pkformatr]�er<�
curve_name�verkey�sigkey�namer.rs            rr�zECDSAKey._decode_keysl�����$��t�8�8�8�

+�#�8�8��4��1B�����9�9�
9�
+��d�m�� �\�\�^�
����)�������$�z�1���*�*�G�G��M���&�'E�F�F��+�+��E�-�-�/��1B���
�'�'��1���� �^�^�-����i�i�)�)���-�-�@�@��M����;���$�	�
+�#�3�q�6�*�*��

+��(�
+�#�3�q�6�*�*��
+�s0� E�BE6�E3�E.�.E3�6	F�?F�Fc�z�t�}|j|�|j|�|j�Sr*)r�	add_mpintri)rr�r�r<s    rr~zECDSAKey._sigencodeCs-���i���
�
�a���
�
�a���{�{�}�r!c�`�t|�}|j�}|j�}||fSr*)rr�)rr�r<r�r�s     rr�zECDSAKey._sigdecodeIs*���c�l���M�M�O���M�M�O���!�t�r!)NNNNNNTr*)r"r#r$r%r(rr�	SECP256R1�	SECP384R1�	SECP521R1rEr �classmethodr`rirr�propertyrurtrxrzr�r�r�r�r�rCrBr�r~r�r&r!rr7r7_s����
#�����j�1�����j�1�����j�1�	
��M�
�
���
���;9�z�B��B��(��
��
�6�+�,��� 
�
��(�B�L�L�N�$�T�F��F�&��%N�N�r!r7N)r%�cryptography.exceptionsrr�cryptography.hazmat.backendsr�cryptography.hazmat.primitivesrr�)cryptography.hazmat.primitives.asymmetricr�/cryptography.hazmat.primitives.asymmetric.utilsr	r
�paramiko.commonr�paramiko.messager�
paramiko.pkeyr
�paramiko.ssh_exceptionr�
paramiko.utilr�objectrr(r7r&r!r�<module>r�sU��&�K�8�@�8��
&�$��/�&�'�&�'�6�V��:n�t�nr!

Zerion Mini Shell 1.0