+
    Dfj@             	      (   R t ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIH	t	H
t
HtHtHt ^ RIHtHtHtHtHtHt ^ RIHt ^ RIHt ^ RIHt ^ RIHtHtHt ^ R	IH t H!t!H"t" ^ R
IH#t# ^ RI$H%t& ^ RI'H(t(H)t)H*t* ^ RI+H,t,H-t-H.t.H/t/H0t0 ^ RI1H2t2 ^ RI3H4t4H5t5 ^ RI6H7t7 ^ RI8H9t9 ^ RI:H;t;H<t< ^ RI=H>t> ]'       d   ^ RI?H@t@ R tA]tB]]C]. ]B3,          ]P                  3,          tE ! R R]]E]F]F]G3,          4      tH ! R R4      tIR tJ ! R R]5P                  4      tL ! R R]L4      tM ! R R ]L4      tN ! R! R"4      tO ! R# R$4      tP ! R% R&4      tQ](P                  ! R'4      w  tStT^tU^tV^tW^tX^tY^tZ^t[^t\^t]^t^^t_^t`^"ta^tb^ tc^!td^te^tf^tg^th^ti^tj^tk^tl^	tm^
tn^to^tp^tq^tr^ts/ tt]u! ]v! 4       P                  4       4       F=  w  txty]xP                  R(4      '       g   K  ]xP                  R)4      '       d   K8  ]x]t]y&   K?  	  R*]t9   g   R+]t9   d	   ]{! R,4      hR# )-z
The lowest level SSH protocol.  This handles the key negotiation, the
encryption and the compression.  The transport layer is described in
RFC 4253.

Maintainer: Paul Swartz
)annotationsN)md5sha1sha256sha384sha512)TYPE_CHECKINGAnyCallableDictTupleUnion)UnsupportedAlgorithm)default_backend)serialization)dhecx25519)Cipher
algorithmsmodes)Literal)__version__)_kexaddresskeys)MPNSffsgetMPgetNS)
SSHService)deferprotocol)Logger)	randbytes)	iterbytesnetworkString)Failure)
SSHFactoryc                @    \        \        P                  V R4      4      # )a  Make an SSH multiple-precision integer from big-endian L{bytes}.

Used in ECDH key exchange.

@type data: L{bytes}
@param data: The input data, interpreted as a big-endian octet string.

@rtype: L{bytes}
@return: The given data encoded as an SSH multiple-precision integer.
big)r   int
from_bytes)datas   &=/usr/lib/python3/dist-packages/twisted/conch/ssh/transport.py_mpFromBytesr0   .   s     cnnT5)**    c                  &    ] tR t^At$ RtR]R&   RtR# )
_MACParamsa   
L{_MACParams} represents the parameters necessary to compute SSH MAC
(Message Authenticate Codes).

L{_MACParams} is a L{tuple} subclass to maintain compatibility with older
versions of the code.  The elements of a L{_MACParams} are::

    0. The digest object used for the MAC
    1. The inner pad ("ipad") string
    2. The outer pad ("opad") string
    3. The size of the digest produced by the digest object

L{_MACParams} is also an object lesson in why tuples are a bad type for
public APIs.

@ivar key: The HMAC key which will be used.
byteskey N)__name__
__module____qualname____firstlineno____doc____annotations____static_attributes__r6   r1   r/   r3   r3   A   s    $ 
Jr1   r3   c                     ] tR t^WtRtR]P                  ^]P                  3R]P                  ^ ]P                  3R]P                  ^]P                  3R]P                  ^]P                  3R]P                  ^]P                  3R]P                  ^]P                  3R]P                  ^ ]P                  3R	]P                  ^]P                  3R
R^ ]P                  3/	tR]R]R]R]R]R
R/tR tR tR tR R ltR tR tR tR tRtR# )
SSHCiphersa  
SSHCiphers represents all the encryption operations that need to occur
to encrypt and authenticate the SSH connection.

@cvar cipherMap: A dictionary mapping SSH encryption names to 3-tuples of
    (<cryptography.hazmat.primitives.interfaces.CipherAlgorithm>,
    <block size>, <cryptography.hazmat.primitives.interfaces.Mode>)
@cvar macMap: A dictionary mapping SSH MAC names to hash modules.

@ivar outCipType: the string type of the outgoing cipher.
@ivar inCipType: the string type of the incoming cipher.
@ivar outMACType: the string type of the incoming MAC.
@ivar inMACType: the string type of the incoming MAC.
@ivar encBlockSize: the block size of the outgoing cipher.
@ivar decBlockSize: the block size of the incoming cipher.
@ivar verifyDigestSize: the size of the incoming MAC.
@ivar outMAC: a tuple of (<hash module>, <inner key>, <outer key>,
    <digest size>) representing the outgoing MAC.
@ivar inMAc: see outMAC, but for the incoming MAC.
   3des-cbc
   aes256-cbc
   aes192-cbc
   aes128-cbc
   aes128-ctr
   aes192-ctr
   aes256-ctr   3des-ctr   noneN   hmac-sha2-512   hmac-sha2-384   hmac-sha2-256	   hmac-sha1   hmac-md5c                	|    Wn         W n        W0n        W@n        ^ V n        ^ V n        ^ V n        RV n        RV n        R# )    NNr1   r1   rO   )	
outCipType	inCipType
outMACType	inMACTypeencBlockSizedecBlockSizeverifyDigestSizeoutMACinMAC)selfoutCipinCipoutMacinMacs   &&&&&r/   __init__SSHCiphers.__init__   s<       !)(
r1   c                .   V P                  V P                  W4      pVP                  4       V n        VP                  P                  ^,          V n        V P                  V P                  W44      pVP                  4       V n        VP                  P                  ^,          V n        V P                  V P                  V4      V n        V P                  V P                  V4      V n        V P                  '       d   V P                  ^,          V n        R# R# )aD  
Set up the ciphers and hashes using the given keys,

@param outIV: the outgoing initialization vector
@param outKey: the outgoing encryption key
@param inIV: the incoming initialization vector
@param inKey: the incoming encryption key
@param outInteg: the outgoing integrity key
@param inInteg: the incoming integrity key.
N)
_getCipherrQ   	encryptor	algorithm
block_sizerU   rR   	decryptorrV   _getMACrS   rX   rT   rY   rW   )rZ   outIVoutKeyinIVinKeyoutInteginIntegos   &&&&&&& r/   setKeysSSHCiphers.setKeys   s     OODOOU;KK22a7OODNND8KK22a7ll4??H=\\$..':
:::$(JJqMD! r1   c           	         V P                   V,          w  rEpVf   \        4       # \        V! VRV 4      V! VRVP                  ^,           4      \	        4       R7      # )z
Creates an initialized cipher object.

@param cip: the name of the cipher, maps into cipherMap
@param iv: the initialzation vector
@param key: the encryption key

@return: the cipher object.
Nbackend)	cipherMap_DummyCipherr   re   r   )rZ   cipivr5   algorithmClasskeySize	modeClasss   &&&&   r/   rb   SSHCiphers._getCipher   sa     .2^^C-@*!>!3x=)b9>449:;#%
 	
r1   c               $    V ^8  d   QhRRRRRR/# )   macr4   r5   returnz@tuple[None, Literal[b''], Literal[b''], Literal[0]] | _MACParamsr6   )formats   "r/   __annotate__SSHCiphers.__annotate__   s$     " ""$"	I"r1   c                R   V P                   V,          pV'       g   R# V! 4       pVP                  pVP                  pVRV RWe,
          ,          ,           pVP                  \        P
                  4      pVP                  \        P                  4      p\        W7W34      p	W)n        V	# )a  
Gets a 4-tuple representing the message authentication code.
(<hash module>, <inner hash value>, <outer hash value>,
<digest size>)

@type mac: L{bytes}
@param mac: a key mapping into macMap

@type key: L{bytes}
@param key: the MAC key.

@rtype: L{bytes}
@return: The MAC components.
N    rP   )	macMapdigest_sizere   	translatehmactrans_36trans_5Cr3   r5   )
rZ   r~   r5   mod
hashObject
digestSize	blockSizeirn   results
   &&&       r/   rg   SSHCiphers._getMAC   s    " kk#&& U
++
))	
 +:'Y-C"DEMM$--(MM$--(SQ34
r1   c                8    V P                   P                  V4      # )z
Encrypt some data.

@type blocks: L{bytes}
@param blocks: The data to encrypt.

@rtype: L{bytes}
@return: The encrypted data.
)rc   updaterZ   blockss   &&r/   encryptSSHCiphers.encrypt        ~~$$V,,r1   c                8    V P                   P                  V4      # )z
Decrypt some data.

@type blocks: L{bytes}
@param blocks: The data to decrypt.

@rtype: L{bytes}
@return: The decrypted data.
)rf   r   r   s   &&r/   decryptSSHCiphers.decrypt   r   r1   c                   V P                   ^ ,          '       g   R# \        P                  ! RV4      V,           p\        P                  ! V P                   P
                  W P                   ^ ,          4      P                  4       # )a  
Create a message authentication code (MAC) for the given packet using
the outgoing MAC values.

@type seqid: L{int}
@param seqid: The sequence ID of the outgoing packet.

@type data: L{bytes}
@param data: The data to create a MAC for.

@rtype: L{str}
@return: The serialized MAC.
r1   >L)rX   structpackr   HMACr5   digest)rZ   seqidr.   s   &&&r/   makeMACSSHCiphers.makeMAC   sS     {{1~~{{4'$.yy$A?FFHHr1   c                :   V P                   ^ ,          '       g   VR8H  # \        P                  ! RV4      V,           p\        P                  ! V P                   P
                  W P                   ^ ,          4      P                  4       p\        P                  ! W44      # )a6  
Verify an incoming MAC using the incoming MAC values.

@type seqid: L{int}
@param seqid: The sequence ID of the incoming packet.

@type data: L{bytes}
@param data: The packet data to verify.

@type mac: L{bytes}
@param mac: The MAC sent with the packet.

@rtype: L{bool}
@return: C{True} if the MAC is valid.
r1   r   )rY   r   r   r   r   r5   r   compare_digest)rZ   r   r.   r~   outers   &&&& r/   verifySSHCiphers.verify  sj      zz!}}#:{{4'$.		$**..$

