+
    '(juy                         . ROt ^ RIt^ RIt^ RIHt ^ RIHtHtHt ^ RI	H
t
Ht ^ RIHt ^ RIHt ^ RIHtHtHt ^ R	IHtHtHt  ! R
 R]4      tRR ltRR ltR tR tR tR tR t R t!R t"RR lt#]#t$Rt%R# )generateRsaKeyN)Random)tobytesbordtostr)DerSequenceDerNull)bytes_to_long)Integer)test_probable_primegenerate_probable_prime	COMPOSITE)_expand_subject_public_key_info_create_subject_public_key_info _extract_subject_public_key_infoc                   ^  a  ] tR t^4t o RtR t]R 4       t]R 4       t]R 4       t	]R 4       t
]R 4       t]R 4       t]R	 4       t]R
 4       t]R 4       t]R 4       tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR'R ltR t R t!R t"R  t#R! t$R" t%R# t&R$ t'R% t(R&t)V t*R# )(r   a  Class defining an RSA key, private or public.
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 invp: Chinese remainder component (:math:`p^{-1} \text{mod } q`)
:vartype invp: integer

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

:ivar u: Same as ``invp``
:vartype u: integer
c                   \        VP                  4       4      p\        R4      pV\        R4      ,          pW$V39  d   \        R4      hVP                  4        F  w  rV\	        V RV,           V4       K  	  W$8X  d\   V P
                  V P                  ^,
          ,          V n        V P
                  V P                  ^,
          ,          V n	        RV n
        R# R# )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.
