
    Ii                    v   S r SSKrSSKrSSKrSSKrSSKrSSKrSSKJrJ	r	J
r
Jr  SSKJr  SSKJrJrJrJr  SSKrSSKJr  SSKJrJr  SSKJr  SS	KJr  SS
KJrJrJrJ r J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+J,r,J-r-J.r.J/r/J0r0J1r1J2r2J3r3J4r4J5r5J6r6J7r7J8r8J9r9J:r:J;r;J<r<J=r=J>r>J?r?J@r@JArAJBrBJCrCJDrDJErEJFrFJGrGJHrHJIrIJJrJJKrKJLrLJMrMJNrN  SSKOJPrPJQrQ  SSKRJSrS  SSKTJUrU  SSKVJWrW  SSKXJYrYJZrZ  SSK[J\r\  SSK]J^r^J_r_  SSK`Jara  SSKbJcrcJdrdJere  SSKfJgrgJhrhJiri  SSKjJkrk  SSKlJmrmJnrn  SSKoJprp  SSKqJrrr  SSKsJtrt  SSKuJvrv  SSKwJxrx  SSKyJzrzJ{r{J|r|J}r}J~r~Jr  SSKJrJrJr   SSKJr  / rS rSSKr\GR                  " \5         " S  S!\GR                  \5      r " S" S#5      r " S$ S%5      r " S& S'\5      rg! \ a	    SSKJr   Naf = f)(z
Core protocol implementation
    N)md5sha1sha256sha512)default_backend)
algorithmsCiphermodesaead)util)AuthHandlerAuthOnlyHandler)GSSAuth)Channel)2	xffffffffcMSG_CHANNEL_OPENcMSG_IGNOREcMSG_GLOBAL_REQUESTDEBUGMSG_KEXINIT
MSG_IGNOREMSG_DISCONNECT	MSG_DEBUGERRORWARNINGcMSG_UNIMPLEMENTEDINFOcMSG_KEXINITcMSG_NEWKEYSMSG_NEWKEYScMSG_REQUEST_SUCCESScMSG_REQUEST_FAILURECONNECTION_FAILED_CODE'OPEN_FAILED_ADMINISTRATIVELY_PROHIBITEDOPEN_SUCCEEDEDcMSG_CHANNEL_OPEN_FAILUREcMSG_CHANNEL_OPEN_SUCCESSMSG_GLOBAL_REQUESTMSG_REQUEST_SUCCESSMSG_REQUEST_FAILUREcMSG_SERVICE_REQUESTMSG_SERVICE_ACCEPTMSG_CHANNEL_OPEN_SUCCESSMSG_CHANNEL_OPEN_FAILUREMSG_CHANNEL_OPENMSG_CHANNEL_SUCCESSMSG_CHANNEL_FAILUREMSG_CHANNEL_DATAMSG_CHANNEL_EXTENDED_DATAMSG_CHANNEL_WINDOW_ADJUSTMSG_CHANNEL_REQUESTMSG_CHANNEL_EOFMSG_CHANNEL_CLOSEMIN_WINDOW_SIZEMIN_PACKET_SIZEMAX_WINDOW_SIZEDEFAULT_WINDOW_SIZEDEFAULT_MAX_PACKET_SIZEHIGHEST_USERAUTH_MESSAGE_IDMSG_UNIMPLEMENTED	MSG_NAMESMSG_EXT_INFOcMSG_EXT_INFObyte_ord)ZlibCompressorZlibDecompressor)DSSKey)
Ed25519Key)KexCurve25519)KexGexKexGexSHA256)	KexGroup1)
KexGroup14KexGroup14SHA256)KexGroup16SHA512)KexNistp256KexNistp384KexNistp521)	KexGSSGexKexGSSGroup1KexGSSGroup14)Message)
PacketizerNeedRekeyException)ModulusPack)RSAKey)ECDSAKey)ServerInterface)
SFTPClient)BadAuthenticationTypeChannelExceptionIncompatiblePeerMessageOrderErrorProxyCommandFailureSSHException)ClosingContextManagerclamp_valueb)	TripleDESc                  >    [          H  n U R                  5         M     g N)_active_threadsstop_thread)thrs    8/venv/lib/python3.13/site-packages/paramiko/transport.py_join_lingering_threadsrl      s         c                   B   \ rS rSrSr\" 5       r\" 5       rSrSR                  \
R                  5      rSrSrSrSrSr\R&                  " 5       (       a  S	\-   rS
rSr\R.                  \R2                  SSS.\R.                  \R2                  SSS.\R.                  \R2                  SSS.\R.                  \R4                  SSS.\R.                  \R4                  SSS.\R.                  \R4                  SSS.\\R4                  SSS.\R:                  SSSSS.\R:                  SSSSS.S.	r\SS.\SS.\ SS.\ SS.\!SS.\!SS.\"SS.\"SS.S.r#0 S\$_S\$_S\$_S\$_S\$_S\$_S\%_S\%_S \&_S!\&_S"\&_S#\&_S$\&_S%\&_S&\'_S'\'_r(\)\*\+\,\-\.\/\0\1\2\3\4S(.r5\R&                  " 5       (       a  \\5S)'   \6\74\6\74S*S+.r8S,r9S-r:\;\<S.SS,SSS,4S/ jr=S0 r>\?S1 5       r@\?S2 5       rA\?S3 5       rB\?S4 5       rC\?S5 5       rD\?S6 5       rES7 rFS8 rGS9 rHSS: jrIS*S; jrJS*S< jrKS= rLS> rM\NSS? j5       rOS@ rPSA rQSB rR SSC jrSSSD jrTSE rUSF rV     SSG jrWSSH jrXSI rYSJ rZSSK jr[SL r\SM r]SSN jr^SSO jr_         SSP jr`SQ raSR rbSS rcST rdSU reSV rfSSW jrgSSX jrhSSY jriSSZ jrjS[ rkS\ rlS] rmS^ rnS_ roS` rpSSa jrqSb rrSc rsSd rtSe ruSf rvSg rwSh rxSi rySj rzSk r{Sl r|Sm r}SSn jr~So rSp rSq rSr rSs rSt rSu rSv rSw rSx rSy rSz rSS{ jrS| rS} rS~ rS rS rS rS rS rS rS rS rS rS rS rS rS r\\GR<                  \\GR@                  \\GRD                  \\GRH                  \\GRL                  \\GRP                  \\GRT                  \\GRX                  0rSrg,)	Transport   ah  
An SSH Transport attaches to a stream (usually a socket), negotiates an
encrypted session, authenticates, and then creates stream tunnels, called
`channels <.Channel>`, across the session.  Multiple channels can be
multiplexed across a single session (and often are, in the case of port
forwardings).

Instances of this class may be used as context managers.
2.0zparamiko_{})	z
aes128-ctrz
aes192-ctrz
aes256-ctrz
aes128-cbcz
aes192-cbcz
aes256-cbcz3des-cbczaes128-gcm@openssh.comzaes256-gcm@openssh.com)hmac-sha2-256hmac-sha2-512hmac-sha2-256-etm@openssh.comhmac-sha2-512-etm@openssh.com	hmac-sha1hmac-md5hmac-sha1-96hmac-md5-96)ssh-ed25519ecdsa-sha2-nistp256ecdsa-sha2-nistp384ecdsa-sha2-nistp521rsa-sha2-512rsa-sha2-256ssh-rsassh-dss)	ecdh-sha2-nistp256ecdh-sha2-nistp384ecdh-sha2-nistp521diffie-hellman-group16-sha512$diffie-hellman-group-exchange-sha256diffie-hellman-group14-sha256"diffie-hellman-group-exchange-sha1diffie-hellman-group14-sha1diffie-hellman-group1-sha1)curve25519-sha256@libssh.org)%gss-gex-sha1-toWM5Slw5Ew8Mqkay+al2g==)gss-group14-sha1-toWM5Slw5Ew8Mqkay+al2g==(gss-group1-sha1-toWM5Slw5Ew8Mqkay+al2g==none   )classmode
block-sizekey-size             T)r   r   iv-sizer   is_aead   )r   size@   )rv   rx   rr   rt   rs   ru   rw   ry   r   zssh-rsa-cert-v01@openssh.comr   z!rsa-sha2-256-cert-v01@openssh.comr~   z!rsa-sha2-512-cert-v01@openssh.comr   zssh-dss-cert-v01@openssh.comr{   z(ecdsa-sha2-nistp256-cert-v01@openssh.comr|   z(ecdsa-sha2-nistp384-cert-v01@openssh.comr}   z(ecdsa-sha2-nistp521-cert-v01@openssh.comrz   z ssh-ed25519-cert-v01@openssh.com)r   r   r   r   r   r   r   r   r   r   r   r   r   )NNzlib@openssh.comzlibr   N皙?Fc
                 
   SU l         SU l        0 U l        Xl        SU l        [        U[        5      (       aF  UR                  SS5      n
U
S   U l        [        U
5      S:X  a  U
S   S4nOU
S   [        U
S   5      4n[        U5      [        L a  Uu  pXl        Sn[        R                  " X[        R                  [        R                  5      nU HY  u  nnnnnU[        R                  :X  d  M  Un[        R                  " U[        R                  5      n UR!                  X45          O   [%        SR'                  X5      5      e[(        R*                  R-                  U 5        S	U l        Xl        U R0                  R3                  U R4                  5        U	=(       d    [6        " U5      U l        S
U R:                  -   S-   U R<                  -   U l        SU l         S=U l!        U l"        S=U l#        U l$        S=U l%        U l&        S=U l'        U l(        SU l)        SU l*        SU l+        X@l,        SU l-        SU l.        SU l/        U RX                  (       a/  [a        SU5      U l.        U Rb                  U Rd                  -   U l2        SU l3        SU l4        SU l5        SU l6        SU l7        SU l8        [        5       U l9        [(        Rt                  " 5       U l;        [y        5       U l=        0 U l>        0 U l?        SU l@        X0lA        X lB        SU lC        SU lD        SU lE        SU lF        [(        R                  " 5       U lH        [(        Rt                  " 5       U lI        SU lJ        SU lK        [        R                  " U R                  5      U lN        U R8                  R                  U R                  5        SU lP        SU lQ        SU lR        SU lS        SU lT        SU lU        SU lV        U=(       d    0 U lW        XplX        SU lY        SU lZ        0 U l[        / U l\        [(        R                  " U Rv                  5      U l^        0 U l_        [        U R                  [        U R                  [        U R                  [        U R                  [        U R                  [        U R                  [        U R                  [        U R                  [        U R                  0	U lr        g! [        R"                   a  n[        U5      n SnAGM-  SnAff = f)aM  
Create a new SSH session over an existing socket, or socket-like
object.  This only creates the `.Transport` object; it doesn't begin
the SSH session yet.  Use `connect` or `start_client` to begin a client
session, or `start_server` to begin a server session.

If the object is not actually a socket, it must have the following
methods:

- ``send(bytes)``: Writes from 1 to ``len(bytes)`` bytes, and returns
  an int representing the number of bytes written.  Returns
  0 or raises ``EOFError`` if the stream has been closed.
- ``recv(int)``: Reads from 1 to ``int`` bytes and returns them as a
  string.  Returns 0 or raises ``EOFError`` if the stream has been
  closed.
- ``close()``: Closes the socket.
- ``settimeout(n)``: Sets a (float) timeout on I/O operations.

For ease of use, you may also pass in an address (as a tuple) or a host
string as the ``sock`` argument.  (A host string is a hostname with an
optional port (separated by ``":"``) which will be converted into a
tuple of ``(hostname, port)``.)  A socket will be connected to this
address and used for communication.  Exceptions from the ``socket``
call may be thrown in this case.

.. note::
    Modifying the the window and packet sizes might have adverse
    effects on your channels created from this transport. The default
    values are the same as in the OpenSSH code base and have been
    battle tested.

:param socket sock:
    a socket or socket-like object to create the session over.
:param int default_window_size:
    sets the default window size on the transport. (defaults to
    2097152)
:param int default_max_packet_size:
    sets the default max packet size on the transport. (defaults to
    32768)
:param bool gss_kex:
    Whether to enable GSSAPI key exchange when GSSAPI is in play.
    Default: ``False``.
:param bool gss_deleg_creds:
    Whether to enable GSSAPI credential delegation when GSSAPI is in
    play. Default: ``True``.
:param dict disabled_algorithms:
    If given, must be a dictionary mapping algorithm type to an
    iterable of algorithm identifiers, which will be disabled for the
    lifetime of the transport.

    Keys should match the last word in the class' builtin algorithm
    tuple attributes, such as ``"ciphers"`` to disable names within
    ``_preferred_ciphers``; or ``"kex"`` to disable something defined
    inside ``_preferred_kex``. Values should exactly match members of
    the matching attribute.

    For example, if you need to disable
    ``diffie-hellman-group16-sha512`` key exchange (perhaps because
    your code talks to a server which implements it differently from
    Paramiko), specify ``disabled_algorithms={"kex":
    ["diffie-hellman-group16-sha512"]}``.
:param bool server_sig_algs:
    Whether to send an extra message to compatible clients, in server
    mode, with a list of supported pubkey algorithms. Default:
    ``True``.
:param bool strict_kex:
    Whether to advertise (and implement, if client also advertises
    support for) a "strict kex" mode for safer handshaking. Default:
    ``True``.
:param packetizer_class:
    Which class to use for instantiating the internal packet handler.
    Default: ``None`` (i.e.: use `Packetizer` as normal).

.. versionchanged:: 1.15
    Added the ``default_window_size`` and ``default_max_packet_size``
    arguments.
.. versionchanged:: 1.15
    Added the ``gss_kex`` and ``gss_deleg_creds`` kwargs.
.. versionchanged:: 2.6
    Added the ``disabled_algorithms`` kwarg.
.. versionchanged:: 2.9
    Added the ``server_sig_algs`` kwarg.
.. versionchanged:: 3.4
    Added the ``strict_kex`` kwarg.
.. versionchanged:: 3.4
    Added the ``packetizer_class`` kwarg.
FN:   r      zNo suitable address familyzUnable to connect to {}: {}TSSH-- zgssapi-keyexg      >@zparamiko.transport      i  )sactivehostnameserver_extensionsadvertise_strict_kexagreed_on_strict_kex
isinstancestrsplitleninttypetuplesocketgetaddrinfo	AF_UNSPECSOCK_STREAMconnecterrorra   format	threadingThread__init__daemonsock
settimeout_active_check_timeoutrU   
packetizer	_PROTO_ID
_CLIENT_IDlocal_versionremote_versionlocal_cipherremote_cipherlocal_kex_initremote_kex_init	local_mac
remote_maclocal_compressionremote_compression
session_idhost_key_typehost_keyuse_gss_kexgss_kex_usedkexgss_ctxtgss_hostr   _preferred_gsskex_preferred_kex
kex_engineHKinitial_kex_donein_kexauthenticated_expected_packetLocklock
ChannelMap	_channelschannel_eventschannels_seen_channel_counterdefault_max_packet_sizedefault_window_size_forward_agent_handler_x11_handler_tcp_handlersaved_exceptionEventclear_to_sendclear_to_send_lockclear_to_send_timeoutlog_namer   
get_loggerloggerset_logauth_handlerglobal_responsecompletion_eventbanner_timeouthandshake_timeoutauth_timeoutchannel_timeoutdisabled_algorithmsserver_sig_algsserver_modeserver_objectserver_key_dictserver_accepts	Conditionserver_accept_cvsubsystem_tabler@   _parse_ext_infor    _parse_newkeysr(   _parse_global_requestr)   _parse_request_successr*   _parse_request_failurer-   _parse_channel_open_successr.   _parse_channel_open_failurer/   _parse_channel_openr   _negotiate_keys_handler_table)selfr   r   r   gss_kexgss_deleg_credsr   r   
strict_kexpacketizer_classhlr   portreason	addrinfosfamilysocktypeproto	canonnamesockaddrafes                         rk   r   Transport.__init__l  sa   F !#$.!$)! dC  C#BqEDM2w!|1r{1s2a5z*:!NH$M1F** 0 0&2D2DI AJ<%Hv111B!==V-?-?@Dh%56  AJ #188J  	!!$'	 			T778 ,9z94@#dnn4s:T__L 133D.599d2+//;??!8! #!&~GD"&"8"84;N;N"ND  %" %NN$	 $  !'>$#6 &*#  #&__."+.."2%)",oodmm4, # $  "$&#6#<" . !!!  ) 3 3DII >!
 $..,, : :!<!<!<!<$d&F&F$d&F&Fd66--

 "<< (!$Q(s   ST-S??Tc                 h   ^ ^ [        T SR                  T5      5      n[        U U4S jU 5       5      $ )Nz_preferred_{}c              3   l   >#    U  H)  nUTR                   R                  T/ 5      ;  d  M%  Uv   M+     g 7frg   )r   get).0xr  type_s     rk   	<genexpr>.Transport._filter_algorithm.<locals>.<genexpr>[  s5      
0044UB?? As   $4	4)getattrr   r   )r  r(  defaults   `` rk   _filter_algorithmTransport._filter_algorithmY  s4    $ 6 6u => 

 
 	
rm   c                 $    U R                  S5      $ )Nciphersr-  r  s    rk   preferred_ciphersTransport.preferred_ciphersa      %%i00rm   c                 $    U R                  S5      $ )Nmacsr1  r2  s    rk   preferred_macsTransport.preferred_macse  s    %%f--rm   c                 `    U R                  S5      n[        U[        S U 5       5      -   5      $ )Nkeysc              3   D   #    U  H  nS R                  U5      v   M     g7f)z{}-cert-v01@openssh.comN)r   )r&  r'  s     rk   r)  +Transport.preferred_keys.<locals>.<genexpr>r  s     JA-44Q77s    )r-  r   )r  filtereds     rk   preferred_keysTransport.preferred_keysi  s8     ))&1JJJK
 	
rm   c                 $    U R                  S5      $ )Npubkeysr1  r2  s    rk   preferred_pubkeysTransport.preferred_pubkeysu  r5  rm   c                 $    U R                  S5      $ )Nkexr1  r2  s    rk   preferred_kexTransport.preferred_kexy  s    %%e,,rm   c                 $    U R                  S5      $ )Ncompressionr1  r2  s    rk   preferred_compressionTransport.preferred_compression}  s    %%m44rm   c                    [        [        U 5      [        -  5      nSR                  U5      nU R                  (       d  US-  nOU R
                  S:w  a<  USR                  U R
                  U R                  U R
                     S   S-  5      -  nU R                  5       (       a(  USR                  [        U R                  5      5      -  nOU R                  (       a  US-  nOUS	-  nUS
-  nU$ )@
Returns a string representation of this object, for debugging.
z<paramiko.Transport at {}z (unconnected)r   z (cipher {}, {:d} bits)r   r   z (active; {} open channel(s))z (connected; awaiting auth)z (connecting)>)hexidr   r   r   r   _cipher_infois_authenticatedr   r   r   )r  id_outs      rk   __repr__Transport.__repr__  s     "T(Y&')005{{##C  B&077%%%%d&7&78DqH  $$&&6=='  &&44&s

rm   c                 X    U R                   R                  5         U R                  5         g)an  
Terminate this Transport without closing the session.  On posix
systems, if a Transport is open during process forking, both parent
and child will share the underlying socket, but only one process can
use the connection (without corrupting the session).  Use this method
to clean up a Transport object without disrupting the other process.

.. versionadded:: 1.5.3
N)r   closer2  s    rk   atforkTransport.atfork  s     			

rm   c                     [        U 5      $ )z
Return a `.SecurityOptions` object which can be used to tweak the
encryption algorithms this transport will permit (for encryption,
digest/hash operations, public keys, and key exchanges) and the order
of preference for them.
)SecurityOptionsr2  s    rk   get_security_optionsTransport.get_security_options  s     t$$rm   c                 ~    U(       d  gUc  U R                   nU(       a  Ub  [        R                  " U5      nXl        g)am  
Normalize/canonicalize ``self.gss_host`` depending on various factors.

:param str gss_host:
    The explicitly requested GSS-oriented hostname to connect to (i.e.
    what the host's name is in the Kerberos database.) Defaults to
    ``self.hostname`` (which will be the 'real' target hostname and/or
    host portion of given socket object.)
:param bool trust_dns:
    Indicates whether or not DNS is trusted; if true, DNS will be used
    to canonicalize the GSS hostname (which again will either be
    ``gss_host`` or the transport's default hostname.)
    (Defaults to True due to backwards compatibility.)
:param bool gssapi_requested:
    Whether GSSAPI key exchange or authentication was even requested.
    If not, this is a no-op and nothing happens
    (and ``self.gss_host`` is not set.)
    (Defaults to True due to backwards compatibility.)
:returns: ``None``.
N)r   r   getfqdnr   )r  r   	trust_dnsgssapi_requesteds       rk   set_gss_hostTransport.set_gss_host  s6    ,   }}H-~~h/H rm   c                    SU l         Ub  Xl        U R                  5         g[        R                  " 5       =U l        nU R                  5         Ub  [
        R
                  " 5       U-   OSn UR                  S5        U R                   (       d   U R                  5       nUb  Ue[        S5      eUR                  5       (       d  Ub  [
        R
                  " 5       U:  a  gMv  )a  
Negotiate a new SSH2 session as a client.  This is the first step after
creating a new `.Transport`.  A separate thread is created for protocol
negotiation.

If an event is passed in, this method returns immediately.  When
negotiation is done (successful or not), the given ``Event`` will
be triggered.  On failure, `is_active` will return ``False``.

(Since 1.4) If ``event`` is ``None``, this method will not return until
negotiation is done.  On success, the method returns normally.
Otherwise an SSHException is raised.

After a successful negotiation, you will usually want to authenticate,
calling `auth_password <Transport.auth_password>` or
`auth_publickey <Transport.auth_publickey>`.

.. note:: `connect` is a simpler method for connecting as a client.

.. note::
    After calling this method (or `start_server` or `connect`), you
    should no longer directly read from or write to the original socket
    object.

:param .threading.Event event:
    an event to trigger when negotiation is complete (optional)

:param float timeout:
    a timeout, in seconds, for SSH2 session negotiation (optional)

:raises:
    `.SSHException` -- if negotiation fails (and no ``event`` was
    passed in)
TNr   Negotiation failed.)
r   r   startr   r   timewaitget_exceptionra   is_set)r  eventtimeoutmax_timer!  s        rk   start_clientTransport.start_client  s    F $)!JJL )2(99

,3,?499;(TJJsO;;&&(=G"#899||~~#		x(? rm   c                    Uc
  [        5       nSU l        X l        SU l        Ub  Xl        U R                  5         g[        R                  " 5       =U l        nU R                  5          UR                  S5        U R                  (       d   U R                  5       nUb  Ue[        S5      eUR                  5       (       a  gMZ  )ah  
Negotiate a new SSH2 session as a server.  This is the first step after
creating a new `.Transport` and setting up your server host key(s).  A
separate thread is created for protocol negotiation.

If an event is passed in, this method returns immediately.  When
negotiation is done (successful or not), the given ``Event`` will
be triggered.  On failure, `is_active` will return ``False``.

(Since 1.4) If ``event`` is ``None``, this method will not return until
negotiation is done.  On success, the method returns normally.
Otherwise an SSHException is raised.

After a successful negotiation, the client will need to authenticate.
Override the methods `get_allowed_auths
<.ServerInterface.get_allowed_auths>`, `check_auth_none
<.ServerInterface.check_auth_none>`, `check_auth_password
<.ServerInterface.check_auth_password>`, and `check_auth_publickey
<.ServerInterface.check_auth_publickey>` in the given ``server`` object
to control the authentication process.

After a successful authentication, the client should request to open a
channel.  Override `check_channel_request
<.ServerInterface.check_channel_request>` in the given ``server``
object to allow channels to be opened.

.. note::
    After calling this method (or `start_client` or `connect`), you
    should no longer directly read from or write to the original socket
    object.

:param .threading.Event event:
    an event to trigger when negotiation is complete.
:param .ServerInterface server:
    an object used to perform authentication and create `channels
    <.Channel>`

:raises:
    `.SSHException` -- if negotiation fails (and no ``event`` was
    passed in)
NTr   rg  )rZ   r  r  r   r   rh  r   r   rj  rk  ra   rl  )r  rm  serverr!  s       rk   start_serverTransport.start_server  s    T >$&F#$)!JJL )2(99

JJsO;;&&(=G"#899||~~ rm   c                     XR                   UR                  5       '   [        U[        5      (       a  XR                   S'   XR                   S'   gg)a  
Add a host key to the list of keys used for server mode.  When behaving
as a server, the host key is used to sign certain packets during the
SSH2 negotiation, so that the client can trust that we are who we say
we are.  Because this is used for signing, the key must contain private
key info, not just the public half.  Only one key of each type (RSA or
DSS) is kept.

:param .PKey key:
    the host key to add, usually an `.RSAKey` or `.DSSKey`.
r   r~   N)r  get_namer   rX   )r  keys     rk   add_server_keyTransport.add_server_keyN  sH     03S\\^, c6""36  036  0 #rm   c                 V     U R                   U R                     $ ! [         a     gf = f)a  
Return the active host key, in server mode.  After negotiating with the
client, this method will return the negotiated host key.  If only one
type of host key was set with `add_server_key`, that's the only key
that will ever be returned.  But in cases where you have set more than
one type of host key (for example, an RSA key and a DSS key), the key
type will be negotiated by the client, and this method will return the
key of the type agreed on.  If the host key has not been negotiated
yet, ``None`` is returned.  In client mode, the behavior is undefined.

:return:
    host key (`.PKey`) of the type negotiated by the client, or
    ``None``.
N)r  r   KeyErrorr2  s    rk   get_server_keyTransport.get_server_keyb  s3    	''(:(:;; 		s    
((c                     [        5       [        l        SS/nU b  UR                  SU 5        U H#  n [        R                  R	                  U5          g   S[        l        g! [
         a     M@  f = f)a  
(optional)
Load a file of prime moduli for use in doing group-exchange key
negotiation in server mode.  It's a rather obscure option and can be
safely ignored.

In server mode, the remote client may request "group-exchange" key
negotiation, which asks the server to send a random prime number that
fits certain criteria.  These primes are pretty difficult to compute,
so they can't be generated on demand.  But many systems contain a file
of suitable primes (usually named something like ``/etc/ssh/moduli``).
If you call `load_server_moduli` and it returns ``True``, then this
file of primes has been loaded and we will support "group-exchange" in
server mode.  Otherwise server mode will just claim that it doesn't
support that method of key negotiation.

:param str filename:
    optional path to the moduli file, if you happen to know that it's
    not in a standard location.
:return:
    True if a moduli file was successfully loaded; False otherwise.

.. note:: This has no effect when used in client mode.
z/etc/ssh/moduliz/usr/local/etc/moduliNr   TF)rW   ro   _modulus_packinsert	read_fileIOError)filename	file_listfns      rk   load_server_moduliTransport.load_server_moduliw  sv    4 #.-	&(?@	Q)B''11"5  #'		  s   A""
A0/A0c                     U R                   (       d  gU R                  5         [        U R                  R	                  5       5       H  nUR                  5         M     U R                  R                  5         g)z@
Close this session, and any open channels that are tied to it.
N)r   ri   listr   values_unlinkr   rY  )r  chans     rk   rY  Transport.close  sM     {{..01DLLN 2		rm   c                 t    U R                   (       a  U R                  (       d  [        S5      eU R                  $ )at  
Return the host key of the server (in client mode).

.. note::
    Previously this call returned a tuple of ``(key type, key
    string)``. You can get the same effect by calling `.PKey.get_name`
    for the key type, and ``str(key)`` for the key string.

:raises: `.SSHException` -- if no session is currently active.

:return: public key (`.PKey`) of the remote server
No existing session)r   r   ra   r   r2  s    rk   get_remote_server_keyTransport.get_remote_server_key  s)     T%:%:455}}rm   c                     U R                   $ )z
Return true if this session is active (open).

:return:
    True if the session is still active (open); False if the session is
    closed
)r   r2  s    rk   	is_activeTransport.is_active  s     {{rm   c                 &    U R                  SUUUS9$ )a  
Request a new channel to the server, of type ``"session"``.  This is
just an alias for calling `open_channel` with an argument of
``"session"``.

.. note:: Modifying the the window and packet sizes might have adverse
    effects on the session created. The default values are the same
    as in the OpenSSH code base and have been battle tested.

:param int window_size:
    optional window size for this session.
:param int max_packet_size:
    optional max packet size for this session.

:return: a new `.Channel`

:raises:
    `.SSHException` -- if the request is rejected or the session ends
    prematurely

.. versionchanged:: 1.13.4/1.14.3/1.15.3
    Added the ``timeout`` argument.
.. versionchanged:: 1.15
    Added the ``window_size`` and ``max_packet_size`` arguments.
session)window_sizemax_packet_sizern  open_channel)r  r  r  rn  s       rk   open_sessionTransport.open_session  s(    8   #+	 ! 
 	
rm   c                 "    U R                  SUS9$ )aq  
Request a new channel to the client, of type ``"x11"``.  This
is just an alias for ``open_channel('x11', src_addr=src_addr)``.

:param tuple src_addr:
    the source address (``(str, int)``) of the x11 server (port is the
    x11 port, ie. 6010)
:return: a new `.Channel`

:raises:
    `.SSHException` -- if the request is rejected or the session ends
    prematurely
x11)src_addrr  )r  r  s     rk   open_x11_channelTransport.open_x11_channel  s        ::rm   c                 $    U R                  S5      $ )a
  