1>EEG""3..r1   )rV   rf   rU   rc   rR   rY   rT   rQ   rX   rS   rW   )r7   r8   r9   r:   r;   r   	TripleDESr   CBCAESCTRrt   r   r   r   r   r   r   r_   ro   rb   rg   r   r   r   r   r=   r6   r1   r/   r?   r?   W   s   , 	j**B		:
EII6
EII6
EII6
EII6
EII6
EII6j**B		:$599%
I 	&&&dSF	)2,
("H
-
-I&/r1   r?   c            	     >   . p . ROpV F~  p\         P                  V,          w  r4p \        V! RV,          4      V! RVP                  ^,          ,          4      \	        4       R7      P                  4        V P                  V4       K  	  V #   \         d     K  i ; i)z
Build a list of ciphers that are supported by the backend in use.

@return: a list of supported ciphers.
@rtype: L{list} of L{str}
    rr   )rF   rA   rE   rB   rD   rC   rG   r@   )r?   rt   r   re   r   rc   appendr   )supportedCipherscscipherrx   ry   rz   s         r/   _getSupportedCiphersr     s     	
B -7-A-A&-I*		,tg~.$.";";q"@AB') ik ##F+  	 $ 		s   ABBBc                     ] tR tRt$ Rt]! 4       tRtR]P                  ! R4      ,           t
RtR],           R,           ]
,           R	,           ],           P                  4       t]! 4       t. RMOt]P$                  ! 4       t. t] F5  t]P-                  R
4      RN8w  g   K  ]]P/                  R
R4      .,          tK7  	  ]. ROO,          t]! 4       P3                  4       '       d   ]P5                  R4       RR.tRPtRQtRtRtRt ^ t!^ t"Rt#Rt$Rt%R]&R&   Rt'R]&R&   Rt(Rt)Rt*](t+Rt,Rt-Rt.Rt// t0R]&R&   R]&R&   R]&R&   R ]&R!&   RRR" R# llt1R$ t2R% t3R& t4R' t5R( t6R) t7R* t8R+ t9R, t:R- t;]<R. 4       t=]=P|                  R/ 4       t=R0 t?R1 t@R2 tAR3 tBR4 tCR5 tDR6 tERSR7 ltFR8 tGR9 tHR: tIR; tJR< tKR= tLR> R? ltMR@ RA ltNRB tORTRC ltPRTRD ltQRE tRRF tSRG tTRH tURI tVRJ tWRK tXRLtYR# )USSHTransportBasei=  as  
Protocol supporting basic SSH functionality: sending/receiving packets and
message dispatch.  To connect to or run a server, you must use
SSHClientTransport or SSHServerTransport.

@ivar protocolVersion: A string representing the version of the SSH
    protocol we support.  Currently defaults to '2.0'.

@ivar version: A string representing the version of the server or client.
    Currently defaults to 'Twisted'.

@ivar comment: An optional string giving more information about the server
    or client.

@ivar supportedCiphers: A list of strings representing the encryption
    algorithms supported, in order from most-preferred to least.

@ivar supportedMACs: A list of strings representing the message
    authentication codes (hashes) supported, in order from most-preferred
    to least.  Both this and supportedCiphers can include 'none' to use no
    encryption or authentication, but that must be done manually,

@ivar supportedKeyExchanges: A list of strings representing the key
    exchanges supported, in order from most-preferred to least.

@ivar supportedPublicKeys: A list of strings representing the public key
    algorithms supported, in order from most-preferred to least.

@ivar supportedCompressions: A list of strings representing compression
    types supported, from most-preferred to least.

@ivar supportedLanguages: A list of strings representing languages
    supported, from most-preferred to least.

@ivar supportedVersions: A container of strings representing supported ssh
    protocol version numbers.

@ivar isClient: A boolean indicating whether this is a client or server.

@ivar gotVersion: A boolean indicating whether we have received the version
    string from the other side.

@ivar buf: Data we've received but hasn't been parsed into a packet.

@ivar outgoingPacketSequence: the sequence number of the next packet we
    will send.

@ivar incomingPacketSequence: the sequence number of the next packet we are
    expecting from the other side.

@ivar outgoingCompression: an object supporting the .compress(str) and
    .flush() methods, or None if there is no outgoing compression.  Used to
    compress outgoing data.

@ivar outgoingCompressionType: A string representing the outgoing
    compression type.

@ivar incomingCompression: an object supporting the .decompress(str)
    method, or None if there is no incoming compression.  Used to
    decompress incoming data.

@ivar incomingCompressionType: A string representing the incoming
    compression type.

@ivar ourVersionString: the version string that we sent to the other side.
    Used in the key exchange.

@ivar otherVersionString: the version string sent by the other side.  Used
    in the key exchange.

@ivar ourKexInitPayload: the MSG_KEXINIT payload we sent.  Used in the key
    exchange.

@ivar otherKexInitPayload: the MSG_KEXINIT payload we received.  Used in
    the key exchange

@ivar sessionID: a string that is unique to this SSH session.  Created as
    part of the key exchange, sessionID is used to generate the various
    encryption and authentication keys.

@ivar service: an L{SSHService} instance, or None.  If it's set to an
    object, it's the currently running service.

@ivar kexAlg: the agreed-upon key exchange algorithm.

@ivar keyAlg: the agreed-upon public key type for the key exchange.

@ivar currentEncryptions: an SSHCiphers instance.  It represents the
    current encryption and authentication options for the transport.

@ivar nextEncryptions: an SSHCiphers instance.  Held here until the
    MSG_NEWKEYS messages are exchanged, when nextEncryptions is
    transitioned to currentEncryptions.

@ivar first: the first bytes of the next packet.  In order to avoid
    decrypting data twice, the first bytes are decrypted and stored until
    the whole packet is available.

@ivar _keyExchangeState: The current protocol state with respect to key
    exchange.  This is either C{_KEY_EXCHANGE_NONE} if no key exchange is
    in progress (and returns to this value after any key exchange
    completqes), C{_KEY_EXCHANGE_REQUESTED} if this side of the connection
    initiated a key exchange, and C{_KEY_EXCHANGE_PROGRESSING} if the other
    side of the connection initiated a key exchange.  C{_KEY_EXCHANGE_NONE}
    is the initial value (however SSH connections begin with key exchange,
    so it will quickly change to another state).

@ivar _blockedByKeyExchange: Whenever C{_keyExchangeState} is not
    C{_KEY_EXCHANGE_NONE}, this is a C{list} of pending messages which were
    passed to L{sendPacket} but could not be sent because it is not legal
    to send them while a key exchange is in progress.  When the key
    exchange completes, another attempt is made to send these messages.

@ivar _peerSupportsExtensions: a boolean indicating whether the other side
    of the connection supports RFC 8308 extension negotiation.

@ivar peerExtensions: a dict of extensions supported by the other side of
    the connection.
   2.0s   Twisted_asciir1      SSH-   -r   s   ecdh   ecdsas   ssh-ed25519rH      zlibFNzbytes | None	sessionIDzSSHService | Noneservice_KEY_EXCHANGE_NONE_KEY_EXCHANGE_REQUESTED_KEY_EXCHANGE_PROGRESSINGs
   ext-info-cs
   ext-info-szDict[bytes, bytes]peerExtensionsr)   factoryobjectavatarzCallable[[], None]logoutFunctionc                    V ^8  d   QhRRRR/# )r}   reasonzFailure | Noner   Noner6   )r   s   "r/   r   SSHTransportBase.__annotate__  s     * *^ *t *r1   c                    V P                   '       d   V P                   P                  4        \        V R4      '       d   V P                  4        V P                  P                  R4       R# )z
When the underlying connection is closed, stop the running service (if
any), and log out the avatar (if any).

@type reason: L{twisted.python.failure.Failure}
@param reason: The cause of the connection being closed.
r   zconnection lostN)r   serviceStoppedhasattrr   _loginfo)rZ   r   s   &&r/   connectionLostSSHTransportBase.connectionLost  sG     <<<LL'')4""!		()r1   c                    V P                   P                  V P                  R,           4       \        RRRR4      V n        V P                  P                  RRRRRR4       V P                  4        R# )zh
Called when the connection is made to the other side.  We sent our
version and the MSG_KEXINIT packet.
s   
rH   r1   N)	transportwriteourVersionStringr?   currentEncryptionsro   sendKexInitrZ   s   &r/   connectionMadeSSHTransportBase.connectionMade  s^    
 	T22W<=",Wgw"P''S#sCEr1   c                   V P                   V P                  8w  d   \        RV P                   : 24      h\        V P                  4      pTP                  V P                  '       d   V P                  MV P                  4       RP                  \        \        34      \        P                  ! ^4      \        RP                  V4      4      \        RP                  V P                  4      4      \        RP                  V P                   4      4      \        RP                  V P                   4      4      \        RP                  V P"                  4      4      \        RP                  V P"                  4      4      \        RP                  V P$                  4      4      \        RP                  V P$                  4      4      \        RP                  V P&                  4      4      \        RP                  V P&                  4      4      R.4      V n        V P+                  \        V P(                  R,          4       V P,                  V n         . V n        R# )a  
Send a I{KEXINIT} message to initiate key exchange or to respond to a
key exchange initiated by the peer.

@raise RuntimeError: If a key exchange has already been started and it
    is not appropriate to send a I{KEXINIT} message at this time.

@return: L{None}
z0Cannot send KEXINIT while key exchange state is r1      ,s           NNN)_keyExchangeStater   RuntimeErrorlistsupportedKeyExchangesr   isClient_EXT_INFO_C_EXT_INFO_Sjoinr4   MSG_KEXINITr%   secureRandomr   supportedPublicKeysr   supportedMACssupportedCompressionssupportedLanguagesourKexInitPayload
sendPacketr   _blockedByKeyExchange)rZ   r   s   & r/   r   SSHTransportBase.sendKexInit   s    !!T%<%<<)), 
 !%T%?%? @ 	$$ $D43C3C	
 "%{n%&&r*499234499T5567499T2234499T2234499T//01499T//01499T7789499T7789499T4456499T4456'"
" 	T%;%;B%?@!%!=!=%'"r1   c                    ^Tu;8:  d   ^8:  d   M MV\         \        \        39  # ^Tu;8:  d   ^8:  d   M M
V\        39  # ^Tu;8*  ;'       d    ^18*  # u # )aZ  
Determine if the given message type may be sent while key exchange is
in progress.

