403Webshell
Server IP : 217.160.0.135  /  Your IP : 216.73.217.85
Web Server : Apache
System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64
User : sws1074145052 ( 1074145052)
PHP Version : 8.3.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /usr/lib/python3/dist-packages/Cryptodome/PublicKey/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3/dist-packages/Cryptodome/PublicKey/__pycache__/RSA.cpython-311.pyc
�

8�tc�p����gd�ZddlZddlZddlmZddlmZmZmZddl	m
Z
ddlmZddl
mZmZmZddlmZmZmZGd	�d
e��Zdd�Zdd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zdd�Z e Z!dZ"dS))�generate�	construct�
import_key�RsaKey�oid�N)�Random)�tobytes�bord�tostr)�DerSequence)�Integer)�test_probable_prime�generate_probable_prime�	COMPOSITE)�_expand_subject_public_key_info�_create_subject_public_key_info� _extract_subject_public_key_infoc�(�eZdZdZd�Zed���Zed���Zed���Zed���Z	ed���Z
ed���Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z		d!d�ZeZeZd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"dS)"raPClass defining an actual RSA key.
    Do not instantiate directly.
    Use :func:`generate`, :func:`construct` or :func:`import_key` instead.

    :ivar n: RSA modulus
    :vartype n: integer

    :ivar e: RSA public exponent
    :vartype e: integer

    :ivar d: RSA private exponent
    :vartype d: integer

    :ivar p: First factor of the RSA modulus
    :vartype p: integer

    :ivar q: Second factor of the RSA modulus
    :vartype q: integer

    :ivar u: Chinese remainder component (:math:`p^{-1} \text{mod } q`)
    :vartype u: integer

    :undocumented: exportKey, publickey
    c�|�t|�����}td��}|td��z}|||fvrtd���|���D]\}}t	|d|z|���||kr0|j|jdz
z|_|j|jdz
z|_	dSdS)a.Build an RSA key.

        :Keywords:
          n : integer
            The modulus.
          e : integer
            The public exponent.
          d : integer
            The private exponent. Only required for private keys.
          p : integer
            The first factor of the modulus. Only required for private keys.
          q : integer
            The second factor of the modulus. Only required for private keys.
          u : integer
            The CRT coefficient (inverse of p modulo q). Only required for
            private keys.
        ��n�e)�p�q�d�uzSome RSA components are missing�_�N)