zSome RSA components are missing_Nne)pqdu)setkeys
ValueErroritemssetattr_d_p_dp_q_dq_invq)selfkwargs	input_set
public_setprivate_set	componentvalues   &,     I/home/ubuntu/cf-venv/lib/python3.14/site-packages/Crypto/PublicKey/RSA.py__init__RsaKey.__init__R   s    & &	_
 3';#<<*55>?? &ID#	/51 !/#ww$''A+.DHww$''A+.DHDJ $    c                ,    \        V P                  4      # N)int_nr'   s   &r.   r   RsaKey.nq       477|r1   c                ,    \        V P                  4      # r3   )r4   _er6   s   &r.   r   RsaKey.eu   r8   r1   c                n    V P                  4       '       g   \        R 4      h\        V P                  4      # )z-No private exponent available for public keys)has_privateAttributeErrorr4   r!   r6   s   &r.   r   RsaKey.dy   s+    !! !PQQ477|r1   c                n    V P                  4       '       g   \        R 4      h\        V P                  4      # )z.No CRT component 'p' available for public keys)r=   r>   r4   r"   r6   s   &r.   r   RsaKey.p   +    !! !QRR477|r1   c                n    V P                  4       '       g   \        R 4      h\        V P                  4      # )z.No CRT component 'q' available for public keys)r=   r>   r4   r$   r6   s   &r.   r   RsaKey.q   rB   r1   c                n    V P                  4       '       g   \        R 4      h\        V P                  4      # )z/No CRT component 'dp' available for public keys)r=   r>   r4   r#   r6   s   &r.   dp	RsaKey.dp   +    !! !RSS488}r1   c                n    V P                  4       '       g   \        R 4      h\        V P                  4      # )z/No CRT component 'dq' available for public keys)r=   r>   r4   r%   r6   s   &r.   dq	RsaKey.dq   rH   r1   c                    V P                  4       '       g   \        R 4      hV P                  f+   V P                  P	                  V P
                  4      V n        \        V P                  4      # )z1No CRT component 'invq' available for public keys)r=   r>   r&   r$   inverser"   r4   r6   s   &r.   invqRsaKey.invq   sM    !! !TUU::1DJ4::r1   c                    V P                   # r3   )r   r6   s   &r.   invpRsaKey.invp   s    vvr1   c                n    V P                  4       '       g   \        R 4      h\        V P                  4      # )z.No CRT component 'u' available for public keys)r=   r>   r4   _ur6   s   &r.   r   RsaKey.u   rB   r1   c                6    V P                   P                  4       # )zSize of the RSA modulus in bitsr5   size_in_bitsr6   s   &r.   rX   RsaKey.size_in_bits   s    ww##%%r1   c                `    V P                   P                  4       ^,
          ^,          ^,           # )z9The minimal amount of bytes that can hold the RSA modulusrW   r6   s   &r.   size_in_bytesRsaKey.size_in_bytes   s$    $$&*q0144r1   c                    ^ Tu;8:  d   V P                   8  g   M \        R4      h\        \        \	        V4      V P
                  V P                   4      4      # )    zPlaintext too large)r5   r   r4   powr   r:   )r'   	plaintexts   &&r.   _encryptRsaKey._encrypt   s@    I''2333wy)477DGG<==r1   c                   ^ Tu;8:  d   V P                   8  g   M \        R4      hV P                  4       '       g   \        R4      h\        P
                  ! ^V P                   R7      p\	        V4      \        W P                  V P                   4      ,          V P                   ,          p\        W0P                  V P                  4      p\        W0P                  V P                  4      pWT,
          V P                  ,          V P                  ,          pW`P                  ,          V,           p\        P                  ! VP                  V P                   4      VV P                   4      pV# )r^   zCiphertext too largezThis is not a private key)min_inclusivemax_exclusive)r5   r   r=   	TypeErrorr   random_ranger_   r:   r#   r"   r%   r$   rT   _mult_modulo_bytesrM   )	r'   
ciphertextrcpm1m2hmpresults	   &&       r.   _decrypt_to_bytesRsaKey._decrypt_to_bytes   s    J((344!!788
   qHZ 3q''477#;;dggEXXtww'XXtww'g DGG+[2 ++IIdgg&GG r1   c                6    \        V P                  V4      4      # )zLegacy private method)r
   rq   r'   ri   s   &&r.   _decryptRsaKey._decrypt   s     T33J?@@r1   c                    \        V R4      # )z"Whether this is an RSA private keyr!   )hasattrr6   s   &r.   r=   RsaKey.has_private   s     tT""r1   c                    R # T r6   s   &r.   can_encryptRsaKey.can_encrypt       r1   c                    R # r{   r|   r6   s   &r.   can_signRsaKey.can_sign   r   r1   c                D    \        V P                  V P                  R7      # )zFA matching RSA public key.

Returns:
    a new :class:`RsaKey` object
r   )r   r5   r:   r6   s   &r.   
public_keyRsaKey.public_key   s     477++r1   c                   V P                  4       VP                  4       8w  d   R # V P                  VP                  8w  g   V P                  VP                  8w  d   R # V P                  4       '       g   R# V P                  VP                  8H  # )FT)r=   r   r   r   r'   others   &&r.   __eq__RsaKey.__eq__   sf    !2!2!4466UWW%'' 1!!%''!"r1   c                    W8X  * # r3   r|   r   s   &&r.   __ne__RsaKey.__ne__   s    ""r1   c                    ^ RI Hp Vh)r^   )PicklingError)pickler   )r'   r   s   & r.   __getstate__RsaKey.__getstate__   s    (r1   c                J   V P                  4       '       d[   R \        V P                  4      \        V P                  4      \        V P                  4      \        V P
                  4      3,          pMRpR\        V P                  4      \        V P                  4      V3,          # )z, d=%d, p=%d, q=%d, u=%d zRsaKey(n=%d, e=%d%s))r=   r4   r!   r"   r$   rT   r5   r:   )r'   extras   & r.   __repr__RsaKey.__repr__   st    .#dgg,DGG25dgg,DGG2N NE E%TWWs477|U(KKKr1   c                `    V P                  4       '       d   R pMRpRV\        V 4      3,          # )PrivatePublicz%s RSA key at 0x%X)r=   id)r'   key_types   & r.   __str__RsaKey.__str__   s/     HH#xD&:::r1   Nc                :   Ve   \        V4      pVf   \        P                  pVR8X  d   V P                  V P                  3 Uu. uF  qwP                  4       NK  	  upw  r\        V^ ,          4      ^,          '       d
   RV,           p\        V	^ ,          4      ^,          '       d
   RV	,           p	RW.p