@param messageType: The type of message
@type messageType: L{int}

@return: C{True} if the given type of message may be sent while key
    exchange is in progress, C{False} if it may not.
@rtype: L{bool}

@see: U{http://tools.ietf.org/html/rfc4253#section-7.1}
)MSG_SERVICE_REQUESTMSG_SERVICE_ACCEPTMSG_EXT_INFOr   )rZ   messageTypes   &&r/   _allowedKeyExchangeMessageType/SSHTransportBase._allowedKeyExchangeMessageTypeR  sa      !r!#"'  
 ""{n44[&&B&&&&r1   c                t   V P                   V P                  8w  d6   V P                  V4      '       g   V P                  P	                  W34       R# \        V34      V,           pV P                  '       d<   V P                  P                  V4      V P                  P                  ^4      ,           pV P                  P                  p^\        V4      ,           pW4V,          ,
          pV^8  d	   WS,           p\        P                  ! RWE,           ^,
          V4      V,           \        P                  ! V4      ,           pV P                  P!                  V4      V P                  P#                  V P$                  V4      ,           pV P&                  P)                  V4       V ;P$                  ^,          un        R# )a  
Sends a packet.  If it's been set up, compress the data, encrypt it,
and authenticate it before sending.  If key exchange is in progress and
the message is not part of key exchange, queue it to be sent later.

@param messageType: The type of the packet; generally one of the
                    MSG_* values.
@type messageType: L{int}
@param payload: The payload for the message.
@type payload: L{str}
N!LB)r   r   r   r   r   r4   outgoingCompressioncompressflushr   rU   lenr   r   r%   r   r   r   outgoingPacketSequencer   r   )rZ   r   payloadbs	totalSizelenPadpacket	encPackets   &&&     r/   r   SSHTransportBase.sendPacketl  sg    !!T%<%<<66{CC**11;2HI''1###..77((..q12G $$11G$	2~&A:[FKKy1A5v>$$V,- 	
 ++33
##++D,G,GPQ	 	Y'##q(#r1   c           
        V P                   P                  pV P                   P                  p\        V P                  4      V8  d   R# \        V R4      '       g*   V P                   P                  V P                  RV 4      pMV P                  pV =\        P                  ! RVR,          4      w  rEVR8  d%   V P                  \        \        RV 24      4       R# \        V P                  4      V^,           V,           8  d	   W0n        R# V^,           V,          ^ 8w  d@   V P                  \        \        RV^,           W^,           V,          3,          4      4       R# V P                  R^V,            V P                  ^V,           R uq`n        W0P                   P                  WaR 4      ,           p\        V4      ^V,           8w  d   V P                  \        R4       R# V'       dh   V P                  RV V P                  VR uqn        V P                   P                  V P                  Wx4      '       g   V P                  \        R	4       R# V^V)  p	V P                   '       d    V P                   P#                  V	4      p	V ;P                  ^,          un        V	#   \$         d6    T P&                  P)                  R
4       T P                  \*        R4        R# i ; i)z
Try to return a decrypted, authenticated, and decompressed packet
out of the buffer.  If there is not enough data, return None.

@rtype: L{str} or L{None}
@return: The decoded packet, if any.
Nfirstr   :N   Ni   zbad packet length zbad packet mod (%i%%%i == %i)s   bad decryptions   bad MACzError decompressing payloads   compression error)r   rV   rW   r   bufr   r   r  r   unpacksendDisconnectDISCONNECT_PROTOCOL_ERRORr'   r   incomingPacketSequenceDISCONNECT_MAC_ERRORincomingCompression
decompress	Exceptionr   failureDISCONNECT_COMPRESSION_ERROR)
rZ   r   msr  	packetLen
paddingLenencDatar  macDatar   s
   &         r/   	getPacketSSHTransportBase.getPacket  sv    $$11$$55txx=2tW%%++33DHHSbMBEJJE
 &eU2Y ?	w) 29+>? txx=9q=2--JMR1$)3 1}bq=B*>?@  HH_q9}5txxI7P0088FFv;!i-' 9;LM $"txx}GX**11++V  ##$8*EJ;'###22==gF 	##q(#  		!!"?@##$@BVW	s   ,J" "<K"!K"c                @    V P                  \        RV,           4       R# )z
Called when an unsupported version of the ssh protocol is received from
the remote endpoint.

@param remoteVersion: remote ssh protocol version which is unsupported
    by us.
@type remoteVersion: L{str}
s   bad version N)r  )DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED)rZ   remoteVersions   &&r/   _unsupportedVersionReceived,SSHTransportBase._unsupportedVersionReceived  s     	57V	
r1   c                l   V P                   V,           V n         V P                  '       Eg5   \        V P                   4      R8  d   V P                  \        R4       R# V P                   P                  RV P                   P                  R4      4      R8X  d   R# V P                   P                  R4      pV F  pVP                  R4      '       g   K  RV n        VP                  R4      V n	        VP                  R4      ^,          pW@P                  9  d   V P                  V4        R# VP                  V4      pRP                  W%^,           R 4      V n         K  	  V P                  4       pV'       d=   \        VR	,          4      pV P!                  WvR
,          4       V P                  4       pKD  R# )z
First, check for the version string (SSH-2.0-*).  After that has been
received, this method adds data to the buffer, and pulls out any
packets.

@type data: L{bytes}
@param data: The data that was received.
i   sK   Peer version string longer than 4KB. Preventing a denial of service attack.N   
r   T   r   rO   r   Nr   )r	  
gotVersionr   r  DISCONNECT_CONNECTION_LOSTfindsplit
startswithrstripotherVersionStringsupportedVersionsr  indexr   r  orddispatchMessage)rZ   r.   linespr  r   r  
messageNums   &&      r/   dataReceivedSSHTransportBase.dataReceived  sJ    88d?488}t###.>
 xx}}UDHHMM'$:;rA HHNN5)E<<((&*DO /0hhuoD+$%GGDM!$4M$,B,BB88GAA$zz%A.9DH  !VC[)J  BZ8^^%F r1   c                   V^28  dn   V\         9   dc   \         V,          R,          p\        V RV 2R4      pVe   V! V4       R# V P                  P                  RVVR7       V P	                  4        R# V P
                  '       d   V P
                  P                  W4       R# V P                  P                  RVVR7       V P	                  4        R# )z
Send a received message to the appropriate method.

@type messageNum: L{int}
@param messageNum: The message number.

@type payload: L{bytes}
@param payload: The message payload.
   NNssh_Nz*couldn't handle {messageType}: {payload!r})r   r   z)couldn't handle {messageNum}: {payload!r})r2  r   )messagesgetattrr   debugsendUnimplementedr   packetReceived)rZ   r2  r   r   fs   &&&  r/   r/   SSHTransportBase.dispatchMessage  s     ?zX5":.r2K[M2D9A}'
		@ +#   
 &&(\\\LL''
<IIOO;%  
 ""$r1   c                ^    \         P                  ! V P                  P                  4       4      # )z
Returns an L{SSHTransportAddress} corresponding to the other (peer)
side of this transport.

@return: L{SSHTransportAddress} for the peer
@rtype: L{SSHTransportAddress}
@since: 12.1
)r   SSHTransportAddressr   getPeerr   s   &r/   rB  SSHTransportBase.getPeer+  "     **4>>+A+A+CDDr1   c                ^    \         P                  ! V P                  P                  4       4      # )z
Returns an L{SSHTransportAddress} corresponding to the this side of
transport.

@return: L{SSHTransportAddress} for the peer
@rtype: L{SSHTransportAddress}
@since: 12.1
)r   rA  r   getHostr   s   &r/   rF  SSHTransportBase.getHost6  rD  r1   c                    V P                   # )zC
The key exchange algorithm name agreed between client and server.
_kexAlgr   s   &r/   kexAlgSSHTransportBase.kexAlgA  s    
 ||r1   c                    Wn         R# )z&
Set the key exchange algorithm name.
NrI  )rZ   values   &&r/   rK  rL  H  s	    
 r1   c           
        \        \        34      V,           V n        \        VR,          ^
4      pVRR
 VR
,          rCR V 4       w
  ppppp	p
ppppWV.pWyV.pV P                  '       d   TTppV P
                  V P                  V P                  V P                  V P                  V P                  V P                  V P                  3pWVV^ ,          V^ ,          V^,          V^,          V^,          V^,          3pV P                  '       d   TTpp\        V^ ,          V^ ,          4      V n        \        V^,          V^,          4      V n        \        \        V^,          V^,          4      \        V^,          V^,          4      \        V^,          V^,          4      \        V^,          V^,          4      4      V n        \        V^,          V^,          4      V n        \        V^,          V^,          4      V n        RV P                  V P                  V P                  V P                   39   g(   V P                  V P"                  V P$                  39   d   V P'                  \(        R4       R# RV P                  P*                  P-                  4       9   d   V P'                  \(        R4       R# V P                  '       d   V P$                  MV P"                  V9   V n        V P0                  P3                  RV P                  V P                  R7       V P0                  P3                  RV P                  P4                  V P                  P6                  V P                  R7       V P0                  P3                  R	V P                  P8                  V P                  P:                  V P                   R7       V P<                  V P>                  8X  d   V P@                  V n        MV PC                  4        WVV3# )a  
Called when we receive a MSG_KEXINIT message.  Payload::
    bytes[16] cookie
    string keyExchangeAlgorithms
    string keyAlgorithms
    string incomingEncryptions
    string outgoingEncryptions
    string incomingAuthentications
    string outgoingAuthentications
    string incomingCompressions
    string outgoingCompressions
    string incomingLanguages
    string outgoingLanguages
    bool firstPacketFollows
    unit32 0 (reserved)

Starts setting up the key exchange, keys, encryptions, and
authentications.  Extended by ssh_KEXINIT in SSHServerTransport and
SSHClientTransport.

@type packet: L{bytes}
@param packet: The message data.

@return: A L{tuple} of negotiated key exchange algorithms, key
algorithms, and unhandled data, or L{None} if something went wrong.
:   NNNc              3  B   "   T F  qP                  R 4      x  K  	  R# 5i)r   N)r(  ).0ss   & r/   	<genexpr>/SSHTransportBase.ssh_KEXINIT.<locals>.<genexpr>  s     ,GqWWT]]Gs   s   couldn't match all kex partsz%kex alg={kexAlg!r} key alg={keyAlg!r})rK  keyAlgz)outgoing: {cip!r} {mac!r} {compression!r})rv   r~   compressionz)incoming: {cip!r} {mac!r} {compression!r}r$  )"r4   r   otherKexInitPayloadr    r   r   r   r   r   r   r   rK  rV  r?   nextEncryptionsoutgoingCompressionTypeincomingCompressionTyper   r   r  DISCONNECT_KEY_EXCHANGE_FAILED__dict__values_peerSupportsExtensionsr   r;  rQ   rS   rR   rT   r   r   r   r   )rZ   r  kstringsrestkexAlgskeyAlgsencCSencSCmacCSmacSCcompCScompSClangCSlangSCoutsinsserverclients   &&                 r/   ssh_KEXINITSSHTransportBase.ssh_KEXINIT]  sw   6 $)+#86#A  &+r"#2" -G,	
 f%V$===T#D&&$$!!!!&&&&	
 DGSVT!Wc!fd1gsSTvV===#VFF&)VAY/&)VAY/)q	6!9%q	6!9%q	6!9%q	6!9%	 
 (+6!9fQi'@$'*6!9fQi'@$,,,,	 {{t//1A1ABB.0O 4''007799.0O  $D43C3C($ 			3;;;; 	 	

 			7$$//$$//44	 	 	
 			7$$..$$..44	 	 	
 !!T%A%AA%)%C%CD"%%r1   c                    \         P                  ! RVR,          4      ^ ,          p\        VR,          4      w  r4V P                  W#4       V P                  P                  4        R# )z