�set�keys�
ValueError�items�setattr�_d�_p�_dp�_q�_dq)�self�kwargs�	input_set�
public_set�private_set�	component�values       �:/usr/lib/python3/dist-packages/Cryptodome/PublicKey/RSA.py�__init__zRsaKey.__init__Ms���&����
�
�&�&�	���_�_�
� �3�';�#<�#<�<���[�*�5�5�5��>�?�?�?� &�����	2�	2��I�u��D�#�	�/�5�1�1�1�1���#�#��w�$�'�A�+�.�D�H��w�$�'�A�+�.�D�H�H�H�$�#�c�*�t|j��S�N)�int�_n�r)s r0rzRsaKey.nk����4�7�|�|�r2c�*�t|j��Sr4)r5�_er7s r0rzRsaKey.eor8r2c�p�|���std���t|j��S)Nz-No private exponent available for public keys)�has_private�AttributeErrorr5r$r7s r0rzRsaKey.dss4�����!�!�	R� �!P�Q�Q�Q��4�7�|�|�r2c�p�|���std���t|j��S)Nz.No CRT component 'p' available for public keys)r<r=r5r%r7s r0rzRsaKey.py�4�����!�!�	S� �!Q�R�R�R��4�7�|�|�r2c�p�|���std���t|j��S)Nz.No CRT component 'q' available for public keys)r<r=r5r'r7s r0rzRsaKey.qr?r2c�p�|���std���t|j��S)Nz.No CRT component 'u' available for public keys)r<r=r5�_ur7s r0rzRsaKey.u�r?r2c�4�|j���S)zSize of the RSA modulus in bits�r6�size_in_bitsr7s r0rEzRsaKey.size_in_bits�s���w�#�#�%�%�%r2c�F�|j���dz
dzdzS)z9The minimal amount of bytes that can hold the RSA modulusr�rDr7s r0�
size_in_byteszRsaKey.size_in_bytes�s%����$�$�&�&��*�q�0�1�4�4r2c��d|cxkr|jksntd���ttt	|��|j|j����S)NrzPlaintext too large)r6r!r5�powr
r:)r)�	plaintexts  r0�_encryptzRsaKey._encrypt�sX���I�'�'�'�'���'�'�'�'��2�3�3�3��3�w�y�)�)�4�7�D�G�<�<�=�=�=r2c��d|cxkr|jksntd���|���std���t	jd|j���}t	|��t
||j|j��z|jz}t
||j|j	��}t
||j
|j��}||z
|jz|jz}||j	z|z}|�
|j��|z|jz}|t
||j|j��krtd���|S)NrzCiphertext too largezThis is not a private keyr)�
min_inclusive�
max_exclusivez Fault detected in RSA decryption)r6r!r<�	TypeErrorr
�random_rangerJr:r&r%r(r'rB�inverse)	r)�
ciphertext�r�cp�m1�m2�h�mp�results	         r0�_decryptzRsaKey._decrypt�s6���J�(�(�(�(���(�(�(�(��3�4�4�4����!�!�	9��7�8�8�8�

� �q���H�H�H��
�Z�
 �
 �3�q�$�'�4�7�#;�#;�
;�d�g�
E��
��T�X�t�w�
'�
'��
��T�X�t�w�
'�
'���2�g���
 �D�G�+��
���[�2�
���)�)�D�G�$�$�r�)�T�W�4����V�T�W�d�g�6�6�6�6��?�@�@�@��
r2c�"�t|d��S)z"Whether this is an RSA private keyr$)�hasattrr7s r0r<zRsaKey.has_private�s���t�T�"�"�"r2c��dS�NT�r7s r0�can_encryptzRsaKey.can_encrypt�����tr2c��dSr_r`r7s r0�can_signzRsaKey.can_sign�rbr2c�8�t|j|j���S)z^A matching RSA public key.

        Returns:
            a new :class:`RsaKey` object
        r)rr6r:r7s r0�
public_keyzRsaKey.public_key�s�����4�7�+�+�+�+r2c���|���|���krdS|j|jks|j|jkrdS|���sdS|j|jkS)NFT)r<rrr�r)�others  r0�__eq__z
RsaKey.__eq__�st��������!2�!2�!4�!4�4�4��5��6�U�W�����%�'� 1� 1��5����!�!�	��4���%�'�!�"r2c��||kSr4r`rhs  r0�__ne__z
RsaKey.__ne__�s���E�M�"�"r2c��ddlm}|�)Nr)�
PicklingError)�picklern)r)rns  r0�__getstate__zRsaKey.__getstate__�s��(�(�(�(�(�(��r2c�*�|���rRdt|j��t|j��t|j��t|j��fz}nd}dt|j��t|j��|fzS)Nz, d=%d, p=%d, q=%d, u=%d�zRsaKey(n=%d, e=%d%s))r<r5r$r%r'rBr6r:)r)�extras  r0�__repr__zRsaKey.__repr__�s{�������	�.�#�d�g�,�,��D�G���25�d�g�,�,��D�G���2N�N�E�E��E�%��T�W���s�4�7�|�|�U�(K�K�Kr2c�\�|���rd}nd}d|t|��fzS)N�Private�Publicz%s RSA key at 0x%X)r<�id)r)�key_types  r0�__str__zRsaKey.__str__�s8�������	 � �H�H��H�#�x��D���&:�:�:r2�PEMNrc
��|�t|��}|�tj}|dkr�d�|j|jfD��\}}t|d��dzrd|z}t|d��dzrd|z}d||g}d�d	�|D����}	d
tj|	��dd�zS|�	���rtd|j|j|j
|j|j|j
|jdz
z|j
|jdz
zt!|j���|j��g	�����}
|dkrd
}|dkr|rt'd���n�ddlm}|dkr!|�d}|�|
t.d��}
nVd}|sd}|�|
t.||��}
d}n0d}t1t.t|j|jg����}
|dkr|
S|dkr-ddlm}
|
�|
|||��}t|��St'd|z���)a5Export this RSA key.

        Args:
          format (string):
            The format to use for wrapping the key:

            - *'PEM'*. (*Default*) Text encoding, done according to `RFC1421`_/`RFC1423`_.
            - *'DER'*. Binary encoding.
            - *'OpenSSH'*. Textual encoding, done according to OpenSSH specification.
              Only suitable for public keys (not private keys).

          passphrase (string):
            (*For private keys only*) The pass phrase used for protecting the output.

          pkcs (integer):
            (*For private keys only*) The ASN.1 structure to use for
            serializing the key. Note that even in case of PEM
            encoding, there is an inner ASN.1 DER structure.

            With ``pkcs=1`` (*default*), the private key is encoded in a
            simple `PKCS#1`_ structure (``RSAPrivateKey``).

            With ``pkcs=8``, the private key is encoded in a `PKCS#8`_ structure
            (``PrivateKeyInfo``).

            .. note::
                This parameter is ignored for a public key.
                For DER and PEM, an ASN.1 DER ``SubjectPublicKeyInfo``
                structure is always used.

          protection (string):
            (*For private keys only*)
            The encryption scheme to use for protecting the private key.

            If ``None`` (default), the behavior depends on :attr:`format`:

            - For *'DER'*, the *PBKDF2WithHMAC-SHA1AndDES-EDE3-CBC*
              scheme is used. The following operations are performed:

                1. A 16 byte Triple DES key is derived from the passphrase
                   using :func:`Cryptodome.Protocol.KDF.PBKDF2` with 8 bytes salt,
                   and 1 000 iterations of :mod:`Cryptodome.Hash.HMAC`.
                2. The private key is encrypted using CBC.
                3. The encrypted key is encoded according to PKCS#8.

            - For *'PEM'*, the obsolete PEM encryption scheme is used.
              It is based on MD5 for key derivation, and Triple DES for encryption.

            Specifying a value for :attr:`protection` is only meaningful for PKCS#8
            (that is, ``pkcs=8``) and only if a pass phrase is present too.

            The supported schemes for PKCS#8 are listed in the
            :mod:`Cryptodome.IO.PKCS8` module (see :attr:`wrap_algo` parameter).

          randfunc (callable):
            A function that provides random bytes. Only used for PEM encoding.
            The default is :func:`Cryptodome.Random.get_random_bytes`.

        Returns:
          byte string: the encoded key

        Raises:
          ValueError:when the format is unknown or when you try to encrypt a private
            key with *DER* format and PKCS#1.

        .. warning::
            If you don't provide a pass phrase, the private key will be
            exported in the clear!

        .. _RFC1421:    http://www.ietf.org/rfc/rfc1421.txt
        .. _RFC1423:    http://www.ietf.org/rfc/rfc1423.txt
        .. _`PKCS#1`:   http://www.ietf.org/rfc/rfc3447.txt
        .. _`PKCS#8`:   http://www.ietf.org/rfc/rfc5208.txt
        N�OpenSSHc�6�g|]}|�����Sr`)�to_bytes��.0�xs  r0�
<listcomp>z%RsaKey.export_key.<locals>.<listcomp>7s ��I�I�I���
�
���I�I�Ir2r��sssh-rsar2c�X�g|]'}tjdt|����|z��(S)�>I)�struct�pack�len)r��kps  r0r�z%RsaKey.export_key.<locals>.<listcomp>=s/��!U�!U�!U�b�&�+�d�C��G�G�"<�"<�r�"A�!U�!U�!Ur2�ssh-rsa ���rzRSA PRIVATE KEY�DERz&PKCS#1 private key cannot be encrypted��PKCS8r{zPRIVATE KEYzENCRYPTED PRIVATE KEYz"PBKDF2WithHMAC-SHA1AndDES-EDE3-CBCz
PUBLIC KEY�r{z3Unknown key format '%s'. Cannot export the RSA key.)r	r�get_random_bytesr:r6r
�join�binascii�
b2a_base64r<rrrrrrr
rR�encoder!�
Cryptodome.IOr��wraprrr{)r)�format�
passphrase�pkcs�
protection�randfunc�e_bytes�n_bytes�keyparts�	keystring�
binary_keyryr�r{�pem_strs               r0�
export_keyzRsaKey.export_key�s���Z�!� ��,�,�J����.�H��Y���I�I�t�w���6H�I�I�I��G�W��G�A�J���$�&�
,�!�G�+���G�A�J���$�&�
,�!�G�+��"�G�W�5�H����!U�!U�H�!U�!U�!U�V�V�I���!4�Y�!?�!?����!D�D�D������!	;�$�a�&*�f�&*�f�&*�f�&*�f�&*�f�&*�f���q��&9�&*�f���q��&9�&-�d�f�o�o�&=�&=�d�f�&E�&E�	&(�	)�	)�*0����
��q�y�y�,���U�?�?�z�?�$�%M�N�N�N��/�/�/�/�/�/��U�?�?�z�'9�,�H�!&���J��T�!B�!B�J�J�6�H�%�J�%I�
�!&���J��,6�
�"D�"D�J�!%�J�J�#�H�8��9D�d�f�FJ�f�FN�:O�:O�;�;�J�
�U�?�?����U�?�?�)�)�)�)�)�)��j�j��X�z�8�L�L�G��7�#�#�#��N�QW�W�X�X�Xr2c� �td����Nz0Use module Cryptodome.Signature.pkcs1_15 instead��NotImplementedError)r)�M�Ks   r0�signzRsaKey.signt���!�"T�U�U�Ur2c� �td���r�r�)r)r��	signatures   r0�verifyz
RsaKey.verifywr�r2c� �td����Nz/Use module Cryptodome.Cipher.PKCS1_OAEP insteadr�)r)rKr�s   r0�encryptzRsaKey.encryptz���!�"S�T�T�Tr2c� �td���r�r�)r)rSs  r0�decryptzRsaKey.decrypt}r�r2c��t�r4r��r)r��Bs   r0�blindzRsaKey.blind����!�!r2c��t�r4r�r�s   r0�unblindzRsaKey.unblind�r�r2c��t�r4r�r7s r0�sizezRsaKey.size�r�r2)r{NrNN)#�__name__�
__module__�__qualname__�__doc__r1�propertyrrrrrrrErHrLr[r<rardrfrjrlrprtrzr��	exportKey�	publickeyr�r�r�r�r�r�r�r`r2r0rr3s;��������2/�/�/�<����X������X������X��
����X��
����X��
����X��
&�&�&�5�5�5�>�>�>�
���0#�#�#�
������,�,�,�#�#�#�#�#�#����
L�L�L�;�;�;�>?�-1�JY�JY�JY�JY�Z�I��I�V�V�V�V�V�V�U�U�U�U�U�U�"�"�"�"�"�"�"�"�"�"�"r2r�c����
���|dkrtd����dzdks�dkrtd���|�tj}td��x}}t����|���|k�r|d|dzzk�r
|dz}||z
}td��d|zdz
z���x�
�||kr*td��d|zdz
z����
��
fd	�}t
|||�
���td��|dzdz
z�����fd�}t
|||�
��}	�|	z}�dz
�|	dz
��}
��|
��}|���|kr
|d|dzzk��
�|	kr|	�c�}	��|	��}t|�|�|	|�
��S)a4Create a new RSA key pair.

    The algorithm closely follows NIST `FIPS 186-4`_ in its
    sections B.3.1 and B.3.3. The modulus is the product of
    two non-strong probable primes.
    Each prime passes a suitable number of Miller-Rabin tests
    with random bases and a single Lucas test.

    Args:
      bits (integer):
        Key length, or size (in bits) of the RSA modulus.
        It must be at least 1024, but **2048 is recommended.**
        The FIPS standard only defines 1024, 2048 and 3072.
      randfunc (callable):
        Function that returns random bytes.
        The default is :func:`Cryptodome.Random.get_random_bytes`.
      e (integer):
        Public RSA exponent. It must be an odd positive integer.
        It is typically a small number with very few ones in its
        binary representation.
        The FIPS standard requires the public exponent to be
        at least 65537 (the default).

    Returns: an RSA key object (:class:`RsaKey`, with private key).

    .. _FIPS 186-4: http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf
    iz"RSA modulus length must be >= 1024�r�zBRSA public exponent must be a positive, odd integer larger than 2.Nrc�H��|�ko|dz