RP                  V
 Uu. uF*  p\        P                  ! R\        V4      4      V,           NK,  	  up4      pR\        P                  ! V4      RR ,           # V P                  4       '       Edb   \        ^ V P                  V P                   V P"                  V P$                  V P&                  V P"                  V P$                  ^,
          ,          V P"                  V P&                  ^,
          ,          \)        V P&                  4      P+                  V P$                  4      .	4      P-                  4       pV^8X  d   RpVR	8X  d   V'       d   \/        R
4      hM^ RIHp VR8X  d)   Vf%   RpVP5                  V\6        R\9        4       R7      pM~RpV'       g   V'       d   \/        R4      hRpVP5                  V\6        W$V\9        4       R7      pRpM:Rp\;        \6        \        V P                  V P                   .4      \9        4       4      pVR	8X  d   V# VR8X  d$   ^ RIHp VP-                  WW%4      p\        V4      # \/        RV,          4      hu upi u upi )a
  Export this RSA key.

Keyword Args:
  format (string):
    The desired output format:

    - ``'PEM'``. (default) Text output, according to `RFC1421`_/`RFC1423`_.
    - ``'DER'``. Binary output.
    - ``'OpenSSH'``. Text output, according to the OpenSSH specification.
      Only suitable for public keys (not private keys).

    Note that PEM contains a DER structure.

  passphrase (bytes or string):
    (*Private keys only*) The passphrase to protect the
    private key.

  pkcs (integer):
    (*Private keys only*) The standard to use for
    serializing the key: PKCS#1 or PKCS#8.

    With ``pkcs=1`` (*default*), the private key is encoded with a
    simple `PKCS#1`_ structure (``RSAPrivateKey``). The key cannot be
    securely encrypted.

    With ``pkcs=8``, the private key is encoded with a `PKCS#8`_ structure
    (``PrivateKeyInfo``). PKCS#8 offers the best ways to securely
    encrypt the key.

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

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

    You can only specify a value if ``pkcs=8``.
    For all possible protection schemes,
    refer to :ref:`the encryption parameters of PKCS#8<enc_params>`.
    The recommended value is
    ``'PBKDF2WithHMAC-SHA512AndAES256-CBC'``.

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

    - if ``format='PEM'``, the obsolete PEM encryption scheme is used.
      It is based on MD5 for key derivation, and 3DES for encryption.

    - if ``format='DER'``, the ``'PBKDF2WithHMAC-SHA1AndDES-EDE3-CBC'``
      scheme is used.

  prot_params (dict):
    (*For private keys only*)

    The parameters to use to derive the encryption key
    from the passphrase. ``'protection'`` must be also specified.
    For all possible values,
    refer to :ref:`the encryption parameters of PKCS#8<enc_params>`.
    The recommendation is to use ``{'iteration_count':21000}`` for PBKDF2,
    and ``{'iteration_count':131072}`` for scrypt.

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

Returns:
  bytes: 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OpenSSH    s   ssh-rsar1   >I   ssh-rsa zRSA PRIVATE KEYDERz&PKCS#1 private key cannot be encryptedPKCS8PEMzPRIVATE KEY)
key_paramszENCRYPTED PRIVATE KEYz"'protection' parameter must be setz"PBKDF2WithHMAC-SHA1AndDES-EDE3-CBC)prot_paramsr   z
PUBLIC KEYr   z3Unknown key format '%s'. Cannot export the RSA key.)r   r   get_random_bytesr:   r5   to_bytesr   joinstructpacklenbinascii
b2a_base64r=   r   r   r   r   r   r   r   rM   encoder   	Crypto.IOr   wrapoidr	   r   r   )r'   format
passphrasepkcs
protectionrandfuncr   xe_bytesn_byteskeypartskp	keystring
binary_keyr   r   r   pem_strs   &&&&&&&           r.   
export_keyRsaKey.export_key  s   l ! ,J..HY7;ww6HI6H