Called when we receive a MSG_DISCONNECT message.  Payload::
    long code
    string description

This means that the other side has disconnected.  Pass the message up
and disconnect ourselves.

@type packet: L{bytes}
@param packet: The message data.
r   Nr7  Nr6  N)r   r
  r    receiveErrorr   loseConnection)rZ   r  
reasonCodedescriptionfoos   &&   r/   ssh_DISCONNECTSSHTransportBase.ssh_DISCONNECT  sL     ]]44Q7
 ,*2%%'r1   c                    R# )z
Called when we receive a MSG_IGNORE message.  No payload.
This means nothing; we simply return.

@type packet: L{bytes}
@param packet: The message data.
Nr6   rZ   r  s   &&r/   
ssh_IGNORESSHTransportBase.ssh_IGNORE  s    r1   c                Z    \         P                  ! RV4      w  pV P                  V4       R# )z
Called when we receive a MSG_UNIMPLEMENTED message.  Payload::
    long packet

This means that the other side did not implement one of our packets.

@type packet: L{bytes}
@param packet: The message data.
r   N)r   r
  receiveUnimplemented)rZ   r  seqnums   && r/   ssh_UNIMPLEMENTED"SSHTransportBase.ssh_UNIMPLEMENTED  s$     MM$/	!!&)r1   c                    \        \        VR,          4      4      p\        VR,          ^4      w  r4pV P                  W#V4       R# )z
Called when we receive a MSG_DEBUG message.  Payload::
    bool alwaysDisplay
    string message
    string language

This means the other side has passed along some debugging info.

@type packet: L{bytes}
@param packet: The message data.
r#  r   N)boolr.  r    receiveDebug)rZ   r  alwaysDisplaymessagelangry  s   &&    r/   	ssh_DEBUGSSHTransportBase.ssh_DEBUG  s<     S-."6":q1s-$7r1   c                    \         P                  ! RVR,          4      w  pVR,          p/ p\        V4       F  p\        V^4      w  rVpWcV&   K  	  W0n        R# )a  
Called when we get a MSG_EXT_INFO message.  Payload::
    uint32 nr-extensions
    repeat the following 2 fields "nr-extensions" times:
      string extension-name
      string extension-value (binary)

@type packet: L{bytes}
@param packet: The message data.
r   rt  r6  N)r   r
  ranger    r   )rZ   r  numExtensions
extensions_extNameextValues   &&     r/   ssh_EXT_INFOSSHTransportBase.ssh_EXT_INFO  sY     "==vbz:
}%A(-fa(8%Gv"*w & )r1   c                    V P                   P                  RVP                  R7       V P                  '       d   V P                  P	                  4        Wn        Wn        V P                  P                  4        R# )z
Set our service to service and start it running.  If we were
running a service previously, stop it first.

@type service: C{SSHService}
@param service: The service to attach.
zstarting service {service!r})r   N)r   r;  namer   r   r   serviceStarted)rZ   r   s   &&r/   
setServiceSSHTransportBase.setService!  sQ     			6M<<<LL'') ##%r1   c                    T P                  \        V'       d   RMR\        V4      ,           \        V4      ,           4       R# )a?  
Send a debug message to the other side.

@param message: the message to send.
@type message: L{str}
@param alwaysDisplay: if True, tell the other side to always
                      display this message.
@type alwaysDisplay: L{bool}
@param language: optionally, the language the message is in.
@type language: L{str}
   r   N)r   	MSG_DEBUGr   )rZ   r  r  languages   &&&&r/   	sendDebugSSHTransportBase.sendDebug0  s+     	ER[H2h<W	
r1   c                D    V P                  \        \        V4      4       R# )z
Send a message that will be ignored by the other side.  This is
useful to fool attacks based on guessing packet sizes in the
encrypted stream.

@param message: data to send with the message
@type message: L{str}
N)r   
MSG_IGNOREr   )rZ   r  s   &&r/   
sendIgnoreSSHTransportBase.sendIgnore@  s     	
BwK0r1   c                t    V P                   pV P                  \        \        P                  ! RV4      4       R# )zK
Send a message to the other side that the last packet was not
understood.
z!LN)r  r   MSG_UNIMPLEMENTEDr   r   rZ   r  s   & r/   r<  "SSHTransportBase.sendUnimplementedK  s)    
 ,,)6;;tV+DEr1   c                   V P                  \        \        P                  ! RV4      \	        V4      ,           \	        R4      ,           4       V P
                  P                  RVVR7       V P                  P                  4        R# )a  
Send a disconnect message to the other side and then disconnect.

@param reason: the reason for the disconnect.  Should be one of the
               DISCONNECT_* values.