����dkS�Nr)�gcd)�	candidater�min_ps ��r0�filter_pzgenerate.<locals>.filter_p�s*����u�$�D�)�a�-�)<�)<�Q�)?�)?�1�)D�Dr2)�
exact_bitsr��prime_filter�dc�t��|�ko1|dz
����dkot|�z
���kSr�)r��abs)r�r�min_distance�min_qrs ����r0�filter_qzgenerate.<locals>.filter_q�sH�����%�6���]�'�'��*�*�a�/�6��	�A�
�&�&��5�
7r2�rrrrrr)
r!rr�r
rE�sqrtr�lcmrRr)�bitsr�rrr�size_q�size_pr�r�rr�rr�r�r�rs  `         @@@@r0rr�sB�������:�d�{�{��=�>�>�>��1�u��z�z�Q��U�U��]�^�^�^����*���A�J�J��A����
�
�A�
�.�.�
�
�d�
"�
"�q�A�$�!�)�,<�'=�'=��������� �����F�
�Q��7�=�=�?�?�?����V����Q�Z�Z�A��J��N�3�9�9�;�;�E�	E�	E�	E�	E�	E�	E�
$�v�-5�19�
;�
;�
;���q�z�z�d�a�i�#�o�6��	7�	7�	7�	7�	7�	7�	7�	7�

$�v�-5�19�
;�
;�
;��
��E���1�u�k�k�!�a�%� � ��
�I�I�c�N�N��?�.�.�
�
�d�
"�
"�q�A�$�!�)�,<�'=�'=�B	�1�u�u��!���1�	�	�	�!���A��A��a�1��Q�/�/�/�/r2Tc�6�Gd�dt��}|��}td|��D]#\}}t||t|�����$|j}|j}t
|d��st||���}�nM|j}	t
|d��r|j	}
|j
}n�|	|zdz
}|}
|
dzd	kr|
dz}
|
dzd	k�d
}td��}|s�|dkr�t|
��}||krht|||��}|dkrF||dz
kr=t|d|��dkr(t|���|dz��}
d}n|dz}||k�h|dz
}|s|dk��|std
���||
zd	ksJ�||
z}t
|d��r|j}n|
�|��}t|||	|
||���}|�r�|dks||krtd���t|���|��dkrtd���|dzstd���|����rM|	dks|	|krtd���t|���|	��dkrtd���|
|z|krtd���t#|
��t$krtd���t#|��t$krtd���|
dz
|dz
z}||
dz
�|dz
��z}||	zt'|��zdkrtd���t
|d��r6|dks||krtd���|
|z|zdkrtd���|S)a!Construct an RSA key from a tuple of valid RSA components.

    The modulus **n** must be the product of two primes.
    The public exponent **e** must be odd and larger than 1.

    In case of a private key, the following equations must apply:

    .. math::

        \begin{align}
        p*q &= n \\
        e*d &\equiv 1 ( \text{mod lcm} [(p-1)(q-1)]) \\
        p*u &\equiv 1 ( \text{mod } q)
        \end{align}

    Args:
        rsa_components (tuple):
            A tuple of integers, with at least 2 and no
            more than 6 items. The items come in the following order:

            1. RSA modulus *n*.
            2. Public exponent *e*.
            3. Private exponent *d*.
               Only required if the key is private.
            4. First factor of *n* (*p*).
               Optional, but the other factor *q* must also be present.
            5. Second factor of *n* (*q*). Optional.
            6. CRT coefficient *q*, that is :math:`p^{-1} \text{mod }q`. Optional.

        consistency_check (boolean):
            If ``True``, the library will verify that the provided components
            fulfil the main RSA properties.

    Raises:
        ValueError: when the key being imported fails the most basic RSA validity checks.

    Returns: An RSA key object (:class:`RsaKey`).
    c��eZdZdS)�construct.<locals>.InputCompsN)r�r�r�r`r2r0�
InputCompsr�s�������r2r�r�rrrrr�rFr�Tz2Unable to compute factors p and q from exponent d.rzInvalid RSA public exponentz-RSA public exponent is not coprime to moduluszRSA modulus is not oddzInvalid RSA private exponentz.RSA private exponent is not coprime to modulusz RSA factors do not match moduluszRSA factor p is compositezRSA factor q is compositezInvalid RSA conditionzInvalid RSA component uzInvalid RSA component u with p)�object�zipr#r
rrr]rrrrrJr�r!rrRr<rrr5)�rsa_components�consistency_checkr��input_comps�compr/rr�keyrrr�ktot�t�spotted�a�k�candr�phir�s                     r0rr�s1��P
�
�
�
�
�V�
�
�
��*�,�,�K��;�^�L�L�3�3�
��u���T�7�5�>�>�2�2�2�2��
�A��
�A��;��$�$�33��q�A�������M���;��$�$�'	��
�A��
�A�A�
�q�5�1�9�D��A��a�%�1�*�*��a����a�%�1�*�*��G���
�
�A��
�!�c�'�'��A�J�J���$�h�h��q�!�Q�<�<�D��q�y�y�T�a�!�e�_�_��T�1�a���A�9M�9M�$�A�J�J�N�N�4�!�8�4�4��"&�����F�A��$�h�h��Q����
�!�c�'�'��
W� �!U�V�V�V���U�q�L�L�L�L��Q��A��;��$�$�	��
�A�A��	�	�!���A��q�A��a�1��2�2�2���#G�
��6�6�Q�!�V�V��:�;�;�;��1�:�:�>�>�!����!�!��L�M�M�M��1�u�	7��5�6�6�6��?�?���	G��A�v�v��a��� �!?�@�@�@��q�z�z�~�~�a� � �A�%�%� �!Q�R�R�R��1�u��z�z� �!C�D�D�D�"�1�%�%��2�2� �!<�=�=�=�"�1�%�%��2�2� �!<�=�=�=��q�5�Q��U�#�C��!�a�%���Q��U�+�+�+�C��A���C��� �Q�&�&� �!8�9�9�9��s�C� � �
G���6�6�Q�!�V�V�$�%>�?�?�?���E�A�I�!�#�#�$�%E�F�F�F��Jr2c��t���|dd���}|ddkrtd���t|dd�t	|d���|d	��gz��S)
N�	T��nr_elements�only_ints_expectedrz(No PKCS#1 encoding of an RSA private keyr���)r�decoder!rr
rR��encodedr*�ders   r0�_import_pkcs1_privater�jsx���-�-�
�
�w�A�$�
�
O�
O�C�
�1�v��{�{��C�D�D�D��S��1��X���Q����!8�!8��Q��!@�!@� A�A�B�B�Br2c�h�t���|dd���}t|��S)Nr�Tr�)rr�rr�s   r0�_import_pkcs1_publicr�~s.��
�-�-�
�
�w�A�$�
�
O�
O�C��S�>�>�r2c�~�t|��\}}}|tks|�td���t|��S)NzNo RSA subjectPublicKeyInfo)rrr!r�)r�r*�algoid�encoded_key�paramss     r0�_import_subjectPublicKeyInfor�sA��"A�'�"J�"J��F�K��
��}�}��*��6�7�7�7���,�,�,r2c�>�t|��}t|��Sr4)rr)r�r*�sp_infos   r0�_import_x509_certr�s��.�w�7�7�G�'��0�0�0r2c��ddlm}|�||��}|dtkrt	d���t|d|��S)Nrr�zNo PKCS#8 encoded RSA keyr)r�r��unwraprr!�_import_keyDER)r�r�r�r�s    r0�
_import_pkcs8r
�sW��#�#�#�#�#�#�
���W�j�)�)�A���t�s�{�{��4�5�5�5��!�A�$�
�+�+�+r2c��tttttf}|D] }	|||��cS#t
$rY�wxYwtd���)z@Import an RSA key (public or private half), encoded in DER form.�RSA key format is not supported)r�r�rrr
r!)�
extern_keyr��	decodings�decodings    r0r	r	�sy��'�%�-�"��	 �I�����	��8�J�
�3�3�3�3�3���	�	�	��D�	�����6�
7�
7�7s�4�
A�Ac�~�ddlm}m}m}m}|||��\}}|dkrtd���||��\}}||��\}	}||��\}
}||��\}}||��\}}||��\}
}||��\}}||��d�||	|
|
||fD��}t
|��S)Nr)�import_openssh_private_generic�
read_bytes�read_string�
check_paddingzssh-rsazThis SSH key is not RSAc�6�g|]}tj|����Sr`)r
�
from_bytesr�s  r0r�z/_import_openssh_private_rsa.<locals>.<listcomp>�s#��B�B�B�q�W�
��
"�
"�B�B�Br2)�_opensshrrrrr!r)�data�passwordrrrr�ssh_name�	decryptedrrr�iqmprrr�padded�builds                 r0�_import_openssh_private_rsar�s@��C�C�C�C�C�C�C�C�C�C�C�C�9�8��x�H�H��H�i��9����2�3�3�3��:�i�(�(�L�A�y��:�i�(�(�L�A�y��:�i�(�(�L�A�y� �j��+�+�O�D�)��:�i�(�(�L�A�y��:�i�(�(�L�A�y���I�&�&�I�A�v��M�&����B�B�Q��1�a��D�,A�B�B�B�E��U���r2c�"�ddlm}t|��}|�t|��}|�d��r;t	|��}|�||��\}}}t
||��}|S|�d��r;|�t	|��|��\}}}|rd}t||��S|�d��r�tj	|�
d��d��}	g}
t|	��d	krctj
d
|	dd	���d}|
�|	d	d	|z���|	d	|zd�}	t|	��d	k�ctj|
d��}tj|
d��}
t#|
|g��St|��dkr)t%|d��dkrt||��St'd
���)a�Import an RSA key (public or private).

    Args:
      extern_key (string or byte string):
        The RSA key to import.

        The following formats are supported for an RSA **public key**:

        - X.509 certificate (binary or PEM format)
        - X.509 ``subjectPublicKeyInfo`` DER SEQUENCE (binary or PEM
          encoding)
        - `PKCS#1`_ ``RSAPublicKey`` DER SEQUENCE (binary or PEM encoding)
        - An OpenSSH line (e.g. the content of ``~/.ssh/id_ecdsa``, ASCII)

        The following formats are supported for an RSA **private key**:

        - PKCS#1 ``RSAPrivateKey`` DER SEQUENCE (binary or PEM encoding)
        - `PKCS#8`_ ``PrivateKeyInfo`` or ``EncryptedPrivateKeyInfo``
          DER SEQUENCE (binary or PEM encoding)
        - OpenSSH (text format, introduced in `OpenSSH 6.5`_)

        For details about the PEM encoding, see `RFC1421`_/`RFC1423`_.

      passphrase (string or byte string):
        For private keys only, the pass phrase that encrypts the key.

    Returns: An RSA key object (:class:`RsaKey`).

    Raises:
      ValueError/IndexError/TypeError:
        When the given key cannot be parsed (possibly because the pass
        phrase is wrong).

    .. _RFC1421: http://www.ietf.org/rfc/rfc1421.txt
    .. _RFC1423: http://www.ietf.org/rfc/rfc1423.txt
    .. _`PKCS#1`: http://www.ietf.org/rfc/rfc3447.txt
    .. _`PKCS#8`: http://www.ietf.org/rfc/rfc5208.txt
    .. _`OpenSSH 6.5`: https://flak.tedunangst.com/post/new-openssh-key-format-and-bcrypt-pbkdf
    rr�Ns-----BEGIN OPENSSH PRIVATE KEYs-----r�� rr�r�r��0r)r�r{r	�
startswithrr�rr	r��
a2b_base64�splitr�r��unpack�appendr
rrr
r!)r
r�r{�text_encoded�openssh_encoded�marker�enc_flagrZr�r�r��lengthrrs              r0rr�s��R"�!�!�!�!�!���$�$�J����Z�(�(�
����>�?�?���Z�(�(��,/�J�J�|�Z�,P�,P�)����,�_�j�I�I���
����X�&�&�/�"%�*�*�U�:�->�->�
�"K�"K���f�h��	��J��c�:�.�.�.����[�)�)�
!��'�
�(8�(8��(>�(>�q�(A�B�B�	����)�n�n�q� � ��]�4��2�A�2��7�7��:�F��O�O�I�a��F�
�l�3�4�4�4�!�!�f�*�+�+�.�I��)�n�n�q� � �
��x��{�+�+����x��{�+�+���!�Q�� � � �
�:������t�J�q�M�2�2�d�:�:��j�*�5�5�5�
�6�
7�
7�7r2z1.2.840.113549.1.1.1)Nr�)Tr4)#�__all__r�r��
Cryptodomer�Cryptodome.Util.py3compatr	r
r�Cryptodome.Util.asn1r�Cryptodome.Math.Numbersr
�Cryptodome.Math.Primalityrrr�Cryptodome.PublicKeyrrrr�rrrr�r�rrr
r	rr�	importKeyrr`r2r0�<module>r5s���@��������
�
�
�
�������:�:�:�:�:�:�:�:�:�:�,�,�,�,�,�,�+�+�+�+�+�+�G�G�G�G�G�G�G�G�G�G�@�@�@�@�@�@�@�@�@�@�
T"�T"�T"�T"�T"�V�T"�T"�T"�n
N0�N0�N0�N0�bL�L�L�L�^C�C�C�(���-�-�-�1�1�1�,�,�,�8�8�8�$���0L8�L8�L8�L8�`
�	����r2

Youez - 2016 - github.com/yon3zu
LinuXploit