6HIGGAJ$&&!G+GAJ$&&!G+"G5HH!UHb&++dCG"<r"A"AH!UVI!4!4Y!?!DDD $a&*ff&*ff&*ff&*ff&*ff&*ffq&9&*ffq&9&-dffo&=&=dff&E	&( 	) *0  qy,U?z$%MNN+U?z'9,H!&JT7>y ", "BJ  7H%&",-Q"RR%I
!&J,68C7>y ", "BJ "&J#H89DdffFJffFN :O9@;J U?U?%jjzLG7##NQWWXXy  J "Vs   L0Lc                &    V P                   ! V/ VB # :meta private:)r   )r'   argsr(   s   &*,r.   	exportKeyRsaKey.exportKey  s    ///r1   c                "    V P                  4       # r   )r   r6   s   &r.   	publickeyRsaKey.publickey  s      r1   c                    \        R4      hr   z,Use module Crypto.Signature.pkcs1_15 insteadNotImplementedError)r'   MKs   &&&r.   signRsaKey.sign      !"PQQr1   c                    \        R4      hr   r   )r'   r   	signatures   &&&r.   verifyRsaKey.verify  r   r1   c                    \        R4      hr   z+Use module Crypto.Cipher.PKCS1_OAEP insteadr   )r'   r`   r   s   &&&r.   encryptRsaKey.encrypt      !"OPPr1   c                    \        R4      hr   r   rt   s   &&r.   decryptRsaKey.decrypt  r   r1   c                    \         hr   r   r'   r   Bs   &&&r.   blindRsaKey.blind      !!r1   c                    \         hr   r   r   s   &&&r.   unblindRsaKey.unblind  r   r1   c                    \         hr   r   r6   s   &r.   sizeRsaKey.size  r   r1   )r#   r%   r&   )r   N   NNN)+__name__
__module____qualname____firstlineno____doc__r/   propertyr   r   r   r   r   rF   rJ   rN   rQ   r   rX   r[   ra   rq   ru   r=   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __static_attributes____classdictcell__)__classdict__s   @r.   r   r   4   s]    :>      
  
  
  
  
      