@type reason: L{int}
@param desc: a descrption of the reason for the disconnection.
@type desc: L{str}
r   r1   z;Disconnecting with error, code {code}
reason: {description}coderx  N)	r   MSG_DISCONNECTr   r   r   r   r   r   rv  )rZ   r   descs   &&&r/   r  SSHTransportBase.sendDisconnectS  s`     	D&(ABtH(LrRUw(VW		J 	 	

 	%%'r1   c                .   V P                   '       d}   RP                  \        P                  ! R\	        V4      4      .V UUu. uF   w  r#\        V4      \        V4      ,           NK"  	  upp,           4      pV P                  \        V4       R# R# u uppi )z
Send an RFC 8308 extension advertisement to the remote peer.

Nothing is sent if the peer doesn't support negotiations.
@type extensions: L{list} of (L{bytes}, L{bytes})
@param extensions: a list of (extension-name, extension-value) pairs.
r1   r   N)r_  r   r   r   r   r   r   r   )rZ   r  r  rN  r   s   &&   r/   sendExtInfoSSHTransportBase.sendExtInfoe  sx     '''hhT3z?34;EF:KD2d8bi'':FGG OOL'2 ( Gs   &Bc                <   \         P                  ! V P                  V P                  4      pVP	                  \        4       4      pVP                  4       V n        V P                  P                  4       P                  4       P                  p\        V4      V n        R# )z
Prepares for a Diffie-Hellman key agreement exchange.

Creates an ephemeral keypair in the group defined by (self.g,
self.p) and stores it.
N)r   DHParameterNumbersr1  g
parametersr   generate_private_keydhSecretKey
public_keypublic_numbersyr   dhSecretKeyPublicMP)rZ   numbersr  r  s   &   r/   _startEphemeralDH"SSHTransportBase._startEphemeralDHt  sq     ''7''(9:
%::<'')88:<<#%a5 r1   c                
   \         P                  ! V\         P                  ! V P                  V P                  4      4      P                  \        4       4      pV P                  P                  V4      pV =VP                  R4      p\        VR,          4      pV^,          '       d7   \        P                  ! R\        V4      ^,           4      R,           pWS,           # \        P                  ! R\        V4      4      pWS,           # )z
Completes the Diffie-Hellman key agreement started by
_startEphemeralDH, and forgets the ephemeral secret key.

@type remoteDHpublicKey: L{int}
@rtype: L{bytes}
@return: The new shared secret, in SSH C{mpint} format.

r   r#  r   )r   DHPublicNumbersr  r1  r  r  r   r  exchangelstripr.  r   r   r   )rZ   remoteDHpublicKey	remoteKeysecretchprefixs   &&    r/   _finishEphemeralDH#SSHTransportBase._finishEphemeralDH  s     &&r44TVVTVVD

*_&
' 	 !!**95 w'99[[s6{Q7'AF  [[s6{3Fr1   c               (    V ^8  d   QhRRRRRRRR/# )r}   cr4   sharedSecretexchangeHashr   r6   )r   s   "r/   r   r     s(     ! ! !e !5 !U !r1   c                   \         P                  ! V P                  4      pV P                  f   Q R4       hV! W#,           V,           V P                  ,           4      P	                  4       pV! W#,           V,           4      P	                  4       pV! W#,           V,           V,           4      P	                  4       pV! W#,           V,           V,           V,           4      P	                  4       pWV,           V,           V,           # )z
Get one of the keys for authentication/encryption.

@param c: The letter identifying which key this is.

@param sharedSecret: The shared secret K.

@param exchangeHash: The hash H from key exchange.

@return: The derived key.
z*session ID must already have been assigned)r   getHashProcessorrK  r   r   )	rZ   r  r  r  hashProcessork1k2k3k4s	   &&&&     r/   _getKeySSHTransportBase._getKey  s     --dkk:~~)W+WW)<6:T^^KLSSU<6;<CCE<6;b@AHHJ<6;b@2EFMMOw|b  r1   c               $    V ^8  d   QhRRRRRR/# r}   r  r4   r  r   r   r6   )r   s   "r/   r   r     s!     * *e *5 *T *r1   c           	        V P                   '       g   W n         V P                  RW4      pV P                  RW4      pV P                  RW4      pV P                  RW4      pV P                  RW4      pV P                  RW4      pWFV.p	W5V.p
V P                  '       d   YrV P                  P	                  V	^ ,          V	^,          V
^ ,          V
^,          V	^,          V
^,          4       V P                  \        R4       R# )	a  
Set up the keys for the connection and sends MSG_NEWKEYS when finished.

@param sharedSecret: a secret string agreed upon using a Diffie-
    Hellman exchange, so it is only shared between the server and the
    client.

@param exchangeHash: A hash of various data known by both sides.
   A   B   C   D   E   Fr1   N)r   r  r   rY  ro   r   MSG_NEWKEYS)rZ   r  r  initIVCSinitIVSCencKeyCSencKeySC
integKeyCS
integKeySCrm  rn  s   &&&        r/   	_keySetupSSHTransportBase._keySetup  s     ~~~)N<<lA<<lA<<lA<<lA\\$C
\\$C
J/:.===#$$T!Wd1gs1vs1vtAwPSTUPVWS)r1   c                   V P                   P                  R4       V P                  V n        V P                  R8X  d   \
        P                  ! ^4      V n        V P                  R8X  d   \
        P                  ! 4       V n
        V P                  V n        V P                  pRV n        V F  w  r#V P                  W#4       K  	  R# )a  
Called back by a subclass once a I{MSG_NEWKEYS} message has been
received.  This indicates key exchange has completed and new encryption
and compression parameters should be adopted.  Any messages which were
queued during key exchange will also be flushed.
zNEW KEYSr   N)r   r;  rY  r   rZ  zlibcompressobjr   r[  decompressobjr  r   r   r   r   )rZ   r9  r   r   s   &   r/   _newKeysSSHTransportBase._newKeys  s     			
#"&"6"6''72'+'7'7':D$''72'+'9'9';D$!%!8!8--%)"$, KOOK1 %-r1   c                    VR8X  d   V P                   P                  R8g  # VR8X  d   V P                   P                  R8g  # VR8X  d+   V P                  R4      ;'       d    V P                  R4      # \	        R4      h)z
Check if the connection is encrypted in the given direction.

@type direction: L{str}
@param direction: The direction: one of 'out', 'in', or 'both'.

@rtype: L{bool}
@return: C{True} if it is encrypted.
outrH   inboth(direction must be "out", "in", or "both")r   rQ   rR   isEncrypted	TypeErrorrZ   	directions   &&r/   r  SSHTransportBase.isEncrypted  sz     **55@@$**44??& ##D)EEd.>.>u.EEFGGr1   c                    VR8X  d   V P                   P                  R8g  # VR8X  d   V P                   P                  R8g  # VR8X  d+   V P                  R4      ;'       d    V P                  R4      # \	        R4      h)z
Check if the connection is verified/authentication in the given direction.

@type direction: L{str}
@param direction: The direction: one of 'out', 'in', or 'both'.

@rtype: L{bool}
@return: C{True} if it is verified.
r  rH   r  r  r  )r   rS   rT   
isVerifiedr  r  s   &&r/   r  SSHTransportBase.isVerified  sv     **55@@$**44??& ??4(CCT__U-CCFGGr1   c                2    V P                  \        R4       R# )zV
Lose the connection to the other side, sending a
DISCONNECT_CONNECTION_LOST message.
s   user closed connectionN)r  r&  r   s   &r/   rv  SSHTransportBase.loseConnection  s    
 	68QRr1   c                B    V P                   P                  RVVR7       R# )a;  
Called when we receive a disconnect error message from the other
side.

@param reasonCode: the reason for the disconnect, one of the
                   DISCONNECT_ values.
@type reasonCode: L{int}
@param description: a human-readable description of the
                    disconnection.
@type description: L{str}
z3Got remote error, code {code}
reason: {description}r  N)r   error)rZ   rw  rx  s   &&&r/   ru  SSHTransportBase.receiveError  s"     			B# 	 	
r1   c                @    V P                   P                  RVR7       R# )z
Called when we receive an unimplemented packet message from the other
side.

@param seqnum: the sequence number that was not understood.
@type seqnum: L{int}
z)other side unimplemented packet #{seqnum})r  N)r   warnr  s   &&r/   r  %SSHTransportBase.receiveUnimplemented"  s     			B6Rr1   c                T    V'       d    V P                   P                  RVR7       R# R# )a<  
Called when we receive a debug message from the other side.

@param alwaysDisplay: if True, this message should always be
                      displayed.
@type alwaysDisplay: L{bool}
@param message: the debug message
@type message: L{str}
@param lang: optionally the language the message is in.
@type lang: L{str}
zRemote Debug Message: {message})r  N)r   r;  )rZ   r  r  r  s   &&&&r/   r  SSHTransportBase.receiveDebug,  s!     IIOO=wOO r1   c                   V P                   P                  R4      '       dP    \        P                  RV P                   R,          ,           ,          p\        P                  ! T\        4       4      # V P                   R9   d   \        P                  P                  4       # \        RP                  V P                   4      4      h  \         d    \        R4      hi ; i)a  
Generate an private key for ECDH key exchange.

@rtype: The appropriate private key type matching C{self.kexAlg}:
    L{ec.EllipticCurvePrivateKey} for C{ecdh-sha2-nistp*}, or
    L{x25519.X25519PrivateKey} for C{curve25519-sha256}.
@return: The generated private key.
   ecdh-sha2-nistpr   r6  
unused-keyz3Cannot generate elliptic curve private key for {!r}s   curve25519-sha256s   curve25519-sha256@libssh.org)rK  r)  r   _curveTableKeyErrorr   r   r  r   r   X25519PrivateKeygenerater   )rZ   curves   & r/   _generateECPrivateKey&SSHTransportBase._generateECPrivateKey;  s     ;;!!"4559((DKKO)CD **5/2CDD[[SS**3355&ELLKK   9*<889s   /C Cc                   V P                   P                  R4      '       dC   VP                  \        P                  P
                  \        P                  P                  4      # V P                   R9   dC   VP                  \        P                  P                  \        P                  P                  4      # \        RV P                   : 24      h)aJ  
Encode an elliptic curve public key to bytes.

@type ecPub: The appropriate public key type matching
    C{self.kexAlg}: L{ec.EllipticCurvePublicKey} for
    C{ecdh-sha2-nistp*}, or L{x25519.X25519PublicKey} for
    C{curve25519-sha256}.
@param ecPub: The public key to encode.

@rtype: L{bytes}
@return: The encoded public key.
r  z,Cannot encode elliptic curve public key for r	  )
rK  r)  public_bytesr   EncodingX962PublicFormatUncompressedPointRawr   )rZ   ecPubs   &&r/   _encodeECPublicKey#SSHTransportBase._encodeECPublicKeyT  s     ;;!!"455%%&&++**<<  [[SS%%&&**M,F,F,J,J  '>t{{oN r1   c                D   V P                   P                  R4      '       dv    \        P                  RV P                   R,          ,           ,          p\        P                  P                  Y24      pTP                  \        P                  ! 4       T4      pMfV P                   R9   d2   \        P                  P                  V4      pVP                  V4      pM$\        RP                  V P                   4      4      h\        V4      #   \         d    \        R4      hi ; i)aw  
Generate a shared secret for ECDH key exchange.

@type ecPriv: The appropriate private key type matching
    C{self.kexAlg}: L{ec.EllipticCurvePrivateKey} for
    C{ecdh-sha2-nistp*}, or L{x25519.X25519PrivateKey} for
    C{curve25519-sha256}.
@param ecPriv: Our private key.

@rtype: L{bytes}
@return: The generated shared secret, as an SSH multiple-precision
    integer.
r  r   r6  r  z5Cannot generate elliptic curve shared secret for {!r}r	  )rK  r)  r   r
  r  r   r   EllipticCurvePublicKeyfrom_encoded_pointr  ECDHr   X25519PublicKeyfrom_public_bytesr   r0   )rZ   ecPrivtheirECPubBytesr  
theirECPubr  s   &&&   r/   _generateECSharedSecret(SSHTransportBase._generateECSharedSecreto  s     ;;!!"4559((DKKO)CD 22EEJ "??2779jAL[[SS//AA/RJ!??:6L&GNNKK  L))#  9*<889s   /D D)r   rJ  r   r_  r	  r   r  r  r  r%  r  r[  rK  rV  rY  rX  r+  r   r   rZ  r   r   r   )rI   rJ   rK   rL   rM   r$  )   rsa-sha2-512   rsa-sha2-256   ssh-rsas   ssh-dssr6   )s   1.99r   )N)Fr1   )r  )Zr7   r8   r9   r:   r;   r$   r   protocolVersiontwisted_versionencodeversioncommentstripr   r   r   r   r   getSupportedKeyExchangesr   r   eckeyr'  replacer   ed25519_supportedr   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  r3  r/  rB  rF  propertyrK  setterrq  rz  r~  r  r  r  r  r  r  r<  r  r  r  r  r  r  r  r  r  rv  ru  r  r  r  r  r$  r=   r6   r1   r/   r   r   =  s   vp 8DOO227;;GG/!D(72T9GCeg  ,-M !99; '::g"$EMM'8$D#EE ' UU**,,"">2$g.)HJ
C"I|"!%G% . 8 !< +   K  K#)+N&+ N&&*0(d'4%)N<|
+&Z%@	E	E   ]] (x&t("*8 )&&
 	1F($3)<!(*22(H&H&S
$SP26"*r1   r   c                      ] tR tRtRtRt^ tR R ltR R ltR R	 lt	R
 R lt
R R ltR R ltR R ltR R ltR R ltR R ltRtR# )SSHServerTransporti  a  
SSHServerTransport implements the server side of the SSH protocol.

@ivar isClient: since we are never the client, this is always False.

@ivar ignoreNextPacket: if True, ignore the next key exchange packet.  This
    is set when the client sends a guessed key exchange packet but with
    an incorrect guess.

@ivar dhGexRequest: the KEX_DH_GEX_REQUEST(_OLD) that the client sent.
    The key generation needs this to be stored.

@ivar g: the Diffie-Hellman group generator.

@ivar p: the Diffie-Hellman group prime.
Fc                    V ^8  d   QhRRRR/# )r}   rV  r4   r   ztuple[keys.Key, keys.Key]r6   )r   s   "r/   r   SSHServerTransport.__annotate__  s     W W5 W-F Wr1   c                    VR9   d   RpMTpV P                   P                  V,          V P                   P                  V,          3# )a[  
Get the public and private host keys corresponding to the given
public key signature algorithm.

The factory stores public and private host keys by their key format,
which is not quite the same as the key signature algorithm: for
example, an ssh-rsa key can sign using any of the ssh-rsa,
rsa-sha2-256, or rsa-sha2-512 algorithms.

@type keyAlg: L{bytes}
@param keyAlg: A public key signature algorithm name.

@rtype: 2-L{tuple} of L{keys.Key}
@return: The public and private host keys.

@raises KeyError: if the factory does not have both a public and a
private host key for this signature algorithm.
r(  >   r'  r&  )r   
publicKeysprivateKeys)rZ   rV  	keyFormats   && r/   _getHostKeysSSHServerTransport._getHostKeys  s@    & 77"II||&&y14<<3K3KI3VVVr1   c                    V ^8  d   QhRRRR/# r}   r  r4   r   r   r6   )r   s   "r/   r   r8    s     - -% -D -r1   c                   \         P                  W4      pV'       g   R# Vw  r4p\        VR,          4      '       dJ   V^ ,          V P                  ^ ,          8w  g    V^ ,          V P                  ^ ,          8w  d
   RV n        R# R# R# )a  
Called when we receive a MSG_KEXINIT message.  For a description
of the packet, see SSHTransportBase.ssh_KEXINIT().  Additionally,
this method checks if a guessed key exchange packet was sent.  If
it was sent, and it guessed incorrectly, the next key exchange
packet MUST be ignored.
Nr#  T)r   rq  r.  r   r   ignoreNextPacket)rZ   r  retvalrc  rd  rb  s   &&    r/   rq  SSHServerTransport.ssh_KEXINIT  sq     "--d;%+"GdtCy>>
d88;;1:!9!9!!<<(,% = r1   c                    V ^8  d   QhRRRR/# r@  r6   )r   s   "r/   r   r8    s     73 73 734 73r1   c                P   \        V4      w  r!V P                  V P                  4      w  r4V P                  4       pVP	                  4       V n        V P                  V P
                  4      pV P                  WR4      p\        P                  ! V P                  4      ! 4       pVP                  \        V P                  4      4       VP                  \        V P                  4      4       VP                  \        V P                  4      4       VP                  \        V P                   4      4       VP                  \        VP#                  4       4      4       VP                  \        V4      4       VP                  \        V4      4       VP                  V4       VP%                  4       p	V P'                  \(        \        VP#                  4       4      \        V4      ,           \        VP+                  WP                  R7      4      ,           4       V P-                  Wy4       R# )ar  
Called from L{ssh_KEX_DH_GEX_REQUEST_OLD} to handle elliptic curve key
exchanges.

Payload::

    string client Elliptic Curve Diffie-Hellman public key

Just like L{_ssh_KEXDH_INIT} this message type is also not dispatched
directly.  Extra check to determine if this is really KEX_ECDH_INIT is
required.

First we load the host's public/private keys.  Then we generate the
ECDH public/private keypair for the given curve.  With that we generate
the shared secret key.  Then we compute the hash to sign and send back
to the client Along with the server's public key and the ECDH public
key.

@param packet: The message data.
signatureTypeN)r    r=  rV  r  r  r  r  r$  r   r  rK  r   r   r+  r   rX  r   blobr   r   MSG_KEXDH_REPLYsignr  )
rZ   r  pktPub
pubHostKeyprivHostKeyr!  encPubr  hr  s
   &&        r/   _ssh_KEX_ECDH_INIT%SSHServerTransport._ssh_KEX_ECDH_INIT  s   , v #'"3"3DKK"@
 ++- &&(
((4 33FC !!$++.0	D++,-	D))*+	D,,-.	D**+,	JOO%&'	F	F	xxzz !j!!,kk!JKL	
 	|2r1   c                    V ^8  d   QhRRRR/# r@  r6   )r   s   "r/   r   r8    s     '3 '3e '3 '3r1   c                N   \        V4      w  r#V P                  V P                  4      w  rE\        P                  ! V P
                  4      w  V n        V n        V P                  4        V P                  V4      p\        P                  ! V P
                  4      ! 4       pVP                  \        V P                  4      4       VP                  \        V P                  4      4       VP                  \        V P                  4      4       VP                  \        V P                   4      4       VP                  \        VP#                  4       4      4       VP                  \%        V4      4       VP                  V P&                  4       VP                  V4       VP)                  4       pV P+                  \,        \        VP#                  4       4      V P&                  ,           \        VP/                  WP                  R7      4      ,           4       V P1                  Wh4       R# )a  
Called to handle the beginning of a non-group key exchange.

Unlike other message types, this is not dispatched automatically.  It
is called from C{ssh_KEX_DH_GEX_REQUEST_OLD} because an extra check is
required to determine if this is really a KEXDH_INIT message or if it
is a KEX_DH_GEX_REQUEST_OLD message.

The KEXDH_INIT payload::

        integer e (the client's Diffie-Hellman public key)

We send the KEXDH_REPLY with our host key and signature.

@type packet: L{bytes}
@param packet: The message data.
rG  N)r   r=  rV  r   getDHGeneratorAndPrimerK  r  r1  r  r  r  r   r   r+  r   rX  r   rI  r   r  r   r   rJ  rK  r  	rZ   r  clientDHpublicKeyry  rM  rN  r  rP  r  s	   &&       r/   _ssh_KEXDH_INIT"SSHServerTransport._ssh_KEXDH_INIT  s   $ "'v"&"3"3DKK"@
44T[[A ../@A!!$++.0	D++,-	D))*+	D,,-.	D**+,	JOO%&'	%&'	))*	xxzz !&&'!!,kk!JKL	
 	|2r1   c                    V ^8  d   QhRRRR/# r@  r6   )r   s   "r/   r   r8  8  s     #K #K #K4 #Kr1   c                V   V P                   '       d
   ^ V n         R# \        P                  ! V P                  4      '       d   V P	                  V4      # \        P
                  ! V P                  4      '       d   V P                  V4      # Wn        \        P                  ! RV4      ^ ,          pV P                  P                  V4      w  V n        V n        V P                  4        V P                  \         \#        V P                  4      \#        V P                  4      ,           4       R# )a]  
This represents different key exchange methods that share the same
integer value.  If the message is determined to be a KEXDH_INIT,
L{_ssh_KEXDH_INIT} is called to handle it. If it is a KEX_ECDH_INIT,
L{_ssh_KEX_ECDH_INIT} is called.
Otherwise, for KEX_DH_GEX_REQUEST_OLD payload::

        integer ideal (ideal size for the Diffie-Hellman prime)

    We send the KEX_DH_GEX_GROUP message with the group that is
    closest in size to ideal.

If we were told to ignore the next key exchange packet by ssh_KEXINIT,
drop it on the floor and return.

@type packet: L{bytes}
@param packet: The message data.
Nr   )rB  r   isFixedGrouprK  rX  isEllipticCurverQ  dhGexRequestr   r
  r   
getDHPrimer  r1  r  r   MSG_KEX_DH_GEX_GROUPr   )rZ   r  ideals   && r/   ssh_KEX_DH_GEX_REQUEST_OLD-SSHServerTransport.ssh_KEX_DH_GEX_REQUEST_OLD8  s    &    $%D!
 T[[))''//!!$++..**622 &MM$/2E!\\44U;NDFDF""$OO0"TVV*r$&&z2IJr1   c                    V ^8  d   QhRRRR/# r@  r6   )r   s   "r/   r   r8  ]  s     G GU Gt Gr1   c                r   V P                   '       d
   ^ V n         R# Wn        \        P                  ! RV4      w  r#pV P                  P                  V4      w  V n        V n        V P                  4        V P                  \        \        V P                  4      \        V P                  4      ,           4       R# )a  
Called when we receive a MSG_KEX_DH_GEX_REQUEST message.  Payload::
    integer minimum
    integer ideal
    integer maximum

The client is asking for a Diffie-Hellman group between minimum and
maximum size, and close to ideal if possible.  We reply with a
MSG_KEX_DH_GEX_GROUP message.

If we were told to ignore the next key exchange packet by ssh_KEXINIT,
drop it on the floor and return.

@type packet: L{bytes}
@param packet: The message data.
Nz>3L)rB  r^  r   r
  r   r_  r  r1  r  r   r`  r   )rZ   r  minra  maxs   &&   r/   ssh_KEX_DH_GEX_REQUEST)SSHServerTransport.ssh_KEX_DH_GEX_REQUEST]  s    "    $%D!" --v6C007 ,bj2dff:.EFr1   c                    V ^8  d   QhRRRR/# r@  r6   )r   s   "r/   r   r8  w  s     (3 (3% (3D (3r1   c                   \        V4      w  r#V P                  V P                  4      w  rEV P                  V4      p\        P
                  ! V P                  4      ! 4       pVP                  \        V P                  4      4       VP                  \        V P                  4      4       VP                  \        V P                  4      4       VP                  \        V P                  4      4       VP                  \        VP                  4       4      4       VP                  V P                  4       VP                  \        V P                   4      4       VP                  \        V P"                  4      4       VP                  \        V4      4       VP                  V P$                  4       VP                  V4       VP'                  4       pV P)                  \*        \        VP                  4       4      V P$                  ,           \        VP-                  WP                  R7      4      ,           4       V P/                  Wh4       R# )z