Request a new channel to the client, of type
``"auth-agent@openssh.com"``.

This is just an alias for ``open_channel('auth-agent@openssh.com')``.

:return: a new `.Channel`

:raises: `.SSHException` --
    if the request is rejected or the session ends prematurely
auth-agent@openssh.comr  r2  s    rk   open_forward_agent_channel$Transport.open_forward_agent_channel  s       !9::rm   c                 &    U R                  SX!5      $ )a  
Request a new channel back to the client, of type ``forwarded-tcpip``.

This is used after a client has requested port forwarding, for sending
incoming connections back to the client.

:param src_addr: originator's address
:param dest_addr: local (server) connected address
forwarded-tcpipr  )r  r  	dest_addrs      rk   open_forwarded_tcpip_channel&Transport.open_forwarded_tcpip_channel  s       !2IHHrm   c                    U R                   (       d  [        S5      eUc  U R                  OUnU R                  R	                  5          U R                  U5      nU R                  U5      nU R                  5       n[        5       nUR                  [        5        UR                  U5        UR                  U5        UR                  U5        UR                  U5        US:X  d  US:X  aQ  UR                  US   5        UR                  US   5        UR                  US   5        UR                  US   5        O.US:X  a(  UR                  US   5        UR                  US   5        [        U5      n	U R                  R                  Xy5        [         R"                  " 5       =U R$                  U'   n
SU R&                  U'   U	R)                  U 5        U	R+                  XE5        U R                  R-                  5         U R/                  U5        [0        R0                  " 5       n U
R3                  S5        U R                   (       d   U R5                  5       nUc  [        S	5      nUeU
R7                  5       (       a  O(X-   [0        R0                  " 5       :  a  [        S
5      eM  U R                  R9                  U5      n	U	b  U	$ U R5                  5       nUc  [        S	5      nUe! U R                  R-                  5         f = f)a  
Request a new channel to the server. `Channels <.Channel>` are
socket-like objects used for the actual transfer of data across the
session. You may only request a channel after negotiating encryption
(using `connect` or `start_client`) and authenticating.

.. note:: Modifying the the window and packet sizes might have adverse
    effects on the channel created. The default values are the same
    as in the OpenSSH code base and have been battle tested.

:param str kind:
    the kind of channel requested (usually ``"session"``,
    ``"forwarded-tcpip"``, ``"direct-tcpip"``, or ``"x11"``)
:param tuple dest_addr:
    the destination address (address + port tuple) of this port
    forwarding, if ``kind`` is ``"forwarded-tcpip"`` or
    ``"direct-tcpip"`` (ignored for other channel types)
:param src_addr: the source address of this port forwarding, if
    ``kind`` is ``"forwarded-tcpip"``, ``"direct-tcpip"``, or ``"x11"``
:param int window_size:
    optional window size for this session.
:param int max_packet_size:
    optional max packet size for this session.
:param float timeout:
    optional timeout opening a channel, default 3600s (1h)

:return: a new `.Channel` on success

:raises:
    `.SSHException` -- if the request is rejected, the session ends
    prematurely or there is a timeout opening a channel

.. versionchanged:: 1.15
    Added the ``window_size`` and ``max_packet_size`` arguments.
SSH session not activer  direct-tcpipr   r   r  Tr   zUnable to open channel.zTimeout opening channel.)r   ra   r   r   acquire_sanitize_window_size_sanitize_packet_size_next_channelrT   add_byter   
add_stringadd_intr   r   putr   r   r   r   _set_transport_set_windowrelease_send_user_messageri  rj  rk  rl  r%  )r  kindr  r  r  r  rn  chanidmr  rm  start_tsr!  s                rk   r  Transport.open_channel  ss   X {{788*1/$&&w			 44[AK"88IO'')F	AJJ()LLIIfIIk"IIo&))t~/EYq\*		)A,'Xa[)		(1+&Xa[)		(1+&6?DNNv,2;//2CCD'%)-Dv&%[:II"99;JJsO;;&&(9$%>?A||~~#diik1"#=>>  ~~!!&)K 967A) IIs   	FK% %Lc                    ^  T R                   (       d  [        S5      e[        U5      nT R                  SX4SS9nUc  [        S5      eUS:X  a  UR	                  5       nUc  U 4S jnUnUT l        U$ )a  
Ask the server to forward TCP connections from a listening port on
the server, across this SSH session.

If a handler is given, that handler is called from a different thread
whenever a forwarded connection arrives.  The handler parameters are::

    handler(
        channel,
        (origin_addr, origin_port),
        (server_addr, server_port),
    )

where ``server_addr`` and ``server_port`` are the address and port that
the server was listening on.

If no handler is set, the default behavior is to send new incoming
forwarded connections into the accept queue, to be picked up via
`accept`.

:param str address: the address to bind when forwarding
:param int port:
    the port to forward, or 0 to ask the server to allocate any port
:param callable handler:
    optional handler for incoming forwarded connections, of the form
    ``func(Channel, (str, int), (str, int))``.

:return: the port number (`int`) allocated by the server

:raises:
    `.SSHException` -- if the server refused the TCP forward request
r  tcpip-forwardTrj  zTCP forwarding request deniedr   c                 (   > TR                  U 5        g rg   _queue_incoming_channel)channelr  dest_addr_portr  s      rk   default_handler7Transport.request_port_forward.<locals>.default_handler  s     ,,W5rm   )r   ra   r   global_requestget_intr   )r  addressr  handlerresponser  s   `     rk   request_port_forwardTransport.request_port_forwardr  s    B {{7884y&&g_4 ' 
 >??19##%D?6
 &G#rm   c                 Z    U R                   (       d  gSU l        U R                  SX4SS9  g)z
Ask the server to cancel a previous port-forwarding request.  No more
connections to the given address & port will be forwarded across this
ssh connection.

:param str address: the address to stop forwarding
:param int port: the port to stop forwarding
Ncancel-tcpip-forwardTr  )r   r   r  )r  r  r  s      rk   cancel_port_forwardTransport.cancel_port_forward  s.     {{ 2WO$Orm   c                 .    [         R                  " U 5      $ )a  
Create an SFTP client channel from an open transport.  On success, an
SFTP session will be opened with the remote host, and a new
`.SFTPClient` object will be returned.

:return:
    a new `.SFTPClient` referring to an sftp session (channel) across
    this transport
)r[   from_transportr2  s    rk   open_sftp_clientTransport.open_sftp_client  s     ((..rm   c                     [        5       nUR                  [        5        Uc%  [        [        R
                  " S5      5      S-  S-   nUR                  [        R
                  " U5      5        U R                  U5        g)aq  
Send a junk packet across the encrypted link.  This is sometimes used
to add "noise" to a connection to confuse would-be attackers.  It can
also be used as a keep-alive for long lived connections traversing
firewalls.

:param int byte_count:
    the number of random bytes to send in the payload of the ignored
    packet -- defaults to a random number from 10 to 41.
Nr   r   
   )rT   r  r   rB   osurandom	add_bytesr  )r  
byte_countr  s      rk   send_ignoreTransport.send_ignore  s\     I	

;"2::a=1B6"<J	BJJz*+"rm   c                 6   [         R                  " 5       U l        U R                  5          U R                  R	                  S5        U R
                  (       d   U R                  5       nUb  Ue[        S5      eU R                  R                  5       (       a   gMo  )a  
Force this session to switch to new keys.  Normally this is done
automatically after the session hits a certain number of packets or
bytes sent or received, but this method gives you the option of forcing
new keys whenever you want.  Negotiating new keys causes a pause in
traffic both ways as the two sides swap keys and do computations.  This
method returns when the session has switched to new keys.

:raises:
    `.SSHException` -- if the key renegotiation failed (which causes
    the session to end)
r   Nrg  )	r   r   r   _send_kex_initrj  r   rk  ra   rl  r  r!  s     rk   renegotiate_keysTransport.renegotiate_keys  s     !* 1!!&&s+;;&&(=G"#899$$++-- rm   c                 n    [         R                  " U 5      4S jnU R                  R                  X5        g)a  
Turn on/off keepalive packets (default is off).  If this is set, after
``interval`` seconds without sending any data over the connection, a
"keepalive" packet will be sent (and ignored by the remote host).  This
can be useful to keep connections alive over a NAT, for example.

:param int interval:
    seconds to wait before sending a keepalive packet (or
    0 to disable keepalives).
c                 "    U R                  SSS9$ )Nzkeepalive@lag.netFr  )r  )r'  s    rk   _request)Transport.set_keepalive.<locals>._request  s    ##$7e#DDrm   N)weakrefproxyr   set_keepalive)r  intervalr  s      rk   r  Transport.set_keepalive  s*     }}T* 	E 	%%h9rm   c                    U(       a  [         R                  " 5       U l        [        5       nUR	                  [
        5        UR                  U5        UR                  U5        Ub  UR                  " U6   U R                  [        SR                  U5      5        U R                  U5        U(       d  g U R                  R                  S5        U R                  (       d  gU R                  R                  5       (       a   U R                   $ M[  )a  
Make a global request to the remote host.  These are normally
extensions to the SSH2 protocol.

:param str kind: name of the request.
:param tuple data:
    an optional tuple containing additional data to attach to the
    request.
:param bool wait:
    ``True`` if this method should not return until a response is
    received; ``False`` otherwise.
:return:
    a `.Message` containing possible additional data if the request was
    successful (or an empty `.Message` if ``wait`` was ``False``);
    ``None`` if the request was denied.
NzSending global request "{}"r   )r   r   r   rT   r  r   r  add_booleanadd_logr   r   r  rj  r   rl  r   )r  r  datarj  r  s        rk   r  Transport.global_request  s    " $-OO$5D!I	

&'	T	dEE4L		%6==dCD"!!&&s+;;$$++--### rm   c                    U R                   R                  5          [        U R                  5      S:  a  U R                  R	                  S5      nORU R
                  R                  U5        [        U R                  5      S:  a  U R                  R	                  S5      nOSnU R                   R                  5         U$ ! U R                   R                  5         f = f)a  
Return the next channel opened by the client over this transport, in
server mode.  If no channel is opened before the given timeout,
``None`` is returned.

:param int timeout:
    seconds to wait for a channel, or ``None`` to wait forever
:return: a new `.Channel` opened by the client
r   N)r   r  r   r  popr  rj  r  )r  rn  r  s      rk   acceptTransport.accept$  s     				 4&&'!+**..q1%%**73t**+a/..2215D  DII IIs   BB? ?Cc
           
         Ub5  [        U[        5      (       a
  / SQU l        OUR                  5       /U l        U R	                  UU	U=(       d    US9  U R                  5         UGbF  U(       Gd>  U R                  5       n
U
R                  5       UR                  5       :w  d"  U
R                  5       UR                  5       :w  a  U R                  [        S5        U R                  [        SR                  UR                  5       [        UR                  5       5      5      5        U R                  [        SR                  U
R                  5       [        U
R                  5       5      5      5        [        S5      eU R                  [        SR                  UR                  5       5      5        Uc  Uc  U(       d  U(       a  U(       a3  U R                  [        S5        U R                  X R                  U5        gU(       a(  U R                  [        S	5        U R                  U5        gUb(  U R                  [        S
5        U R!                  X$5        gU R                  [        S5        U R#                  X#5        g)a  
Negotiate an SSH2 session, and optionally verify the server's host key
and authenticate using a password or private key.  This is a shortcut
for `start_client`, `get_remote_server_key`, and
`Transport.auth_password` or `Transport.auth_publickey`.  Use those
methods if you want more control.

You can use this method immediately after creating a Transport to
negotiate encryption with a server.  If it fails, an exception will be
thrown.  On success, the method will return cleanly, and an encrypted
session exists.  You may immediately call `open_channel` or
`open_session` to get a `.Channel` object, which is used for data
transfer.

.. note::
    If you fail to supply a password or private key, this method may
    succeed, but a subsequent `open_channel` or `open_session` call may
    fail because you haven't authenticated yet.

:param .PKey hostkey:
    the host key expected from the server, or ``None`` if you don't
    want to do host key verification.
:param str username: the username to authenticate as.
:param str password:
    a password to use for authentication, if you want to use password
    authentication; otherwise ``None``.
:param .PKey pkey:
    a private key to use for authentication, if you want to use private
    key authentication; otherwise ``None``.
:param str gss_host:
    The target's name in the kerberos database. Default: hostname
:param bool gss_auth:
    ``True`` if you want to use GSS-API authentication.
:param bool gss_kex:
    Perform GSS-API Key Exchange and user authentication.
:param bool gss_deleg_creds:
    Whether to delegate GSS-API client credentials.
:param gss_trust_dns:
    Indicates whether or not the DNS is trusted to securely
    canonicalize the name of the host being connected to (default
    ``True``).

:raises: `.SSHException` -- if the SSH2 negotiation fails, the host key
    supplied by the server is incorrect, or authentication fails.

.. versionchanged:: 2.3
    Added the ``gss_trust_dns`` argument.
N)r~   r   r   )r   rb  rc  zBad host key from serverzExpected: {}: {}zGot     : {}: {}zHost key verified ({})z,Attempting GSS-API auth... (gssapi-with-mic)z)Attempting GSS-API auth... (gssapi-keyex)zAttempting public-key auth...zAttempting password auth...)r   rX   _preferred_keysrw  rd  rp  r  asbytesr  r   r   reprra   auth_gssapi_with_micr   auth_gssapi_keyexauth_publickeyauth_password)r  hostkeyusernamepasswordpkeyr   gss_authr  r  gss_trust_dnsrx  s              rk   r   Transport.connect=  s   x  '6**($ )0(8(8(:';$#$0 	 	
 	
 ,,.C'"2"2"44;;=GOO$55		%!;<		&--((*D1B,C 		&--S[[](; ##=>>II/66w7G7G7IJ ("68w		I ))mm_ 	 		%!LM&&x0 	 !		%!@A##H3
 	 		%!>?""86rm   c                     U R                   R                  5          U R                  nSU l        UU R                   R                  5         $ ! U R                   R                  5         f = f)a9  
Return any exception that happened during the last server request.
This can be used to fetch more specific error information after using
calls like `start_client`.  The exception (if any) is cleared after
this call.

:return:
    an exception, or ``None`` if there is no stored exception.

.. versionadded:: 1.1
N)r   r  r   r  r  s     rk   rk  Transport.get_exception  sP     				 $$A#'D IIDII   A A'c                      U R                   R                  5         X#U4U R                  U'   U R                   R                  5         g! U R                   R                  5         f = f)a  
Set the handler class for a subsystem in server mode.  If a request
for this subsystem is made on an open ssh channel later, this handler
will be constructed and called -- see `.SubsystemHandler` for more
detailed documentation.

Any extra parameters (including keyword arguments) are saved and
passed to the `.SubsystemHandler` constructor later.

:param str name: name of the subsystem.
:param handler:
    subclass of `.SubsystemHandler` that handles this subsystem.
Nr   r  r  r  )r  namer  argskwargss        rk   set_subsystem_handlerTransport.set_subsystem_handler  sM    	 II*1)@D  &IIDIIs   +A A$c                     U R                   =(       a/    U R                  SL=(       a    U R                  R                  5       $ )z
Return true if this session is active and authenticated.

:return:
    True if the session is still open and has been authenticated
    successfully; False if authentication failed and/or the session is
    closed.
N)r   r   rS  r2  s    rk   rS  Transport.is_authenticated  s:     KK 5!!-5!!224	
rm   c                 t    U R                   (       a  U R                  c  gU R                  R                  5       $ )z
Return the username this connection is authenticated for.  If the
session is not authenticated (or authentication failed), this method
returns ``None``.

:return: username that was authenticated (a `str`), or ``None``.
N)r   r   get_usernamer2  s    rk   r  Transport.get_username  s.     {{t008  --//rm   c                 l    U R                   (       a  U R                  c  gU R                  R                  $ )z
Return the banner supplied by the server upon connect. If no banner is
supplied, this method returns ``None``.

:returns: server supplied banner (`str`), or ``None``.

.. versionadded:: 1.13
N)r   r   bannerr2  s    rk   
get_bannerTransport.get_banner   s+     {{t008  '''rm   c                    U R                   (       a  U R                  (       d  [        S5      e[        R                  " 5       n[        U 5      U l        U R                  R                  X5        U R                  R                  U5      $ )at  
Try to authenticate to the server using no authentication at all.
This will almost always fail.  It may be useful for determining the
list of authentication types supported by the server, by catching the
`.BadAuthenticationType` exception raised.

:param str username: the username to authenticate as
:return:
    list of auth types permissible for the next stage of
    authentication (normally empty)

:raises:
    `.BadAuthenticationType` -- if "none" authentication isn't allowed
    by the server for this user
:raises:
    `.SSHException` -- if the authentication failed due to a network
    error

.. versionadded:: 1.5
r  )	r   r   ra   r   r   r   r   	auth_nonewait_for_responser  r  my_events      rk   r  Transport.auth_none  sc    * T%:%:455??$'-##H7  228<<rm   c                   ^ U R                   (       a  U R                  (       d  [        S5      eUc  [        R                  " 5       nOUn[        U 5      U l        U R                  R                  UTU5        Ub  / $  U R                  R                  U5      $ ! [         aJ  nU(       a  SUR                  ;  a  e  U4S jnU R                  X5      s SnA$ ! [         a    Uef = fSnAff = f)aX  
Authenticate to the server using a password.  The username and password
are sent over an encrypted link.

If an ``event`` is passed in, this method will return immediately, and
the event will be triggered once authentication succeeds or fails.  On
success, `is_authenticated` will return ``True``.  On failure, you may
use `get_exception` to get more detailed error information.

Since 1.1, if no event is passed, this method will block until the
authentication succeeds or fails.  On failure, an exception is raised.
Otherwise, the method simply returns.

Since 1.5, if no event is passed and ``fallback`` is ``True`` (the
default), if the server doesn't support plain password authentication
but does support so-called "keyboard-interactive" mode, an attempt
will be made to authenticate using this interactive mode.  If it fails,
the normal exception will be thrown as if the attempt had never been
made.  This is useful for some recent Gentoo and Debian distributions,
which turn off plain password authentication in a misguided belief
that interactive authentication is "more secure".  (It's not.)

If the server requires multi-step authentication (which is very rare),
this method will return a list of auth types permissible for the next
step.  Otherwise, in the normal case, an empty list is returned.

:param str username: the username to authenticate as
:param basestring password: the password to authenticate with
:param .threading.Event event:
    an event to trigger when the authentication attempt is complete
    (whether it was successful or not)
:param bool fallback:
    ``True`` if an attempt at an automated "interactive" password auth
    should be made if the server doesn't support normal password auth
:return:
    list of auth types permissible for the next stage of
    authentication (normally empty)

:raises:
    `.BadAuthenticationType` -- if password authentication isn't
    allowed by the server for this user (and no event was passed in)
:raises:
    `.AuthenticationException` -- if the authentication failed (and no
    event was passed in)
:raises: `.SSHException` -- if there was a network error
r  Nkeyboard-interactivec                 `   > [        U5      S:  a  [        S5      e[        U5      S:X  a  / $ T/$ Nr   zFallback authentication failed.r   r   ra   titleinstructionsfieldsr  s      rk   r  (Transport.auth_password.<locals>.handlern  5    6{Q*+LMM6{a'
  "	$:%rm   )r   r   ra   r   r   r   r   r   r  r\   allowed_typesauth_interactive)r  r  r  rm  fallbackr  r!  r  s     `     rk   r   Transport.auth_password)  s    ^ T%:%: 455= (HH'-''(HEI	$$66x@@$ 	  6aoo M	& ,,X?? '	s0   =B 
C,"C';CC,C$$C''C,c                 *   U R                   (       a  U R                  (       d  [        S5      eUc  [        R                  " 5       nOUn[        U 5      U l        U R                  R                  XU5        Ub  / $ U R                  R                  U5      $ )a  
Authenticate to the server using a private key.  The key is used to
sign data from the server, so it must include the private part.

If an ``event`` is passed in, this method will return immediately, and
the event will be triggered once authentication succeeds or fails.  On
success, `is_authenticated` will return ``True``.  On failure, you may
use `get_exception` to get more detailed error information.

Since 1.1, if no event is passed, this method will block until the
authentication succeeds or fails.  On failure, an exception is raised.
Otherwise, the method simply returns.

If the server requires multi-step authentication (which is very rare),
this method will return a list of auth types permissible for the next
step.  Otherwise, in the normal case, an empty list is returned.

:param str username: the username to authenticate as
:param .PKey key: the private key to authenticate with
:param .threading.Event event:
    an event to trigger when the authentication attempt is complete
    (whether it was successful or not)
:return:
    list of auth types permissible for the next stage of
    authentication (normally empty)

:raises:
    `.BadAuthenticationType` -- if public-key authentication isn't
    allowed by the server for this user (and no event was passed in)
:raises:
    `.AuthenticationException` -- if the authentication failed (and no
    event was passed in)
:raises: `.SSHException` -- if there was a network error
r  )	r   r   ra   r   r   r   r   r  r  )r  r  rx  rm  r  s        rk   r  Transport.auth_publickey~  s{    F T%:%:455= (HH'-((AI  228<<rm   c                    U R                   (       a  U R                  (       d  [        S5      e[        R                  " 5       n[        U 5      U l        U R                  R                  XXC5        U R                  R                  U5      $ )a  
Authenticate to the server interactively.  A handler is used to answer
arbitrary questions from the server.  On many servers, this is just a
dumb wrapper around PAM.

This method will block until the authentication succeeds or fails,
periodically calling the handler asynchronously to get answers to
authentication questions.  The handler may be called more than once
if the server continues to ask questions.

The handler is expected to be a callable that will handle calls of the
form: ``handler(title, instructions, prompt_list)``.  The ``title`` is
meant to be a dialog-window title, and the ``instructions`` are user
instructions (both are strings).  ``prompt_list`` will be a list of
prompts, each prompt being a tuple of ``(str, bool)``.  The string is
the prompt and the boolean indicates whether the user text should be
echoed.

A sample call would thus be:
``handler('title', 'instructions', [('Password:', False)])``.

The handler should return a list or tuple of answers to the server's
questions.

If the server requires multi-step authentication (which is very rare),
this method will return a list of auth types permissible for the next
step.  Otherwise, in the normal case, an empty list is returned.

:param str username: the username to authenticate as
:param callable handler: a handler for responding to server questions
:param str submethods: a string list of desired submethods (optional)
:return:
    list of auth types permissible for the next stage of
    authentication (normally empty).

:raises: `.BadAuthenticationType` -- if public-key authentication isn't
    allowed by the server for this user
:raises: `.AuthenticationException` -- if the authentication failed
:raises: `.SSHException` -- if there was a network error

.. versionadded:: 1.5
r  )	r   r   ra   r   r   r   r   r-  r  )r  r  r  
submethodsr  s        rk   r-  Transport.auth_interactive  sk    V T%:%:455??$'-**x	
   228<<rm   c                 :    U(       d  S nU R                  XU5      $ )z
Authenticate to the server interactively but dumber.
Just print the prompt and / or instructions to stdout and send back
the response. This is good for situations where partial auth is
achieved by key and then the user has to enter a 2fac token.
c                    / nU (       a  [        U R                  5       5        U(       a  [        UR                  5       5        U H6  u  pE[        UR                  5       SS9  UR                  [        5       5        M8     U$ N )endprintstripappendinputr'  r(  prompt_listanswersprompt
show_inputs         rk   r  0Transport.auth_interactive_dumb.<locals>.handler  ^    %++-(,,,./*5&F&,,.c2NN57+ +6 rm   )r-  r  r  r  r3  s       rk   auth_interactive_dumbTransport.auth_interactive_dumb  s!     	 $$X
CCrm   c                    U R                   (       a  U R                  (       d  [        S5      e[        R                  " 5       n[        U 5      U l        U R                  R                  XX45        U R                  R                  U5      $ )aD  
Authenticate to the Server using GSS-API / SSPI.

:param str username: The username to authenticate as
:param str gss_host: The target host
:param bool gss_deleg_creds: Delegate credentials or not
:return: list of auth types permissible for the next stage of
         authentication (normally empty)
:raises: `.BadAuthenticationType` -- if gssapi-with-mic isn't
    allowed by the server (and no event was passed in)
:raises:
    `.AuthenticationException` -- if the authentication failed (and no
    event was passed in)
:raises: `.SSHException` -- if there was a network error
r  )	r   r   ra   r   r   r   r   r  r  )r  r  r   r  r  s        rk   r  Transport.auth_gssapi_with_mic  sj      T%:%:455??$'-..	
   228<<rm   c                    U R                   (       a  U R                  (       d  [        S5      e[        R                  " 5       n[        U 5      U l        U R                  R                  X5        U R                  R                  U5      $ )a  
Authenticate to the server with GSS-API/SSPI if GSS-API kex is in use.

:param str username: The username to authenticate as.
:returns:
    a list of auth types permissible for the next stage of
    authentication (normally empty)
:raises: `.BadAuthenticationType` --
    if GSS-API Key Exchange was not performed (and no event was passed
    in)
:raises: `.AuthenticationException` --
    if the authentication failed (and no event was passed in)
:raises: `.SSHException` -- if there was a network error
r  )	r   r   ra   r   r   r   r   r  r  r  s      rk   r  Transport.auth_gssapi_keyex  sc     T%:%:455??$'-++H?  228<<rm   c                     Xl         [        R                  " U5      U l        U R                  R                  U R                  5        g)a/  
Set the channel for this transport's logging.  The default is
``"paramiko.transport"`` but it can be set to anything you want. (See
the `.logging` module for more info.)  SSH Channels will log to a
sub-channel of the one specified.

:param str name: new channel name for logging

.. versionadded:: 1.1
N)r   r   r   r   r   r   r  r  s     rk   set_log_channelTransport.set_log_channel,  s/     ood+,rm   c                     U R                   $ )zu
Return the channel name used for this transport's logging.

:return: channel name as a `str`

.. versionadded:: 1.2
)r   r2  s    rk   get_log_channelTransport.get_log_channel;  s     }}rm   c                 :    U R                   R                  U5        g)a)  
Turn on/off logging a hex dump of protocol traffic at DEBUG level in
the logs.  Normally you would want this off (which is the default),
but if you are debugging something, it may be useful.

:param bool hexdump:
    ``True`` to log protocol traffix (in hex) to the log; ``False``
    otherwise.
N)r   set_hexdump)r  hexdumps     rk   rU  Transport.set_hexdumpE  s     	##G,rm   c                 6    U R                   R                  5       $ )z
Return ``True`` if the transport is currently logging hex dumps of
protocol traffic.

:return: ``True`` if hex dumps are being logged, else ``False``.

.. versionadded:: 1.4
)r   get_hexdumpr2  s    rk   rY  Transport.get_hexdumpQ  s     **,,rm   c                 0    U(       a  SU l         gSU l         g)ac  
Turn on/off compression.  This will only have an affect before starting
the transport (ie before calling `connect`, etc).  By default,
compression is off since it negatively affects interactive sessions.

:param bool compress:
    ``True`` to ask the remote client/server to compress traffic;
    ``False`` to refuse compression

.. versionadded:: 1.5.2
r   r   N)_preferred_compression)r  compresss     rk   use_compressionTransport.use_compression\  s     *ND'*3D'rm   c                 F    [        U R                  SS5      nUc  gU" 5       $ )aM  
Return the address of the remote side of this Transport, if possible.

This is effectively a wrapper around ``getpeername`` on the underlying
socket.  If the socket-like object has no ``getpeername`` method, then
``("unknown", 0)`` is returned.

:return:
    the address of the remote host, if known, as a ``(str, int)``
    tuple.
getpeernameN)unknownr   )r+  r   )r  gps     rk   ra  Transport.getpeernamem  s%     TYYt4:trm   c                    SU l         U R                  R                  5         U R                  5       (       a  U [        R
                  " 5       La  U R                  R                  (       d  U R                  R                  (       dz  U R                  S5        U R                  5       (       aS  U [        R
                  " 5       La:  U R                  R                  (       d  U R                  R                  (       d  Mv  g g g g g g g g )NFr   )
r   r   rY  is_aliver   current_threadr   _closedclosedjoinr2  s    rk   ri   Transport.stop_thread~  s     MMOOI4466II%%OO**IIcN MMOOI4466II%%OO*** & 7  + & 7 rm   c                     [        [        U5      [        5      (       a%  U H  nU R                  R	                  X5        M      g U R                  R                  " X/UQ76   g rg   )
issubclassr   r  r   log)r  levelmsgr  r  s        rk   r  Transport._log  sD    d3i&&)  KKOOE..rm   c                     U R                   $ )z0used by KexGex to find primes for group exchange)r  r2  s    rk   _get_modulus_packTransport._get_modulus_pack  s    !!!rm   c                    U R                   nU R                  R                  U5      bA  U R                   S-   S-  U l         U R                   nU R                  R                  U5      b  MA  U R                   S-   S-  U l         U$ )zyou are holding the lockr   i )r   r   r%  r  r  s     rk   r  Transport._next_channel  s{    &&nn  (4%)%:%:Q%>($JD!**F nn  (4 "&!6!6!:h Frm   c                 :    U R                   R                  U5        g)z?used by a Channel to remove itself from the active channel listN)r   deleterv  s     rk   _unlink_channelTransport._unlink_channel  s    f%rm   c                 :    U R                   R                  U5        g rg   )r   send_message)r  r  s     rk   _send_messageTransport._send_message  s    $$T*rm   c                 X   [         R                   " 5       n U R                  R                  S5        U R                  (       d  U R	                  [
        S5        gU R                  R                  5         U R                  R                  5       (       a  OLU R                  R                  5         [         R                   " 5       X R                  -   :  a  [        S5      eM   U R                  U5        U R                  R                  5         g! U R                  R                  5         f = f)zc
send a message, but block if we're in key negotiation.  this is used
for user-initiated requests.
r   z0Dropping user packet because connection is dead.Nz2Key-exchange timed out waiting for key negotiation)ri  r   rj  r   r  r   r   r  rl  r  r   ra   r~  )r  r  rh  s      rk   r  Transport._send_user_message  s    
 		##C(;;		M ##++-!!((**##++-yy{U%?%???"H  	.t$##++-D##++-s   !D D)c                 D    Xl         X l        U R                  c  X l        gg)zB
Used by a kex obj to set the K (root key) and H (exchange hash).
N)r   r   r   )r  khs      rk   _set_K_HTransport._set_K_H  s"     ??"O #rm   c                 $    [        U5      U l        g)zG
Used by a kex obj to register the next packet type it expects to see.
N)r   r   )r  ptypess     rk   _expect_packetTransport._expect_packet  s     !&frm   c                    U R                   U R                     " [        U5      5      nUc  [        S5      eUR	                  U R
                  [        U5      5      (       d$  [        SR                  U R                  5      5      eX0l        g )NzUnknown host key typez#Signature verification ({}) failed.)	_key_infor   rT   ra   verify_ssh_sigr   r   r   )r  r   sigrx  s       rk   _verify_keyTransport._verify_key  sw    nnT//01BC;677!!$&&'#,775<<&& 
 rm   c                    [        5       nUR                  U R                  5        UR                  U R                  5        UR                  [        U5      5        UR                  U R                  5        [        U R                  SS5      nSR                  U R                  R                  R                  U5      nUc  [        nUS-  n[        U S5      (       d#  U R                  [         U5        [#        U SS5        U" UR%                  5       5      R'                  5       =pg[)        U5      U:  a  [        5       nUR                  U R                  5        UR                  U R                  5        UR                  U5        U" UR%                  5       5      R'                  5       nXh-  nXx-  n[)        U5      U:  a  M  USU $ )z0id is 'A' - 'F' for the various keys used by ssh	hash_algoNz&kex engine {} specified hash_algo {!r}z, falling back to sha1_logged_hash_selectionT)rT   	add_mpintr   r  r   r  rd   r   r+  r   r   	__class____name__r   hasattrr  r   setattrr  digestr   )	r  rQ  nbytesr  r  hash_select_msgrU  sofarr  s	            rk   _compute_keyTransport._compute_key  sa   I	DFF	DFF	

1R5	DOO$ DOO[$?	BIIOO%%..	
 I77Ot566IIe_-D2D9		,3355#h	AKKKKKKqyy{+224FMCOE #h 7F|rm   c                    XR                   ;  a  [        SU-   5      eU R                   U   nUS   " U5      nU(       a  U$ [        UUS   " U5      [        5       S9nX@R                  L a  UR                  5       $ UR                  5       $ )NzUnknown cipher r   r   )	algorithmr   backend)rR  ra   r	   r   _ENCRYPT	encryptor	decryptor)	r  r  rx  iv	operationr   infor  ciphers	            rk   _get_engineTransport._get_engine  s    (((04788  &M#&	 fb!#%	
 %##%%##%%rm   c                 6   ^  Uc  U 4S jnUT l         g UT l         g )Nc                 (   > TR                  U 5        g rg   r  )r  r  s    rk   r  =Transport._set_forward_agent_handler.<locals>.default_handler      ,,W5rm   )r   r  r  r  s   `  rk   _set_forward_agent_handler$Transport._set_forward_agent_handler  s    ?6 +:D'*1D'rm   c                 6   ^  Uc  U 4S jnUT l         g UT l         g )Nc                 (   > TR                  U 5        g rg   r  )r  src_addr_portr  s     rk   r  3Transport._set_x11_handler.<locals>.default_handler$  r  rm   )r   r  s   `  rk   _set_x11_handlerTransport._set_x11_handler   s    ?6 !0D 'Drm   c                    U R                   R                  5          U R                  R                  U5        U R                  R                  5         U R                   R                  5         g ! U R                   R                  5         f = frg   )r   r  r  r=  r  notifyr  )r  r  s     rk   r  !Transport._queue_incoming_channel+  s^    			 &&w/!!((*IIDIIs   5A, ,Bc                 J    Uc  U R                   n[        [        U[        5      $ rg   )r   rc   r8   r:   )r  r  s     rk   r  Transport._sanitize_window_size3  s"    22K?KIIrm   c                 J    Uc  U R                   n[        [        U[        5      $ rg   )r   rc   r9   r:   )r  r  s     rk   r  Transport._sanitize_packet_size8  s"    ""::O?O_MMrm   c                    U R                   (       a  U[        ::  d  U R                  5       (       a  g[        5       nU[        :X  a  UR                  [        5        U$ U[        :X  a}  UR                  5       nUR                  5       nUR                  [        5        UR                  U5        UR                  [        5        UR                  S5        UR                  S5        U$ )a?  
Checks message type against current auth state.

If server mode, and auth has not succeeded, and the message is of a
post-auth type (channel open or global request) an appropriate error
response Message is crafted and returned to caller for sending.

Otherwise (client mode, authed, or pre-auth message) returns None.
Nr   en)r  r=   rS  rT   r(   r  r"   r/   get_textr  r&   r  r$   r  )r  ptypemessagereplyr  r  s         rk   _ensure_authedTransport._ensure_authed=  s       33$$&& 	&&NN/0  &&##%D__&FNN45MM&!MMABR T" rm   c                     U R                   (       a<  U R                  (       d*  [        R                  " USU 35      n[	        SU< S35      egg)z
Conditionally raise `MessageOrderError` during strict initial kex.

This method should only be called inside code that handles non-KEXINIT
messages; it does not interrogate ``ptype`` besides using it to log
more accurately.
zmsg z!In strict-kex mode, but was sent !N)r   r   r?   r%  r_   )r  r  r  s      rk   _enforce_strict_kexTransport._enforce_strict_kexc  sM     $$T-B-B==$ug7D#3D81=  .C$rm   c                    [         U l         [        R                  U 5        [        [	        U 5      [
        -  5      nU R                  (       a&  U R                  [        SR                  U5      5        O%U R                  [        SR                  U5      5          U R                  R                  [        U R                  S-   5      5        U R                  [        SR                  U R                  5      5        U R                  5         U R                  R                  U R                   5        U R#                  5         U R%                  [&        5        U R(                  (       Ga~  U R                  R+                  5       (       a!  U R,                  (       d  U R#                  5          U R                  R/                  5       u  p#U[2        :X  a  U R5                  U5        M  U[6        :X  a  U R9                  U5        GOU[:        :X  a$  U R5                  U5        U R=                  U5        M  [?        U R@                  5      S:  a  X R@                  ;  a?  [B        nU RD                  (       a  [F        nU" SR                  U R@                  U5      5      e[I        5       U l         US:  a$  US::  a  U RJ                  RM                  X#5        GMw  X RN                  ;   aB  U RQ                  X#5      nU(       a  U RS                  U5        GOU RN                  U   " U5        GOX RT                  ;   a  URW                  5       nU RX                  R[                  U5      nUb  U RT                  U   " Xs5        GOFX`R\                  ;   a'  U R                  [        S	R                  U5      5        GOU R                  [^        S
R                  U5      5        GOU R`                  bW  X R`                  RN                  ;   a>  U R`                  RN                  U   nU" U5        [?        U R@                  5      S:  a  GM  O[b        U   n	SR                  X)5      n
U R                  [d        U
5        U[f        :w  aK  [i        5       nURk                  [l        5        URo                  URp                  5        U RS                  U5        U R                  Rs                  5         U R(                  (       a  GM~  [        R                  U 5        [        U RX                  R                  5       5       H  nUR                  5         M     U R(                  (       a  SU l        U R                  R                  5         U R                  b  U R                  R                  5         U R`                  b  U R`                  R                  5         U R                  R                  5        H  nUR                  5         M      U R                  R                  5         U R                  R                  5         U R                  R                  5         U R                  R                  5         g ! [0         a     GM  f = f! [B         as  nU R                  [^        SR                  U R                  (       a  SOSU5      5        U R                  [^        [t        Rv                  " 5       5        Xl<         S nAGNS nAf[z         a'  nU R                  [        S5        Xl<         S nAGN#S nAf[|        R~                   a  n[        UR                  5      [H        L a\  UR                  (       a-  SR                  UR                  S   UR                  S   5      nO*[        U5      =(       d    [        U5      nOUR                  nU R                  [^        SU-   5        Xl<         S nAGNS nAf[         a\  nU R                  [^        S[        U5      -   5        U R                  [^        [t        Rv                  " 5       5        Xl<         S nAGNGS nAff = f! U R                  R                  5         f = f!   U R                   R                  b  e  g = f)Nz!starting thread (server mode): {}z!starting thread (client mode): {}z
zLocal version/idstring: {}r   z$Expecting packet from {!r}, got {:d}r   )   z&Ignoring message for dead channel {:d}z(Channel request for unknown channel {:d}zOops, unhandled type {} ({!r})zException ({}): {}rs  clientzEOF in transport threadz	{} ({:d})r   zSocket exception: zUnknown exception: F)Usysrh   r=  rP  rQ  r   r  r  r   r   r   	write_allrd   r   _check_bannerstart_handshaker   r  r  r   r   
need_rekeyr   read_messagerV   r   r  r   _parse_disconnectr   _parse_debugr   r   ra   r   r_   r   r   
parse_nextr  r  r~  _channel_handler_tabler  r   r%  r   r   r   r?   r   r>   rT   r  r   r  seqnocomplete_handshaker   
tb_stringsr   EOFErrorr   r   r   r  r   r  	Exceptionremover  r  r  rY  r   setabortr   r   r  r  r  r  r   modules)r  tidr  r  	exc_class	error_msgr  r  r  r  warningrp  r!  emsgrm  s                  rk   runTransport.runq  sV     	t$"T(Y&'IIe@GGLMIIe@GGLMY	)))!D,>,>,G*HI		0778J8JK ""$ //0F0FG##%##K0kkk1133DKK++-!#'??#?#?#A 
*007 .0..q1)+007))!, 4001A5 (=(==(4I#88,=	"+ F M M$($9$95!"# 
 16- "RKerk OO66u@$ 3 33$($7$7$A	$ ..y9 //6q9"="==!"#~~11&9+ 77>tG#'9'99 II % H O O$*!" !II % J Q Q$*!" "))5!%6%6%E%EE"&"3"3"B"B5"I
t4459$ :  )/"B"I"I!# 		'73 $55"))CLL);<KK0 ..s3OO668g kkk\ ""4(T^^2245 6{{#%%'((4))--/$$0%%++-!00779EIIK :(II%%'))002II%%'IIOOu . ! !^   )		(//$($4$4(A 		%!23'($$ )		%!:;'($$<< 	)<5(vv*11!&&)QVVAYG"1v0a66D		%!5!<='($$ )		%!6Q!?@		%!23'($$)( II%%'	
 xx+ ,s   DY  'Y 8Y  ;a =GY  a DY  $D a %4`3 4a 
YY  YY   
`0*A([a `0%\a `0B#_a `0A`+%a +`00a 3aa a.c                     SR                  U5      nX#:X  a  XB-  nOUSR                  X#5      -  nU R                  [        U5        g )Nz{}: zlocal={}, remote={})r   r  r   )r  whichlocalremoterp  s        rk   _log_agreementTransport._log_agreement	  sB     mmE"?LC(//>>C		%rm   c                 p   U R                   R                  5          U R                  R                  5         U R                   R	                  5         U R
                  c  U R                  5         U R                  U5        U R                  R                  5         g ! U R                   R	                  5         f = frg   )
r   r  r   clearr  r   r  _parse_kex_initr   	start_kexr  r  s     rk   r  Transport._negotiate_keys*	  s    '')	.$$&##++-&!Q!!# ##++-s   B B5c                    [        S5       HX  nUS:X  a  U R                  nOSn U R                  R                  U5      nUS S S:X  a    OU R                  [        SU-   5        MZ     WS S S:w  a  [        SU-   S	-   5      eX0l
        U R                  [        S
R                  U5      5        UR                  S5      nUS:  a  US U nUR                  SS5      n[        U5      S:  a  [        S5      eUS   nUS   nUS:w  a"  US:w  a  Sn[        UR                  U5      5      eSR                  Xg5      nU R                  [         U5        g ! [         a    e [
         a  n[        S[        U5      -   5      eS nAff = f)Nd   r      z!Error reading SSH protocol banner   r   zBanner: z!Indecipherable protocol version ""zRemote version/idstring: {}r8  r      zInvalid SSH bannerr   z1.99rq   z(Incompatible version ({} instead of 2.0)z!Connected (version {}, client {}))ranger   r   readliner`   r  ra   r   r  r   r   r   findr   r   r^   r   )	r  irn  bufr!  segsversionr  rp  s	            rk   r  Transport._check_banner7	  s   sA Av--oo..w7 2Aw& IIeZ#-.# $ r7fBSH3NOO!		%6==cBC HHSM6bq'Cyya t9q=344q'afE!1<C"3::g#677188I		$= '  "7#a&@ s   EE?#E::E?c                    U R                   R                  5          U R                  R                  5         U R                   R	                  5         SU l        SU l        [        U R                  5      nU R                  (       a  SnU Vs/ s H  o3R                  U5      (       d  M  UPM     nnU R                  ce  [        U5      S:  aV  U R                  5       R                   Vs/ s H  nUR                  U5      (       a  M  UPM     nnXPR                  5       l        [        [        [        U R                   R#                  5       5      R$                  U R&                  5      5      nOU R&                  nUR)                  S5        U R*                  (       a*  U R                  (       a  SOSnUR)                  S	U S
35        [-        5       nUR/                  [0        5        UR3                  [4        R6                  " S5      5        UR9                  U5        UR9                  U5        UR9                  U R:                  5        UR9                  U R:                  5        UR9                  U R<                  5        UR9                  U R<                  5        UR9                  U R>                  5        UR9                  U R>                  5        URA                  [C        5       5        URA                  [C        5       5        URE                  S5        URG                  S5        URI                  5       =U l%        U l&        U RO                  U5        g! U R                   R	                  5         f = fs  snf s  snf )zk
announce to the other side that we'd like to negotiate keys, and what
kind of key negotiation we support.
FTz!diffie-hellman-group-exchange-shaNr   
ext-info-csckex-strict--v00@openssh.comr   )(r   r  r   r  r  r   r   r  rG  r  
startswithr  r   r^  rF  filterr  r;  __contains__r?  r=  r   rT   r  r   r  r  r  add_listr3  r8  rK  r  bytesr  r  r  r   _latest_kex_initr~  )	r  	kex_algosmp_required_prefixr  kex_mppkexavailable_server_keysr  r  s	            rk   r  Transport._send_kex_initb	  s   
 	'')	.$$&##++-!++,	!D!*OAll;M.NaFO""*Vq
 "668<<<<<(:; <  
 37))+/$(--2245BB ''%! %)$7$7!
 \* $$++CE{5'1ABCI	

< 	BJJrN#	

9	

()	

4))*	

4))*	

4&&'	

4&&'	

4--.	

4--.	UW	UW	e			!67iikAd31{ ##++- Ps#   M 
M-'M-'M2M2M*c                    0 nU(       a  UR                  5         UR                  S5        UR                  5       US'   UR                  5       US'   UR                  5       US'   UR                  5       US'   UR                  5       US'   UR                  5       US'   UR                  5       US'   UR                  5       US	'   UR                  5       US
'   UR                  5       US'   UR                  5       US'   UR	                  5         U$ )Nr   kex_algo_listserver_key_algo_listclient_encrypt_algo_listserver_encrypt_algo_listclient_mac_algo_listserver_mac_algo_listclient_compress_algo_listserver_compress_algo_listclient_lang_listserver_lang_listkex_follows)get_byte	get_bytesget_listget_booleanr  )r  r  ignore_first_byteparseds       rk   _really_parse_kex_init Transport._really_parse_kex_init	  s    JJL	B"#**,)*%&-.ZZ\)*-.ZZ\)*)*%&)*%&./jjl*+./jjl*+%&ZZ\!"%&ZZ\!" !}			rm   c                 H    U R                  [        U R                  5      SS9$ )NT)r$  )r&  rT   r  r2  s    rk   _get_latest_kex_initTransport._get_latest_kex_init	  s+    **D))*" + 
 	
rm   c                 F   U R                  U5      nUS   nUS   nUS   nUS   nUS   nUS   nUS   n	US   n
US	   nUS
   nUS   nU R                  [        S5        SU4SU4SU4SU4SU4SU4SU	4SU
4SU4SU44
 HE  u  pUS/:X  a  S/nSR                  U5      nU R                  [        SR	                  X5      5        MG     U R                  [        SR	                  U5      5        U R                  [        S5        S U l        S U l        / n[        U5       H  u  nnUR                  S5      (       a  UU l        UR                  SU5        M7  UR                  S5      (       d  MO  U R                  (       a  S OS!nSU S"3nUU:H  =(       a    U R                  U l        U R                  [        S#U R                   35        UR                  SU5        M     U H  nUR                  U5        M     U R                  (       a,  U R                  (       d  UR                  S:w  a  [!        S$5      eU R                  (       a*  [#        [%        U R&                  R(                  U5      5      nO)[#        [%        UR(                  U R&                  5      5      n[+        U5      S:X  a  [-        S%5      eU R.                  US      " U 5      U l        U R                  [        S&R	                  US   5      5        U R                  (       aj  [#        [%        [#        U R2                  R5                  5       5      R(                  U R6                  5      5      n[#        [%        UR(                  U5      5      nO)[#        [%        UR(                  U R6                  5      5      n[+        U5      S:X  a  [-        S'5      eUS   U l        U R                  (       a  U R;                  5       c  [-        S(5      eU R=                  S)US   US   5        U R                  (       aS  [#        [%        U R>                  R(                  U5      5      n[#        [%        U R>                  R(                  U5      5      nOR[#        [%        UR(                  U R>                  5      5      n[#        [%        UR(                  U R>                  5      5      n[+        U5      S:X  d  [+        U5      S:X  a  [-        S*5      eUS   U l         US   U l!        U R=                  S+U R@                  U RB                  S,9  U R                  (       aS  [#        [%        U RD                  R(                  U5      5      n[#        [%        U RD                  R(                  U5      5      nOR[#        [%        UR(                  U RD                  5      5      n[#        [%        UR(                  U RD                  5      5      n[+        U5      S:X  d  [+        U5      S:X  a  [-        S-5      eUS   U l#        US   U l$        U R=                  S.U RF                  U RH                  S,9  U R                  (       aS  [#        [%        U RJ                  R(                  U	5      5      n[#        [%        U RJ                  R(                  U
5      5      nOR[#        [%        U	R(                  U RJ                  5      5      n[#        [%        U
R(                  U RJ                  5      5      n[+        U5      S:X  d  [+        U5      S:X  a-  S/nUS0-  n[-        UR	                  UUU RJ                  5      5      eUS   U l&        US   U l'        U R=                  S1U RL                  U RN                  S,9  U R                  [        S25        [P        URS                  5       -   U l*        g )3Nr  r  r  r  r  r  r  r  r  r  r  z"=== Key exchange possibilities ===z	kex algosz
server keyzclient encryptzserver encryptz
client macz
server maczclient compresszserver compresszclient langzserver langr   z<none>z, z{}: {}zkex follows: {}z=== Key exchange agreements ===z	ext-info-r   r  r  r  r  zStrict kex mode: z9In strict-kex mode, but KEXINIT was not the first packet!z3Incompatible ssh peer (no acceptable kex algorithm)zKex: {}z.Incompatible ssh peer (no acceptable host key)z;Incompatible ssh peer (can't match requested host key type)HostKeyz/Incompatible ssh server (no acceptable ciphers)r	   )r  r  z,Incompatible ssh server (no acceptable macs)MACz3Incompatible ssh server (no acceptable compression)z {!r} {!r} {!r}Compressionz=== End of kex handshake ===)+r&  r  r   rj  r   _remote_ext_info_remote_strict_kex	enumerater  r  r  r   r   r  r   r  r_   r  r	  rG  r
  r   r^   	_kex_infor   r  r;  r?  r   r}  r  r3  r   r   r8  r   r   rK  r   r   r   
get_so_farr   )r  r  r%  r  r  r  r  r  r  r  r  r  r  r  prefixvalueto_popr  algor  expected
agreed_kexr  agreed_keysagreed_local_ciphersagreed_remote_ciphersagreed_remote_macsagreed_local_macsagreed_remote_compressionagreed_local_compressionrp  s                                  rk   r  Transport._parse_kex_init	  s   ,,Q//%&<=#)*D#E #)*D#E %&<=%&<=$*+F$G!$*+F$G!!"45!"45]+		%=>-(/0 7878/0/0 9: 9:,-,-
MF }!
IIe$EIIeX__V;<#
$ 			%*11+>?		%:; !%"& /GAt{++(,%a#//#//S(/?@ H$B)B)B ) 		.t/H/H.IJ a# 0  Aa   %%))1#K  t))66FJ }1143E3EFJ z?a #E  ..A7=		%))*Q-89$(--2245BB''%! )668LK +88$:M:MNK {q "@  )^!4!4!6!>"M  	I{1~{1~F#'**77,$  %)**77,%! $(,99**$  %),99**%! #$)S1F-G1-L"A  13215D--d6H6H 	 	
 !%t**779MN" !%t**779MN! !%+88$:M:MN! "&+88$:M:MN" !"a'S1C-D-I">  +1-,Q/ 	 	
 (,..;;-)% (,..;;-($ (,-::..($ )--::..)% ()Q.,-2GC$$C"

,-..  ":!!<";A">((** 	 	

 			%78  ,alln<rm   c                    U R                   U R                     nUR                  SS5      nUS   nUS   nUR                  SU5      nU R                  (       a%  U R	                  SU5      nU R	                  SU5      nO$U R	                  SU5      nU R	                  S	U5      nU R                  U R                  UUU R                  US
9nU(       + =(       a    SU R                  ;   n	U R                  U R                     S   n
U R                  U R                     S   nU R                  (       a"  U R	                  SU" 5       R                  5      nO!U R	                  SU" 5       R                  5      nU R                  R                  UUU(       a  SOUU(       a  SOU
U(       a  SOUU	UU(       a  UOSS9  U R                  U R                     S   nUbW  U R                  S:w  d  U R                  (       a6  U R                  [         S5        U R                  R#                  U" 5       5        U R$                  (       a1  U R                  [         S5        U R                  R'                  5         gg)zDswitch on newly negotiated encryption parameters for
inbound trafficr   Fr   r   r   ACBDr  rx  r  r  r   etm@openssh.comr   r   EFNr   )block_engine
block_size
mac_enginemac_sizemac_keyetmr   iv_inr   r   $Switching on inbound compression ...z8Resetting inbound seqno after NEWKEYS due to strict mode)rR  r   r%  r  r  r  _DECRYPTr   	_mac_infodigest_sizer   set_inbound_cipher_compression_infor   r   r  r   set_inbound_compressorr   reset_seqno_in)r  r  r   rL  key_sizeiv_sizerQ  key_inenginerP  rN  rM  rO  compress_ins                 rk   _activate_inboundTransport._activate_inbound
  s       !3!34xx	5),'

#((9j1%%c73E&&sH5F%%c73E&&sH5F!!##mm " 
 xA.$//A>>$//26:^^DOO4W=
 ''Z\-E-EFG''Z\-E-EFG**!#tRX Dg%T 	+ 		
 ,,T-D-DEaH"##'99T=O=OIIeCDOO22;=A$$IIJ OO**, %rm   c                    [        5       nUR                  [        5        U R                  U5        U R                  (       a0  U R                  [        S5        U R                  R                  5         U R                  U R                     nUR                  SS5      nUS   nUS   nUR                  SU5      nU R                  (       a%  U R                  SU5      nU R                  SU5      nO$U R                  S	U5      nU R                  S
U5      nU R                  U R                  UUU R                  US9n	U(       + =(       a    SU R                   ;   n
U R"                  U R                      S   nU R"                  U R                      S   nU R                  (       a"  U R                  SU" 5       R$                  5      nO!U R                  SU" 5       R$                  5      nU R                  R'                  S5      nU R                  R)                  U	UU(       a  SOUU(       a  SOUU(       a  SOUUU
UU(       a  UOSS9	  U R*                  U R,                     S   nUbW  U R,                  S:w  d  U R.                  (       a6  U R                  [        S5        U R                  R1                  U" 5       5        U R                  R3                  5       (       d  SU l        U R                  (       a  U R6                  (       a  U R8                  S:X  a  SSR;                  U R<                  5      0n[        5       nUR                  [>        5        URA                  [C        U5      5        [E        URG                  5       5       H(  u  nnURI                  U5        URI                  U5        M*     U R                  U5        U RK                  [L        5        g)zEswitch on newly negotiated encryption parameters for
outbound trafficz9Resetting outbound seqno after NEWKEYS due to strict moder   Fr   r   r   rE  rF  rC  rD  rG  rH  r   r   rJ  rI  z-ctrNr   )	rK  rL  rM  rN  rO  sdctrrP  r   iv_outr   r   %Switching on outbound compression ...r  zserver-sig-algs,)'rT   r  r   r~  r   r  r   r   reset_seqno_outrR  r   r%  r  r  r  r  r   rT  rU  endswithset_outbound_cipherrW  r   r   set_outbound_compressorr  r   r   r/  rj  rC  rA   r  r   sorteditemsr  r  r    )r  r  r  r   rL  rZ  r[  rc  key_outr]  rP  rN  rM  rO  rb  compress_out
extensionsr  r5  s                      rk   _activate_outboundTransport._activate_outbound
  s    I	

< 1$$IIK OO++-  !2!23xx	5),'

#((9j1&&sG4F''X6G&&sG4F''X6G!!""mm " 
 x@.$..@>>$..1&9^^DNN3G<
 ''Z\-E-EFG''Z\-E-EFG!!**62++!#tRX Dg!6t 	, 
	
 --d.D.DEaH#""&88D<N<NIIeDEOO33LNC))++DK $$%%5+SXXd6L6L-MNJ	AJJ}%IIc*o&%j&6&6&89eT"U#  : q!K(rm   c                    SU l         U R                  S:X  aR  U R                  U R                     S   nU R                  [        S5        U R
                  R                  U" 5       5        U R                  S:X  aS  U R                  U R                     S   nU R                  [        S5        U R
                  R                  U" 5       5        g g )NTr   r   rd  r   rR  )	r   r   rW  r  r   r   ri  r   rX  )r  rm  r^  s      rk   _auth_triggerTransport._auth_trigger8  s    !!!%7711$2H2HI!LLIIeDEOO33LNC""&88001H1HI!LKIIeCDOO22;=A 9rm   c                     0 n[        UR                  5       5       H'  nUR                  5       nUR                  5       nXRU'   M)     U R	                  [
        SR                  U5      5        X l        g )NzGot EXT_INFO: {})r  r  r  
get_stringr  r   r   r   )r  rp  rn  _r  r5  s         rk   r  Transport._parse_ext_infoD  sa     
s{{}%A<<>DNN$E$t & 			%+22:>? ",rm   c                    U R                  [        S5        U R                  5         S =U l        U l        S U l        S U l        U R                  (       a  U R                  c  [        U 5      U l        U R                  (       d  S=U l
        U R                  l        U R                  b  U R                  R                  5         U R                  R                  5       (       d  SU l        U R"                  R%                  5          U R&                  R                  5         U R"                  R)                  5         g ! U R"                  R)                  5         f = f)NzSwitch to new keys ...TF)r  r   r_  r   r   r   r   r  r   r   r   r   _initial_kex_doner   r  r  r   r   r  r   r  r  s     rk   r	  Transport._parse_newkeysR  s	   		%12 599d2!2!2!: +D 1D$$ IMLD!DOO$E  ,!!%%'))++DK'')	.""$##++- ##++-s   D7 7Ec                     UR                  5       nUR                  5       nU R                  [        SR	                  X#5      5        g )NzDisconnect (code {:d}): {})r  r  r  r   r   )r  r  codedescs       rk   r  Transport._parse_disconnectn  s2    yy{zz|		$4;;DGHrm   c                 N   UR                  5       nU R                  [        SR                  U5      5        UR	                  5       nU R
                  (       d(  U R                  [        SR                  U5      5        SnOUS:X  aF  UR                  5       nUR                  5       nU R                  R                  XV5      nU(       a  U4nO_US:X  a>  UR                  5       nUR                  5       nU R                  R                  XV5        SnOU R                  R                  X!5      nSn[        U5      [        L a  UnSnU(       a]  [        5       nU(       a%  UR                  [        5        UR                   " U6   OUR                  ["        5        U R%                  U5        g g )NzReceived global request "{}"z*Rejecting "{}" global request from server.Fr  r  T )r  r  r   r   r#  r  r  r  check_port_forward_requestcancel_port_forward_requestcheck_global_requestr   r   rT   r  r!   r  r"   r~  )	r  r  r  
want_replyokr  r  extrarp  s	            rk   r
  Transport._parse_global_requests  sL   zz|		%7>>tDE]]_
II<CCDI B_$jjlG99;D##>>wMBU++jjlG99;D::7IB##88AB8uEB)C1212s# rm   c                     U R                  [        S5        Xl        U R                  b  U R                  R	                  5         g g )NzGlobal request successful.r  r   r   r   r  r  s     rk   r   Transport._parse_request_success  s:    		%56   ,!!%%' -rm   c                     U R                  [        S5        S U l        U R                  b  U R                  R	                  5         g g )NzGlobal request denied.r  r  s     rk   r   Transport._parse_request_failure  s<    		%12#  ,!!%%' -rm   c                 v   UR                  5       nUR                  5       nUR                  5       nUR                  5       nU R                  R                  U5      nUc  U R                  [        S5        g U R
                  R                  5          UR                  X4U5        U R                  [        SR                  U5      5        X R                  ;   a*  U R                  U   R                  5         U R                  U	 U R
                  R                  5         g ! U R
                  R                  5         f = f)Nz%Success for unrequested channel! [??]zSecsh channel {:d} opened.)r  r   r%  r  r   r   r  _set_remote_channelr   r   r   r  r  )r  r  r  server_chanidserver_window_sizeserver_max_packet_sizer  s          rk   r  %Transport._parse_channel_open_success  s    		YY[!"~~!!&)<IIgFG				 $$3I IIe9@@HI,,,##F+//1''/II IIs   A0D D8c                    UR                  5       nUR                  5       nUR                  5       nUR                  5         [        R                  " US5      nU R	                  [
        SR                  X$U5      5        U R                  R                  5          [        X55      U l
        X R                  ;   aT  U R                  R                  U5        X R                  ;   a*  U R                  U   R                  5         U R                  U	 U R                  R                  5         g ! U R                  R                  5         f = f)Nz(unknown code)z&Secsh channel {:d} open FAILED: {}: {})r  r  r#   r%  r  r   r   r   r  r]   r   r   r   ry  r  r  )r  r  r  r  
reason_strreason_texts         rk   r  %Transport._parse_channel_open_failure  s    ZZ\
	

,009IJ		4;;K	
 				 #3F#HD ,,,%%f-000''/335++F3II IIs   A3D' 'Ec                 T   UR                  5       nUR                  5       nUR                  5       nUR                  5       nSnUS:X  aj  U R                  b]  U R                  [        S5        U R
                  R                  5          U R                  5       nU R
                  R                  5         GOUS:X  a  U R                  b  UR                  5       nUR                  5       n	U R                  [        SR                  X5      5        U R
                  R                  5          U R                  5       nU R
                  R                  5         GOUS:X  a  U R                  b  UR                  5       n
UR                  5       nUR                  5       nUR                  5       n	U R                  [        SR                  X5      5        U R
                  R                  5          U R                  5       nU R
                  R                  5         GO6U R                  (       d.  U R                  [        SR                  U5      5        S	n[        nOU R
                  R                  5          U R                  5       nU R
                  R                  5         US
:X  a`  UR                  5       nUR                  5       nUR                  5       nUR                  5       n	U R                  R                  UX4X45      nOU R                  R!                  X'5      nU["        :w  a'  U R                  [        SR                  U5      5        S	nU(       au  [%        5       nUR'                  [(        5        UR+                  U5        UR+                  W5        UR-                  S5        UR-                  S5        U R/                  U5        g [1        W5      nU R
                  R                  5          U R2                  R5                  UU5        S	U R6                  U'   UR9                  U 5        UR;                  U R<                  U R>                  5        URA                  X4U5        U R
                  R                  5         [%        5       nUR'                  [B        5        UR+                  U5        UR+                  U5        UR+                  U R<                  5        UR+                  U R>                  5        U R/                  U5        U R                  [        SR                  Xr5      5        US:X  a  U R                  U5        g US:X  a  U R                  UWW	45        g US:X  a   WW	4Ul"        U R                  UX4W
W45        g U RG                  U5        g ! U R
                  R                  5         f = f! U R
                  R                  5         f = f! U R
                  R                  5         f = f! U R
                  R                  5         f = f! U R
                  R                  5         f = f)NFr  z!Incoming forward agent connectionr  z$Incoming x11 connection from {}:{:d}r  z.Incoming tcp forwarded connection from {}:{:d}z+Rejecting "{}" channel request from server.Tr  z+Rejecting "{}" channel request from client.r   r  zSecsh channel {:d} ({}) opened.)$r  r  r   r  r   r   r  r  r  r   r   r   r  r$   r  "check_channel_direct_tcpip_requestcheck_channel_requestr%   rT   r  r&   r  r  r~  r   r   r  r   r  r  r   r   r  r'   origin_addrr  )r  r  r  r  initial_window_sizer  reject	my_chanidr  origin_portserver_addrserver_portr  r  	dest_portrp  r  s                    rk   r  Transport._parse_channel_open  s   zz|iik))+,,++7IIe@AII$ ..0			!!#em$"3"3"?**,K))+KII6== II$ ..0			!!#''d.?.?.K**,K))+K**,K))+KII@GG II$ ..0			!!#!!II=DDTJ F<FII$ ..0			!!#~%JJL	IIK	jjliik++NN .* ++AA '		AHHN )CLL23KKKKNN2NN4 s#y!			 NNy$/,0Dy)%(($*F*F $$_ III	

,-			&			)			$**+			$../1		4;;IL	
 ++''-U]d[+$>?&& +[9D{0;2L ((.[ 		!!# 		!!#  		!!# 		!!#Z IIs=   V &V. %W +W, )A4X V+.W
W),XX'c                     UR                  5         UR                  5       nUR                  5         U R                  [        SR	                  [
        R                  " U5      5      5        g )NzDebug msg: {})r#  ru  r  r   r   r   safe_string)r  r  rp  s      rk   r  Transport._parse_debugO  sC    	lln			%//0@0@0EFGrm   c                 $    U R                   R                  5         XR                  ;  a  S / 0 4U R                   R                  5         $ U R                  U   U R                   R                  5         $ ! U R                   R                  5         f = frg   r  rN  s     rk   _get_subsystem_handler Transport._get_subsystem_handlerU  so    	 II///R| II ''-IIDIIs   -A3 
A3 3B)Gr   r   r   r   r   r   r  r  r\  r   r  r/  r0  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r   r  r  r  r   r   r   r  r  r   )TTrg   )NNN)NNNNN)NT)	Nr   NNNFFTTr   Nr   T)NNF)F)r  
__module____qualname____firstlineno____doc__objectr  rS  r   r   paramiko__version__r   _preferred_ciphers_preferred_macsr  _preferred_pubkeysr   rG   is_availabler   r\  r   AESr
   CTRCBCre   r   AESGCMrR  r   r   r   r   rT  rX   rE   rY   rF   r  rJ   rK   rH   rI   rL   rM   rR   rS   rQ   rN   rO   rP   r2  rC   rD   rW  r  r   r;   r<   r   r-  propertyr3  r8  r?  rC  rG  rK  rV  rZ  r^  rd  rp  rt  ry  r}  staticmethodr  rY  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   rk  r  rS  r  r  r  r   r  r-  rG  r  r  rO  rR  rU  rY  r^  ra  ri   r  rs  r  rz  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r&  r)  r  r_  ro  rr  r  r	  r  r
  r  r  r  r  r  r  r  r0   r   _request_successr1   _request_failedr2   _feedr3   _feed_extendedr4   _window_adjustr5   _handle_requestr6   _handle_eofr7   _handle_closer  __static_attributes__r  rm   rk   ro   ro      s    xHxHI%%h&:&:;J
	O	O	
N !!##:^K
 '  ^^II	
  ^^II	
  ^^II	
  ^^II	
  ^^II	
  ^^II	
 II	
 [[#
 [[#
e9Lx  $R0"&3#)26392)F#)26392)F!2.!$b1	I
 	6 	' 	 	,V 	 	,V 	6 	' 	x 	3H 	x  	3H!" 	x#$ 	3H%& 	z'( 	+J)I0 '0'1.40<)9)94@5B1:)))I !!##4A	01 ,-=>!12 M
 0 7 k
Z
 1 1 . . 	
 	
 1 1 - - 5 52% !D8t@D7(* & &P	" ?C!
F; ;
I ]~4lP
/#$4:"#$J6 ~@ ( (

0(=8Sj/=b3=jD.=4=.-
-	-4""*/"&+.4 .
<&*2	( J
N
$LjX	$)VFP&
h=T8-tO)b
B,8I
"$H((,0|/|H  	W55W44'--!7#9#9!7#9#9W44,,700	rm   ro   c                   2   \ rS rSrSrSrS rS rS r\	S 5       r
\
R                  S 5       r
\	S	 5       r\R                  S
 5       r\	S 5       r\R                  S 5       r\	S 5       r\R                  S 5       r\	S 5       r\R                  S 5       rSrg)r]  im  a  
Simple object containing the security preferences of an ssh transport.
These are tuples of acceptable ciphers, digests, key types, and key
exchange algorithms, listed in order of preference.

Changing the contents and/or order of these fields affects the underlying
`.Transport` (but only if you change them before starting the session).
If you try to add an algorithm that paramiko doesn't recognize,
``ValueError`` will be raised.  If you try to assign something besides a
tuple to one of the fields, ``TypeError`` will be raised.

_transportc                     Xl         g rg   r  )r  	transports     rk   r   SecurityOptions.__init__|  s    #rm   c                 8    SR                  U R                  5      $ )rN  z#<paramiko.SecurityOptions for {!r}>)r   r  r2  s    rk   rV  SecurityOptions.__repr__  s     5;;DOOLLrm   c                 n   [        U5      [        L a  [        U5      n[        U5      [        La  [        S5      e[        [	        U R
                  U5      R                  5       5      nU Vs/ s H  oUU;  d  M
  UPM     nn[        U5      S:  a  [        S5      e[        U R
                  X5        g s  snf )Nzexpected tuple or listr   zunknown cipher)
r   r  r   	TypeErrorr+  r  r;  r   
ValueErrorr  )r  r  origr'  possiblen	forbiddens          rk   _setSecurityOptions._set  s    7d?aA7%4556;;=> !71h%6Q	7y>A-..) 8s   ,	B29B2c                 .    U R                   R                  $ )zSymmetric encryption ciphers)r  r  r2  s    rk   r0  SecurityOptions.ciphers  s     111rm   c                 *    U R                  SSU5        g )Nr  rR  r  r  r'  s     rk   r0  r    s    		&:rm   c                 .    U R                   R                  $ )z Digest (one-way hash) algorithms)r  r  r2  s    rk   digestsSecurityOptions.digests       ...rm   c                 *    U R                  SSU5        g )Nr  rT  r  r  s     rk   r  r        		#[!4rm   c                 .    U R                   R                  $ )zPublic-key algorithms)r  r  r2  s    rk   	key_typesSecurityOptions.key_types  r  rm   c                 *    U R                  SSU5        g )Nr  r  r  r  s     rk   r  r    r  rm   c                 .    U R                   R                  $ )zKey exchange algorithms)r  r   r2  s    rk   rF  SecurityOptions.kex  s     ---rm   c                 *    U R                  SSU5        g )Nr   r2  r  r  s     rk   rF  r    s    		"K3rm   c                 .    U R                   R                  $ )zCompression algorithms)r  r\  r2  s    rk   rJ  SecurityOptions.compression  s     555rm   c                 *    U R                  SSU5        g )Nr\  rW  r  r  s     rk   rJ  r    s    		*,?Crm   r  N)r  r  r  r  r  	__slots__r   rV  r  r  r0  setterr  r  rF  rJ  r  r  rm   rk   r]  r]  m  s    
 I$M	* 2 2 ^^; ; / / ^^5 5 / / 5 5 . . 	ZZ4 4 6 6 D Drm   r]  c                   8    \ rS rSrS rS rS rS rS rS r	Sr
g	)
r   i  c                 l    [         R                  " 5       U l        [        R                  " 5       U l        g rg   )r  WeakValueDictionary_mapr   r   _lockr2  s    rk   r   ChannelMap.__init__  s     //1	^^%
rm   c                     U R                   R                  5          X R                  U'   U R                   R                  5         g ! U R                   R                  5         f = frg   )r  r  r  r  )r  r  r  s      rk   r  ChannelMap.put  sD    

	! $IIfJJ DJJ s   A A!c                     U R                   R                  5          U R                  R                  US 5      U R                   R	                  5         $ ! U R                   R	                  5         f = frg   )r  r  r  r%  r  rv  s     rk   r%  ChannelMap.get  sJ    

	!99==.JJ DJJ s   A A.c                     U R                   R                  5           U R                  U	 U R                   R	                  5         g ! [         a     N'f = f! U R                   R	                  5         f = frg   )r  r  r  r|  r  rv  s     rk   ry  ChannelMap.delete  sa    

	!IIf% JJ    JJ s#   A 
AA AA A1c                     U R                   R                  5          [        U R                  R	                  5       5      U R                   R                  5         $ ! U R                   R                  5         f = frg   )r  r  r  r  r  r  r2  s    rk   r  ChannelMap.values  sM    

	!		((*+JJ DJJ s   "A A5c                     U R                   R                  5          [        U R                  5      U R                   R	                  5         $ ! U R                   R	                  5         f = frg   )r  r  r   r  r  r2  s    rk   __len__ChannelMap.__len__  sC    

	!tyy>JJ DJJ r
  )r  r  N)r  r  r  r  r   r  r%  ry  r  r  r  r  rm   rk   r   r     s     &
!!!!!rm   r   c                   t   ^  \ rS rSrSrU 4S jrS rS rS rS r	SS jr
S	 rSS
 jrSS jrS rS rSrU =r$ )ServiceRequestingTransporti  zX
Transport, but also handling service requests, like it oughtta!

.. versionadded:: 3.2
c                 n   > [         TU ]  " U0 UD6  SU l        U R                  U R                  [
        '   g )NF)superr   _service_userauth_accepted_parse_service_acceptr  r,   )r  r  r  r  s      rk   r   #ServiceRequestingTransport.__init__  s4    $)&)*/'262L2L./rm   c                     UR                  5       nUS:w  a&  U R                  [        SR                  U5      5        g SU l        U R                  [        S5        g )Nssh-userauthz!Service request "{}" accepted (?)Tz+MSG_SERVICE_ACCEPT received; auth may begin)r  r  r   r   r  )r  r  services      rk   r  0ServiceRequestingTransport._parse_service_accept  sT    **, n$ II:AA'J  +/'		%FGrm   c                    U R                   (       a  U R                  (       d  [        S5      eU R                  (       a  g [	        5       nUR                  [        5        UR                  S5        U R                  [        S5        U R                  U5        U R                  (       d)  [        R                  " S5        U R                  (       d  M)  U R                  5       U l        g )Nr  r  z)Sending MSG_SERVICE_REQUEST: ssh-userauthr   )r   r   ra   r  rT   r  r+   r  r  r   r~  ri  sleepget_auth_handlerr   r  s     rk   ensure_session)ServiceRequestingTransport.ensure_session  s     T%:%: 455**I	

'(	^$		%DE1 11 JJsO 111 !113rm   c                     [        U 5      $ rg   )r   r2  s    rk   r  +ServiceRequestingTransport.get_auth_handler4  s    t$$rm   c                 X    U R                  5         U R                  R                  U5      $ rg   )r  r   r  r  r  s     rk   r  $ServiceRequestingTransport.auth_none8  s%      **844rm   c                   ^ U R                  5          U R                  R                  UT5      $ ! [         aJ  nU(       a  SUR                  ;  a  e  U4S jnU R                  X5      s S nA$ ! [         a    Uef = fS nAff = f)Nr"  c                 `   > [        U5      S:  a  [        S5      e[        U5      S:X  a  / $ T/$ r$  r%  r&  s      rk   r  9ServiceRequestingTransport.auth_password.<locals>.handlerI  r+  rm   )r  r   r   r\   r,  r-  ra   )r  r  r  r.  r!  r  s     `   rk   r   (ServiceRequestingTransport.auth_password=  s    	$$228XFF$ 	  6aoo M	& ,,X?? '	s,   / 
BA>A.(B.A;;A>>Bc                 X    U R                  5         U R                  R                  X5      $ rg   )r  r   r  )r  r  rx  s      rk   r  )ServiceRequestingTransport.auth_publickeyY  s%      //>>rm   c                 Z    U R                  5         U R                  R                  XU5      $ rg   )r  r   r-  rF  s       rk   r-  +ServiceRequestingTransport.auth_interactive^  s,      11z
 	
rm   c                 Z    U R                  5         U(       d  S nU R                  XU5      $ )Nc                    / nU (       a  [        U R                  5       5        U(       a  [        UR                  5       5        U H6  u  pE[        UR                  5       SS9  UR                  [        5       5        M8     U$ r7  r:  r?  s         rk   r  AServiceRequestingTransport.auth_interactive_dumb.<locals>.handlerm  rE  rm   )r  r-  rF  s       rk   rG  0ServiceRequestingTransport.auth_interactive_dumbe  s-    
 		 $$X
CCrm   c                     U R                  5         U R                  5       U l        U R                  R                  XU5      $ rg   )r  r  r   r  )r  r  r   r  s       rk   r  /ServiceRequestingTransport.auth_gssapi_with_micz  s=     113  55
 	
rm   c                     U R                  5         U R                  5       U l        U R                  R                  U5      $ rg   )r  r  r   r  r  s     rk   r  ,ServiceRequestingTransport.auth_gssapi_keyex  s6     113  228<<rm   )r  r   r  r  r  )r  r  r  r  r  r   r  r  r  r  r   r  r-  rG  r  r  r  __classcell__)r  s   @rk   r   r     sH    M
H*"4H%5
8?

D*
= =rm   r   )r  r  r   r  r   ri  r  hashlibr   r   r   r   cryptography.hazmat.backendsr   &cryptography.hazmat.primitives.ciphersr   r	   r
   r   r  r   paramiko.auth_handlerr   r   paramiko.ssh_gssr   paramiko.channelr   paramiko.commonr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   paramiko.compressrC   rD   paramiko.dsskeyrE   paramiko.ed25519keyrF   paramiko.kex_curve25519rG   paramiko.kex_gexrH   rI   paramiko.kex_group1rJ   paramiko.kex_group14rK   rL   paramiko.kex_group16rM   paramiko.kex_ecdh_nistrN   rO   rP   paramiko.kex_gssrQ   rR   rS   paramiko.messagerT   paramiko.packetrU   rV   paramiko.primesrW   paramiko.rsakeyrX   paramiko.ecdsakeyrY   paramiko.serverrZ   paramiko.sftp_clientr[   paramiko.ssh_exceptionr\   r]   r^   r_   r`   ra   paramiko.utilrb   rc   rd   /cryptography.hazmat.decrepit.ciphers.algorithmsre   ImportError1cryptography.hazmat.primitives.ciphers.algorithmsrh   rl   atexitregisterr   ro   r]  r   r   r  rm   rk   <module>rD     sS  ( 
  
    - - 8    > $ $3 3 3 3 3 3 3 3 3 3 3 3 3h ? " * 1 1 ) = 1 H H C C $ : ' " & + +  LI 
  ' (J/	  "7 J/`^ND NDb*! *!Z[= [=Ac  LKLs   F) )F87F8