&5>
2A
#
,##
L;YYx0!
RRQQ""" "r1   c           	     p  aaaaa V R8  d   \        R4      hS^,          ^ 8X  g   S^8  d   \        R4      hVf   \        P                  p\        ^4      ;r4\        S4      oVP	                  4       V 8w  Ed   V^V ^,          ,          8  d   V ^,          pW,
          p\        ^4      ^V,          ^,
          ,          P                  4       ;ooWV8w  d/   \        ^4      ^V,          ^,
          ,          P                  4       oVV3R lp\        VVVR7      o\        ^4      V ^,          ^d,
          ,          oVVVV3R lp\        VVVR7      p	SV	,          pS^,
          P                  V	^,
          4      p
SP                  V
4      pEK(  SX	8  d   V	Suop	SP                  V	4      p\        VSVSWR7      # )a  Create 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.
Keyword Args:
  randfunc (callable):
    Function that returns random bytes.
    The default is :func:`Crypto.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
i   z"RSA modulus length must be >= 1024zBRSA public exponent must be a positive, odd integer larger than 2.c                 T   < V S8  ;'       d    V ^,
          P                  S4      ^8H  # r   )gcd)	candidater   min_ps   &r.   filter_pgenerate.<locals>.filter_p  s*    u$DD)a-)<)<Q)?1)DDr1   )
exact_bitsr   prime_filterc                    < V S8  ;'       d9    V ^,
          P                  S4      ^8H  ;'       d    \        V S,
          4      S8  # r   )r   abs)r   r   min_distancemin_qr   s   &r.   filter_qgenerate.<locals>.filter_q  sL    % 6 6]''*a/6 6	A&57r1   r   r   r   r   r   r   )
r   r   r   r   rX   sqrtr   lcmrM   r   )bitsr   r   r   r   size_qsize_pr  r	  r   r  r   r  r   r  r   s   &&f         @@@@r.   r   r     s   < d{=>>1uzQU]^^**AJA
A
..
d
"qA$!),<'=  F
Q7==??QZAJN399;E	E $v-519; qzdai#o6	7 	7
 $v-519; E1ukk!a% IIcN1u!1			!AAa1//r1   c           	     N    ! R R\         4      pV! 4       p\        R
V 4       F  w  rE\        W4\        V4      4       K  	  VP                  pVP
                  p\        VR4      '       g   \        WgR7      pEMgVP                  p	\        VR4      '       d   VP                  p
VP                  pMW,          ^,
          pTpV^,          ^ 8X  d   V^,          pK  Rp\        ^4      pV'       g   V^d8  d   \        V4      pVV8  dd   \        VVV4      pV^8w  dE   VV^,
          8w  d7   \        V^V4      ^8X  d%   \        V4      P                  V^,           4      p
RpMV^,          pKj  V^,          pK  V'       g   \        R	4      hVX
,          ^ 8X  g   Q hWj,          p\        VR4      '       d   VP                  pMV
P                  V4      p\        WgWVVR
7      pV'       Ed   V^8:  g   Wv8  d   \        R4      h\        V4      P                  V4      ^8w  d   \        R4      hV^,          '       g   \        R4      hVP!                  4       '       EdJ   X	^8:  g   W8  d   \        R4      h\        V4      P                  V	4      ^8w  d   \        R4      hX
X,          V8w  d   \        R4      h\#        V
4      \$        8X  d   \        R4      h\#        V4      \$        8X  d   \        R4      hV
^,
          V^,
          ,          pVV
^,
          P                  V^,
          4      ,          pWy,          \'        V4      ,          ^8w  d   \        R4      h\        VR4      '       d:   X^8:  g   VV8  d   \        R4      hV
V,          V,          ^8w  d   \        R4      hV# )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.

Keyword Args:
    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                       ] tR tRtRtR# )construct.<locals>.InputCompsiD  r|   N)r   r   r   r   r   r|   r1   r.   
InputCompsr  D  s    r1   r  r   r   r   r   FTz2Unable to compute factors p and q from exponent d.r  zInvalid RSA public exponentz-RSA public exponent is not coprime to moduluszRSA modulus is not oddzInvalid RSA private exponentz.RSA private exponent is not coprime to modulusz RSA factors do not match moduluszRSA factor p is compositezRSA factor q is compositezInvalid RSA conditionzInvalid RSA component uzInvalid RSA component u with p)objectzipr    r   r   r   rx   r   r   r   r   r_   r   r   r   rM   r=   r   r   r4   )rsa_componentsconsistency_checkr  input_compscompr-   r   r   keyr   r   r   ktottspottedakcandr   phir  s   &&                   r.   	constructr#    s   RV  ,K;^L75>2 M 	AA;$$qMM;$$AA
 519D Aa%1*a G
A!c'AJ$hq!Q<DqyTa!e_T1aA9M $AJNN4!84"&FAQ !UVVUqL!LA;$$A		!A q12  6QV:;;1:>>!!LMM 1uu566??Av !?@@qz~~a A% !QRR1uz !CDD"1%2 !<=="1%2 !<==q5QU#C!a%QU++CC Q& !899sC  6Q!V$%>??EAI!#$%EFFJr1   c                     \        4       P                  V ^	RR7      pV^ ,          ^ 8w  d   \        R4      h\        VR,          \	        V^,          4      P                  V^,          4      .,           4      # )	   Tnr_elementsonly_ints_expectedz(No PKCS#1 encoding of an RSA private key:r      N)r   decoder   r#  r   rM   encodedr(   ders   &* r.   _import_pkcs1_privater.    sb     -

wA$

OC
1v{CDDSXQ!8!8Q!@ AABBr1   c                 P    \        4       P                  V ^RR7      p\        V4      # )   Tr&  )r   r*  r#  r+  s   &* r.   _import_pkcs1_publicr1    s'    
 -

wA$

OCS>r1   c                 n    \         R 3p\        V 4      w  r4pW29  g   Ve   \        R4      h\        V4      # )1.2.840.113549.1.1.10zNo RSA subjectPublicKeyInfo)r   r   r   r1  )r,  r(   oidsalgoidencoded_keyparamss   &*    r.   _import_subjectPublicKeyInfor8    s>    ()D"A'"JFV/677,,r1   c                 .    \        V 4      p\        V4      # r3   )r   r8  )r,  r(   sp_infos   &* r.   _import_x509_certr;    s    .w7G'00r1   c                     ^ RI Hp \        R3pVP                  W4      pV^ ,          V9  d   \	        R4      h\        V^,          V4      # )r^   r   r3  zNo PKCS#8 encoded RSA key)r   r   r   unwrapr   _import_keyDER)r,  r   r   r4  r   s   &&   r.   _import_pkcs8r?    sG    ()DW)At4455!A$
++r1   c                    \         \        \        \        \        3pV F  p V! W4      u # 	  \        R4      h  \
         d     K)  i ; i)z@Import an RSA key (public or private half), encoded in DER form.RSA key format is not supported)r.  r1  r8  r;  r?  r   )
extern_keyr   	decodingsdecodings   &&  r.   r>  r>    sX     '%-"	 I 	J33  6
77  		s   9AAc                 ^   ^RI HpHpHpHp V! W4      w  rgVR8w  d   \        R4      hV! V4      w  rV! V4      w  rV! V4      w  rV! V4      w  rV! V4      w  rV! V4      w  rV! V4      w  rV! V4       WWW3 Uu. uF  p\        P                  ! V4      NK  	  pp\        V4      # u upi )r   )import_openssh_private_generic
read_bytesread_stringcheck_paddingzssh-rsazThis SSH key is not RSA)	_opensshrF  rG  rH  rI  r   r   
from_bytesr#  )datapasswordrF  rG  rH  rI  ssh_name	decryptedr   r   r   iqmpr   r   r   paddedr   builds   &&                r.   _import_openssh_private_rsarS    s    C C 9HH9233i(LAi(LAi(LA +ODi(LAi(LAI&IA&-.1,AB,AqW",AEBU Cs   >B*c                   ^ RI Hp \        V 4      p Ve   \        V4      pV P                  R4      '       d-   \	        V 4      pVP                  W14      w  rEp\        WA4      pV# V P                  R4      '       d4   VP                  \	        V 4      V4      w  rpV'       d   Rp\        W4      # V P                  R4      '       d   \        P                  ! V P                  R4      ^,          4      p	. p
\        V	4      ^8  dO   \        P                  ! RV	R,          4      ^ ,          pV
P                  V	^^V,            4       V	^V,           R p	K^  \        P                   ! V
^,          4      p\        P                   ! V
^,          4      p\#        W.4      # \        V 4      ^ 8  d#   \%        V ^ ,          4      ^08X  d   \        W4      # \'        R	4      h)
ay  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
r   Ns   -----BEGIN OPENSSH PRIVATE KEYs   -----r       r   :N   NrA  )r   r   r   
startswithr   r*  rS  r>  r   
a2b_base64splitr   r   unpackappendr   rK  r#  r   r   )rB  r   r   text_encodedopenssh_encodedmarkerenc_flagrp   r-  r   r   lengthr   r   s   &&            r.   
import_keyra    s   R $JZ(
>??Z(,/JJ|,P),_IX&&"%**U:->
"KhJc..[))''
(8(8(>q(AB	)nq ]]427:FOOIaF
34!!f*+.Ix{+x{+!  
:tJqM2d:j55
6
77r1   z1.2.840.113549.1.1.1)r   r#  ra  r   r   )Ni  r{   r3   )&__all__r   r   Cryptor   Crypto.Util.py3compatr   r   r   Crypto.Util.asn1r   r	   Crypto.Util.numberr
   Crypto.Math.Numbersr   Crypto.Math.Primalityr   r   r   Crypto.PublicKeyr   r   r   r  r   r   r#  r.  r1  r8  r;  r?  r>  rS  ra  	importKeyr   r|   r1   r.   <module>rk     s   @    6 6 1 , 'G G@ @
R"V R"jO0dM`C(-1,8$0L8` 	 r1   