Called when we get a MSG_KEX_DH_GEX_INIT message.  Payload::
    integer e (client DH public key)

We send the MSG_KEX_DH_GEX_REPLY message with our host key and
signature.

@type packet: L{bytes}
@param packet: The message data.
rG  N)r   r=  rV  r  r   r  rK  r   r   r+  r   rX  r   rI  r^  r   r1  r  r  r   r   MSG_KEX_DH_GEX_REPLYrK  r  rV  s	   &&       r/   ssh_KEX_DH_GEX_INIT&SSHServerTransport.ssh_KEX_DH_GEX_INITw  s    "'v"&"3"3DKK"@
 ../@A!!$++.0	D++,-	D))*+	D,,-.	D**+,	JOO%&'	""#	DFF	DFF	%&'	))*	xxz z !&&'!!,kk!JKL	
 	|2r1   c               $    V ^8  d   QhRRRRRR/# r  r6   )r   s   "r/   r   r8    s!      e 5 T r1   c                    V P                   RJ p\        P                  WV4       V'       d0   V P                  RRP	                  V P
                  4      3.4       R# R# )#
See SSHTransportBase._keySetup().
Ns   server-sig-algsr   )r   r   r  r  r   r   )rZ   r  r  firstKeys   &&& r/   r  SSHServerTransport._keySetup  sT     >>T)""4|D $dii0H0H&IJK r1   c                    V ^8  d   QhRRRR/# r@  r6   )r   s   "r/   r   r8    s      % D r1   c                d    VR8w  d   V P                  \        R4       R# V P                  4        R# )z
Called when we get a MSG_NEWKEYS message.  No payload.
When we get this, the keys have been set on both sides, and we
start using them to encrypt and authenticate the connection.

@param packet: The message data.
r1      NEWKEYS takes no dataN)r  r  r  r}  s   &&r/   ssh_NEWKEYSSSHServerTransport.ssh_NEWKEYS  s)     S= 9;STr1   c                    V ^8  d   QhRRRR/# r@  r6   )r   s   "r/   r   r8    s     # #% #D #r1   c                   \        V4      w  r#V P                  P                  W4      pV'       g    V P                  \        RV,           4       R# V P                  \        \        V4      4       V P                  V! 4       4       R# )a  
Called when we get a MSG_SERVICE_REQUEST message.  Payload::
    string serviceName

The client has requested a service.  If we can start the service,
start it; otherwise, disconnect with
DISCONNECT_SERVICE_NOT_AVAILABLE.

@type packet: L{bytes}
@param packet: The message data.
s   don't have service N)	r    r   
getServicer   DISCONNECT_SERVICE_NOT_AVAILABLEr   r   r   r  )rZ   r  r   rb  clss   &&   r/   ssh_SERVICE_REQUEST&SSHServerTransport.ssh_SERVICE_REQUEST  se     fll%%d402H72R OO.7<OOCE"r1   )r^  r  r  rB  r1  N)r7   r8   r9   r:   r;   r   rB  r=  rq  rQ  rX  rb  rh  rm  r  rw  r~  r=   r6   r1   r/   r6  r6    sR    " HW2-(73r'3R#KJG4(3T # #r1   r6  c                      ] tR tRtRtRtRtRtRtR t	R t
R	 tR
 tR tR tR tR tR tR tR tR R ltR tR tRtR# )SSHClientTransporti  a  
SSHClientTransport implements the client side of the SSH protocol.

@ivar isClient: since we are always the client, this is always True.

@ivar _gotNewKeys: if we receive a MSG_NEWKEYS message before we are
    ready to transition to the new keys, this is set to True so we
    can transition when the keys are ready locally.

@ivar x: our Diffie-Hellman private key.

@ivar e: our Diffie-Hellman public key.

@ivar g: the Diffie-Hellman group generator.

@ivar p: the Diffie-Hellman group prime

@ivar instance: the SSHService object we are requesting.

@ivar _dhMinimalGroupSize: Minimal acceptable group size advertised by the
    client in MSG_KEX_DH_GEX_REQUEST.
@type _dhMinimalGroupSize: int

@ivar _dhMaximalGroupSize: Maximal acceptable group size advertised by the
    client in MSG_KEX_DH_GEX_REQUEST.
@type _dhMaximalGroupSize: int

@ivar _dhPreferredGroupSize: Preferred group size advertised by the client
    in MSG_KEX_DH_GEX_REQUEST.
@type _dhPreferredGroupSize: int
Ti   i    i   c                >    \         P                  V 4       ^ V n        R# )zc
Called when the connection is started with the server.  Just sets
up a private instance variable.
N)r   r   _gotNewKeysr   s   &r/   r   !SSHClientTransport.connectionMade  s    
 	''-r1   c           	         \         P                  W4      f   R# \        P                  ! V P                  4      '       do   V P                  4       V n        V P                  P                  4       V n        V P                  \        \        V P                  V P                  4      4      4       R# \        P                  ! V P                  4      '       d`   \        P                  ! V P                  4      w  V n        V n        V P#                  4        V P                  \$        V P&                  4       R# V P                  \(        \*        P,                  ! RV P.                  V P0                  V P2                  4      4       R# )a  
Called when we receive a MSG_KEXINIT message.  For a description
of the packet, see SSHTransportBase.ssh_KEXINIT().  Additionally,
this method sends the first key exchange packet.

If the agreed-upon exchange is ECDH, generate a key pair for the
corresponding curve and send the public key.

If the agreed-upon exchange has a fixed prime/generator group,
generate a public key and send it in a MSG_KEXDH_INIT message.
Otherwise, ask for a 2048 bit group with a MSG_KEX_DH_GEX_REQUEST
message.
N!LLL)r   rq  r   r]  rK  r  r!  r  r  r   MSG_KEX_DH_GEX_REQUEST_OLDr   r  r\  rU  r  r1  r  MSG_KEXDH_INITr  MSG_KEX_DH_GEX_REQUESTr   r   _dhMinimalGroupSize_dhPreferredGroupSize_dhMaximalGroupSizer}  s   &&r/   rq  SSHClientTransport.ssh_KEXINIT	  s    ''5= ,,446DK//1DJ OO*Bt/F/Ftzz/R,S t{{++!88ENDFDF""$OOND,D,DE
 OO&,,..,,	r1   c                V  a  V 3R lp\        V^4      w  r4rQRP                  \        \        V4      P	                  4       4       Uu. uF  p\
        P                  ! V4      NK  	  up4      pS P                  W74      pVP                  W#WE4       VP                  V 3R l4       V# u upi )a]  
Called to handle a reply to a ECDH exchange message(KEX_ECDH_INIT).

Like the handler for I{KEXDH_INIT}, this message type has an
overlapping value.  This method is called from C{ssh_KEX_DH_GEX_GROUP}
if that method detects a non-group key exchange is in progress.

Payload::

    string serverHostKey
    string server Elliptic Curve Diffie-Hellman public key
    string signature

We verify the host key and continue if it passes verificiation.
Otherwise raise an exception and return.

@type packet: L{bytes}
@param packet: The message data.

@return: A deferred firing when key exchange is complete.
c                x  < TpSP                  SP                  V4      p\        P                  ! SP                  4      ! 4       pVP                  \        SP                  4      4       VP                  \        SP                  4      4       VP                  \        SP                  4      4       VP                  \        SP                  4      4       VP                  \        V4      4       VP                  \        SP                  SP                  4      4      4       VP                  \        V4      4       VP                  V4       VP                  4       p\        P                  P!                  V4      P#                  W74      '       g   SP%                  \&        R 4       R# SP)                  WW4       R# )   bad signatureN)r$  r!  r   r  rK  r   r   r   r+  r   rX  r  r  r   r   Key
fromStringr   r  r\  r  )	ignoredhostKeypubKey	signaturetheirECHostr  rP  r  rZ   s	   &&&&    r/   _continue_KEX_ECDH_REPLYHSSHClientTransport._ssh_KEX_ECDH_REPLY.<locals>._continue_KEX_ECDH_REPLYO  s&   !K77VLL%%dkk24AHHR--./HHR//01HHR../0HHR0012HHR_%HHR//

;<=HHRZ HH\"88:L88&&{3::9SS##$BDTU|:r1      :c                T   < SP                  \        R V  2P                  R4      4      # )zbad host key [ecdh] zutf-8)r  "DISCONNECT_HOST_KEY_NOT_VERIFIABLEr+  unusedrZ   s   &r/   <lambda>8SSHClientTransport._ssh_KEX_ECDH_REPLY.<locals>.<lambda>t  s(    4..2&vh/66w?r1   )
r    r   r&   r   r   binasciihexlifyverifyHostKeyaddCallback
addErrback)	rZ   r  r  r  r  r  r  fingerprintds	   f&       r/   _ssh_KEX_ECDH_REPLY&SSHClientTransport._ssh_KEX_ECDH_REPLY8  s    .	;2 .361-=* ii,5c'l6I6I6K,LM,LbXb!,LM
 w4	.K		
  Ns   B&c                  a  \        V4      w  r!\        V4      w  r1\        V4      w  rARP                  \        \	        V4      P                  4       4       Uu. uF  p\        P                  ! V4      NK  	  up4      pS P                  W&4      pVP                  S P                  W#V4       VP                  V 3R l4       V# u upi )aI  
Called to handle a reply to a non-group key exchange message
(KEXDH_INIT).

Like the handler for I{KEXDH_INIT}, this message type has an
overlapping value.  This method is called from C{ssh_KEX_DH_GEX_GROUP}
if that method detects a non-group key exchange is in progress.

Payload::

    string serverHostKey
    integer f (server Diffie-Hellman public key)
    string signature

We verify the host key by calling verifyHostKey, then continue in
_continueKEXDH_REPLY.

@type packet: L{bytes}
@param packet: The message data.

@return: A deferred firing when key exchange is complete.
r  c                0   < SP                  \        R 4      # s   bad host keyr  r  r  s   &r/   r  5SSHClientTransport._ssh_KEXDH_REPLY.<locals>.<lambda>      4..2Or1   )r    r   r   r&   r   r   r  r  r  r  _continueKEXDH_REPLYr  )rZ   r  r  r>  r  r  r  r  s   f&      r/   _ssh_KEXDH_REPLY#SSHClientTransport._ssh_KEXDH_REPLY{  s    . v&M	!&M	ii,5c&k6H6H6J,KL,KbXb!,KL
 v3	d//IF		

  M   Cc                   \         P                  ! V P                  4      '       d   V P                  V4      # \         P                  ! V P                  4      '       d   V P                  V4      # \        V4      w  V n        p\        V4      w  V n        pV P                  4        V P                  \        V P                  4       R# )aU  
This handles different messages which share an integer value.

If the key exchange does not have a fixed prime/generator group,
we generate a Diffie-Hellman public key and send it in a
MSG_KEX_DH_GEX_INIT message.

Payload::
    string g (group generator)
    string p (group prime)

@type packet: L{bytes}
@param packet: The message data.
N)r   r\  rK  r  r]  r  r   r1  r  r  r   MSG_KEX_DH_GEX_INITr  )rZ   r  rb  s   && r/   ssh_KEX_DH_GEX_GROUP'SSHClientTransport.ssh_KEX_DH_GEX_GROUP  s     T[[))((00!!$++..++F33 =LDFD ;LDFD""$OO/1I1IJr1   c                0   \         P                  P                  V4      pV P                  V4      p\        P
                  ! V P                  4      ! 4       pVP                  \        V P                  4      4       VP                  \        V P                  4      4       VP                  \        V P                  4      4       VP                  \        V P                  4      4       VP                  \        V4      4       VP                  V P                  4       VP                  \        V4      4       VP                  V4       VP                  4       pVP!                  WH4      '       g   V P#                  \$        R4       R# V P'                  Wh4       R# )a  
The host key has been verified, so we generate the keys.

@param ignored: Ignored.

@param pubKey: the public key blob for the server's public key.
@type pubKey: L{str}
@param f: the server's Diffie-Hellman public key.
@type f: L{int}
@param signature: the server's signature, verifying that it has the
    correct private key.
@type signature: L{str}
r  N)r   r  r  r  r   r  rK  r   r   r   r+  r   rX  r  r   r   r   r  r\  r  	rZ   r  r  r>  r  	serverKeyr  rP  r  s	   &&&&&    r/   r  'SSHClientTransport._continueKEXDH_REPLY  s    HH''/	..q1!!$++.0	D))*+	D++,-	D**+,	D,,-.	F	))*	A	xxz	88 >@PQ|2r1   c                  a  \        V4      w  r!\        V4      w  r1\        V4      w  rARP                  \        \	        V4      P                  4       4       Uu. uF  p\        P                  ! V4      NK  	  up4      pS P                  W&4      pVP                  S P                  W#V4       VP                  V 3R l4       V# u upi )aN  
Called when we receive a MSG_KEX_DH_GEX_REPLY message.  Payload::
    string server host key
    integer f (server DH public key)

We verify the host key by calling verifyHostKey, then continue in
_continueGEX_REPLY.

@type packet: L{bytes}
@param packet: The message data.

@return: A deferred firing once key exchange is complete.
r  c                0   < SP                  \        R 4      # r  r  r  s   &r/   r  9SSHClientTransport.ssh_KEX_DH_GEX_REPLY.<locals>.<lambda>  r  r1   )r    r   r   r&   r   r   r  r  r  r  _continueGEX_REPLYr  )rZ   r  r  r>  r  r  r  r  s   f&      r/   ssh_KEX_DH_GEX_REPLY'SSHClientTransport.ssh_KEX_DH_GEX_REPLY  s     v&M	!&M	ii*3CK4F4F4H*IJ*IQXa *IJ
 v3	d--v)D		

  Kr  c                L   \         P                  P                  V4      pV P                  V4      p\        P
                  ! V P                  4      ! 4       pVP                  \        V P                  4      4       VP                  \        V P                  4      4       VP                  \        V P                  4      4       VP                  \        V P                  4      4       VP                  \        V4      4       VP                  \        P                  ! RV P                  V P                   V P"                  4      4       VP                  \%        V P&                  4      4       VP                  \%        V P(                  4      4       VP                  V P*                  4       VP                  \%        V4      4       VP                  V4       VP-                  4       pVP/                  WH4      '       g   V P1                  \2        R4       R# V P5                  Wh4       R# )r  r  r  N)r   r  r  r  r   r  rK  r   r   r   r+  r   rX  r   r   r  r  r  r   r1  r  r  r   r   r  r\  r  r  s	   &&&&&    r/   r  %SSHClientTransport._continueGEX_REPLY  su    HH''/	..q1!!$++.0	D))*+	D++,-	D**+,	D,,-.	F	KK((**((		
 	
DFF	DFF	))*	A	xxz	88 >@PQ|2r1   c                |    \         P                  WV4       V P                  '       d   V P                  R4       R# R# )rq  r1   N)r   r  r  rw  )rZ   r  r  s   &&&r/   r  SSHClientTransport._keySetup  s3     	""4|DS! r1   c                    VR8w  d   V P                  \        R4       R# V P                  P                  '       g
   ^V n        R# V P                  4        V P                  4        R# )z
Called when we receive a MSG_NEWKEYS message.  No payload.
If we've finished setting up our own keys, start using them.
Otherwise, remember that we've received this message.

@type packet: L{bytes}
@param packet: The message data.
r1   rv  N)r  r  rY  rU   r  r  connectionSecurer}  s   &&r/   rw  SSHClientTransport.ssh_NEWKEYS'  sR     S= 9;ST##000 Dr1   c                   VR8X  d   V P                   P                  R4       MB\        V4      ^ ,          pW P                  P                  8w  d   V P                  \        R4       V P                  V P                  4       R# )z
Called when we receive a MSG_SERVICE_ACCEPT message.  Payload::
    string service name

Start the service we requested.

@type packet: L{bytes}
@param packet: The message data.
r1   z"got SERVICE_ACCEPT without payloads.   received accept for service we did not requestN)r   r   r    instancer  r  r  r  )rZ   r  r  s   && r/   ssh_SERVICE_ACCEPT%SSHClientTransport.ssh_SERVICE_ACCEPT9  s`     S=IINN?@=#D}})))##-E 	&r1   c                    V ^8  d   QhRRRR/# )r}   r  r!   r   r   r6   )r   s   "r/   r   SSHClientTransport.__annotate__N  s     ! !z !d !r1   c                d    V P                  \        \        VP                  4      4       Wn        R# )z
Request that a service be run over this transport.

@type instance: subclass of L{twisted.conch.ssh.service.SSHService}
@param instance: The service to run.
N)r   r   r   r  r  )rZ   r  s   &&r/   requestService!SSHClientTransport.requestServiceN  s!     	+R->? r1   c                >    \         P                  ! \        4       4      # )a!  
Returns a Deferred that gets a callback if it is a valid key, or
an errback if not.

@type hostKey: L{bytes}
@param hostKey: The host key to verify.

@type fingerprint: L{bytes}
@param fingerprint: The fingerprint of the key.

@return: A deferred firing with C{True} if the key is valid.
)r"   failNotImplementedError)rZ   r  r  s   &&&r/   r   SSHClientTransport.verifyHostKeyZ  s     zz-/00r1   c                    \        4       h)z
Called when the encryption has been set up.  Generally,
requestService() is called to run another service over the transport.
)r  r   s   &r/   r  #SSHClientTransport.connectionSecurei  s    
 "##r1   )r  r!  r  r  r  r1  N)r7   r8   r9   r:   r;   r   r  r  r  r   rq  r  r  r  r  r  r  r  rw  r  r  r  r  r=   r6   r1   r/   r  r    sq    @ H  !-^AF$LK23>:'3R" $'*!1$r1   r  c                       ] tR tRtRtR tRtR# )_NullEncryptionContextiq  z@
An encryption context that does not actually encrypt anything.
c                    V# )z
'Encrypt' new data by doing nothing.

@type data: L{bytes}
@param data: The data to 'encrypt'.

@rtype: L{bytes}
@return: The 'encrypted' data.
r6   )rZ   r.   s   &&r/   r   _NullEncryptionContext.updatev  s	     r1   r6   N)r7   r8   r9   r:   r;   r   r=   r6   r1   r/   r  r  q  s    
r1   r  c                      ] tR tRtRt^@tRtR# )_DummyAlgorithmi  zB
An encryption algorithm that does not actually encrypt anything.
r6   N)r7   r8   r9   r:   r;   re   r=   r6   r1   r/   r  r    s     Jr1   r  c                  4    ] tR tRtRt]! 4       tR tR tRt	R# )ru   i  z
A cipher for the none encryption method.

@ivar block_size: the block size of the encryption.  In the case of the
none cipher, this is 8 bytes.
c                    \        4       # )z6
Construct a noop encryptor.

@return: The encryptor.
r  r   s   &r/   rc   _DummyCipher.encryptor       &''r1   c                    \        4       # )z6
Construct a noop decryptor.

@return: The decryptor.
r  r   s   &r/   rf   _DummyCipher.decryptor  r  r1   r6   N)
r7   r8   r9   r:   r;   r  rd   rc   rf   r=   r6   r1   r/   ru   ru     s      !I((r1   ru   s   diffie-hellman-group14-sha1MSG_
MSG_KEXDH_r  rJ  z7legacy SSH mnemonics should not end up in messages dict)|r;   
__future__r   r  r   r   typesr  hashlibr   r   r   r   r   typingr   r	   r
   r   r   r   cryptography.exceptionsr   cryptography.hazmat.backendsr   cryptography.hazmat.primitivesr   )cryptography.hazmat.primitives.asymmetricr   r   r   &cryptography.hazmat.primitives.ciphersr   r   r   r   twistedr   r*  twisted.conch.sshr   r   r   twisted.conch.ssh.commonr   r   r   r   r    twisted.conch.ssh.servicer!   twisted.internetr"   r#   twisted.loggerr$   twisted.pythonr%   twisted.python.compatr&   r'   twisted.python.failurer(   twisted.conch.ssh.factoryr)   r0   _Hashstr
ModuleType
_DigestModr4   r,   r3   r?   r   Protocolr   r6  r  r  r  ru   rU  DH_GENERATORDH_PRIMEr  r  r  r  r   r   r   r   r  r  rJ  r  r  r`  r  rl  &DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECTr  r\  DISCONNECT_RESERVEDr  r  r|  r  r  r&  DISCONNECT_BY_APPLICATIONDISCONNECT_TOO_MANY_CONNECTIONS!DISCONNECT_AUTH_CANCELLED_BY_USER)DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLEDISCONNECT_ILLEGAL_USER_NAMEr9  r   globalsitemsr  rN  r)  r   r6   r1   r/   <module>r     sR  
 #      5 5 C C 8 8 8 D D L L  2 1 1 > > 0 , ! $ : *
 4+ 	3U+U-=-==>
z5%45 ,B/ B/JBT*x(( T*n"#) #D
X$) X$v $ ( (6 445ST h 
 	        *+ & !"     #$  ,- )%& "  "$ $& !,. )!  	)*KD%vt|'D'D +
 x#4#@
P
QQ $Ar1   