ó
    &ÝNjT%  ã                   ól  • 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JrJrJ	r	J
r
JrJr  SSKJr  SS jrSS jrSS jrS rS	 rS
 rS rS rS rS rS rS r\R6                  " 5       qSq\R<                  " 5       qS r \4S jr! " S S5      r"\"" 5       r#S r$S r% " S S5      r&S r'S r(S S jr)S S jr*g)!zo
The dreaded ``utils.py`` - clearinghouse for commonly used functions or data
that don't belong anywhere else.
é    N)ÚDEBUGÚbyte_chrÚbyte_ordÚmax_byteÚ	xffffffffÚ	zero_byte)Ú	SSHConfigc           	      ó–  • SnSnU(       d#  [        U 5      S:”  a  [        U S   5      S:¼  a  Sn[        U 5      S-  (       a*  [        nU(       a  [        nUS[        U 5      S-  -
  -  U -   n [	        S[        U 5      S5       H(  nUS-  [
        R                  " SXUS-    5      S   -   nM*     U(       a  USS[        U 5      -  -  -  nU$ )zPturns a normalized byte string into a long-int
(adapted from Crypto.Util.number)r   é€   é   é   é    ú>Ié   )Úlenr   r   r   ÚrangeÚstructÚunpack)ÚsÚalways_positiveÚoutÚnegativeÚfillerÚis         ÚJ/home/mande/repo/quber/.venv/lib/python3.13/site-packages/paramiko/util.pyÚinflate_longr   )   sÀ   € ð €CØ€HÞ¤ A£¨£
´¸!¸A¹$³À4Ó1GØˆÜ
ˆ1ƒv�‡zÜˆÞÜˆFð �aœ#˜a›& 1™*‘nÑ%¨Ñ)ˆÜ�1”c˜!“f˜aÖ ˆØ�b‰yœFŸMšM¨$°°a¸!±e°Ó=¸aÑ@Ñ@Šñ !æØˆq�Qœ˜Q›‘ZÑ Ñ ˆØ€Jó    c                 óæ  • [        5       n[        U 5      n U S:w  a:  U S:w  a4  [        R                  " SU [        -  5      U-   nU S-  n U S:w  a  U S:w  a  M4  [        U5       H'  nU S:X  a  US   S:w  a    O,U S:X  d  M  US   S:w  d  M'    O   SnU S:X  a  [        nO[        nX#S   S nU(       aB  U S:X  a  [        US   5      S	:¼  a	  [        U-   nU S:X  a  [        US   5      S	:  a	  [        U-   nU$ )
zPturns a long-int into a normalized byte string
(adapted from Crypto.Util.number)r   éÿÿÿÿr   r   r   éÿ   )r   Nr   )	ÚbytesÚintr   Úpackr   Ú	enumerater   r   r   )ÚnÚadd_sign_paddingr   r   s       r   Údeflate_longr'   >   sõ   € ô 	‹€AÜˆA‹€AØ�‹6˜˜R›Ü�KŠK˜˜a¤)™mÓ,¨qÑ0ˆØ	ˆb‰ˆð �‹6˜˜R�ô �qŽ\ˆØ�‹F˜˜1™ ›ÙØ��G˜!˜A™$ $�,Ùñ	 ð ˆØ�‹6Ü‰AäˆAØ	ˆA‰$ˆ&ˆ	€AÞØ�‹Fœ ! A¡$›¨4Ó/Ü˜A‘ˆAØ�‹Gœ( 1 Q¡4›.¨4Ó/Ü˜1‘ˆAØ€Hr   c                 ó(  • Sn/ n[        U 5      US-   :”  a8  UR                  [        XUS-    5      5        US-  n[        U 5      US-   :”  a  M8  U[        U 5      :  a  UR                  [        XS  5      5        U Vs/ s H  oAU-   PM	     sn$ s  snf )Nr   é   )r   ÚappendÚformat_binary_line)ÚdataÚprefixÚxr   Úlines        r   Úformat_binaryr0   ]   s�   € Ø	€AØ
€CÜ
ˆd‹)�a˜"‘fÓ
Ø�
‰
Ô% d¨q°2©vÐ&6Ó7Ô8Ø	ˆR‰ˆô ˆd‹)�a˜"‘fÕ
ð 	Œ3ˆt‹9ƒ}Ø�
‰
Ô% d¨2 hÓ/Ô0Ù&)Ó*¢c˜d�TŒM¡cÑ*Ð*ùÒ*s   Á>Bc           
      óD  • SR                  U  Vs/ s H  nSR                  [        U5      5      PM     sn5      nSR                  U  Vs/ s H/  nSR                  [        U5      5      [        U5      S-   S-     PM1     sn5      nSR                  X#5      $ s  snf s  snf )NÚ z{:02X}Ú z.{:c}..é?   é_   z	{:50s} {})ÚjoinÚformatr   )r,   ÚcÚleftÚrights       r   r+   r+   h   sŠ   € Ø�8‰8¹4Ó@º4°a�X—_‘_¤X¨a£[Ö1¹4Ñ@ÓA€DØ�G‰GÙJNÓOÊ$ÀQˆ×	Ñ	œ( 1›+Ó	&¬°«°bÑ(8¸RÑ'?Ô	@É$ÑOó€Eð ×Ñ˜dÓ*Ð*ùò	 AùâOs   �$BÁ
6Bc                 ó¬   • SnU  HK  n[        U5      nSUs=::  a  S::  a  O  OU[        U5      -  nM.  U[        SR                  U5      5      -  nMM     U$ )Nr   r   é   z%{:02X})r   r   Úbr7   )r   r   r8   r   s       r   Úsafe_stringr>   p   sT   € Ø
€CÛˆÜ�Q‹KˆØ��>�cŽ>Ø”8˜A“;ÑŠCà”1�Y×%Ñ% aÓ(Ó)Ñ)ŠCñ ð €Jr   c                 óè   •  U R                  5       $ ! [         aU    [        U S5      n[        US   5      nUS:X  a   g[	        U5      S-  nUS-  (       d  US-  nUS-  nUS-  (       d  M  Us $ f = f)NFr   r   r   r   )Ú
bit_lengthÚAttributeErrorr'   r   r   )r%   ÚnormÚhbyteÚbitlens       r   r@   r@   {   s~   € ðØ�|‰|‹~ÐøÜó 	Ü˜A˜uÓ%ˆÜ˜˜a™Ó!ˆØ�A‹:ÙÜ�T“˜Q‘ˆØ˜4—<Ø�a‰KˆEØ�a‰KˆFð ˜4—<‘<ð Šð	ús   ‚ ’*A1¾,A1Á,A1Á0A1c                  óŠ   • SR                  [        R                  " [        R                  " 5       6 5      R                  S5      $ )Nr3   Ú
)r6   Ú	tracebackÚformat_exceptionÚsysÚexc_infoÚsplit© r   r   Ú
tb_stringsrM   Š   s-   € Ø�7‰7”9×-Ò-¬s¯|ª|«~Ð>Ó?×EÑEÀdÓKÐKr   c                 óv  • [        5       n[        5       n[        U5      S:”  a  USS nUS:”  aŠ  U " 5       n[        U5      S:”  a  UR                  U5        UR                  [        U5      5        UR                  U5        UR	                  5       n[        U[        U5      5      nXESU -  nX7-  nUS:”  a  MŠ  U$ )aý  
Given a password, passphrase, or other human-source key, scramble it
through a secure hash into some keyworthy bytes.  This specific algorithm
is used for encrypting/decrypting private key files.

:param function hash_alg: A function which creates a new hash object, such
    as ``hashlib.sha256``.
:param salt: data to salt the hash with.
:type bytes salt: Hash salt bytes.
:param str key: human-entered password or passphrase.
:param int nbytes: number of bytes to generate.
:return: Key data, as `bytes`.
r   Nr   )r!   r   Úupdater=   ÚdigestÚmin)Úhash_algÚsaltÚkeyÚnbytesÚkeydatarP   Úhash_objÚsizes           r   Úgenerate_key_bytesrY   Ž   sª   € ô ‹g€GÜ‹W€FÜ
ˆ4ƒy�1ƒ}Ø�B�QˆxˆØ
�1‹*Ù“:ˆÜˆv‹;˜‹?Ø�O‰O˜FÔ#Ø�‰œ˜#›ÔØ�‰˜ÔØ—‘Ó"ˆÜ�6œ3˜v›;Ó'ˆØ˜%˜4�=Ñ ˆØ‰ˆð �1�*ð €Nr   c                 ó   • SSK Jn  U" U 5      $ )a&  
Read a file of known SSH host keys, in the format used by openssh, and
return a compound dict of ``hostname -> keytype ->`` `PKey
<paramiko.pkey.PKey>`. The hostname may be an IP address or DNS name.

This type of file unfortunately doesn't exist on Windows, but on posix,
it will usually be stored in ``os.path.expanduser("~/.ssh/known_hosts")``.

Since 1.5.3, this is just a wrapper around `.HostKeys`.

:param str filename: name of the file to read host keys from
:return:
    nested dict of `.PKey` objects, indexed by hostname and then keytype
r   )ÚHostKeys)Úparamiko.hostkeysr[   )Úfilenamer[   s     r   Úload_host_keysr^   ­   s   € õ +á�HÓÐr   c                 ó<   • [        5       nUR                  U 5        U$ )z�
Provided only as a backward-compatible wrapper around `.SSHConfig`.

.. deprecated:: 2.7
    Use `SSHConfig.from_file` instead.
)r	   Úparse)Úfile_objÚconfigs     r   Úparse_ssh_configrc   Á   s   € ô ‹[€FØ
‡L�L�ÔØ€Mr   c                 ó$   • UR                  U 5      $ )zE
Provided only as a backward-compatible wrapper around `.SSHConfig`.
)Úlookup)Úhostnamerb   s     r   Úlookup_ssh_host_configrg   Í   s   € ð �=‰=˜Ó"Ð"r   c                 ó|   • SSUpCnSSU pvnUS:”  a!  XG-  nXRXX-  -
  pRXcXh-  -
  pcXtXx-  -
  ptUS:”  a  M!  US:  a  X1-  nU$ )Nr   r   rL   )	r.   ÚmÚu1Úu2Úu3Úv1Úv2Úv3Úqs	            r   Úmod_inverserq   Ô   se   € à�A�qˆB€BØ�A�qˆB€Bà
ˆq‹&Ø‰HˆØ˜"™&‘[ˆBØ˜"™&‘[ˆBØ˜"™&‘[ˆBð	 ˆq�&ð
 
ˆAƒvØ
‰ˆØ€Ir   c                  óÖ   •  [         R                  $ ! [         aL    [           [        S-  q[        [         l        S S S 5        O! , (       d  f       O= f[         R                  s $ f = f)Nr   )Ú_g_thread_dataÚidrA   Ú_g_thread_lockÚ_g_thread_counterrL   r   r   Úget_thread_idrw   è   sP   € ð!Ü× Ñ Ð øÜó !ÞÜ Ñ"ÐÜ 1ŒNÔ÷ �^Ž^úô × Ñ Ò ð	!ús%   ‚ ’A(¢A»	A(Á
A	ÁA(Á'A(c                 óF  • [         R                  " S5      n[        UR                  5      S:”  a  gUR	                  U5        [        U S5      n[         R                  " U5      nSnUS-  nUR                  [         R                  " US5      5        UR                  U5        g)zGsend paramiko logs to a logfile,
if they're not already going somewhereÚparamikor   NÚaz>%(levelname)-.3s [%(asctime)s.%(msecs)03d] thr=%(_threadid)-3dz %(name)s: %(message)sz%Y%m%d-%H:%M:%S)
ÚloggingÚ	getLoggerr   ÚhandlersÚsetLevelÚopenÚStreamHandlerÚsetFormatterÚ	FormatterÚ
addHandler)r]   ÚlevelÚloggerÚfÚhandlerÚfrms         r   Úlog_to_filer‰   ó   sŠ   € ô ×Ò˜zÓ*€FÜ
ˆ6�?‰?Ó˜aÓØØ
‡O�O�EÔÜˆX�sÓ€AÜ×#Ò# AÓ&€GØ
J€CØÐ#Ñ#€CØ×Ñœ×*Ò*¨3Ð0AÓBÔCØ
×Ñ�gÕr   c                   ó   • \ rS rSrS rSrg)ÚPFilteri  c                 ó"   • [        5       Ul        g)NT)rw   Ú	_threadid)ÚselfÚrecords     r   ÚfilterÚPFilter.filter  s   € Ü(›?ˆÔØr   rL   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r�   Ú__static_attributes__rL   r   r   r‹   r‹     s   † õr   r‹   c                 ó\   • [         R                  " U 5      nUR                  [        5        U$ ©N)r{   r|   Ú	addFilterÚ_pfilter)Únamer…   s     r   Ú
get_loggerrœ     s%   € Ü×Ò˜tÓ$€FØ
×Ñ”XÔØ€Mr   c                 ó´   • [        U 5      [        U5      :w  a  gSn[        [        U 5      5       H!  nU[        X   5      [        X   5      -  -  nM#     US:H  $ )NFr   )r   r   r   )rz   r=   Úresr   s       r   Úconstant_time_bytes_eqrŸ     sP   € Ü
ˆ1ƒv”�Q“ÓØØ
€Cä”3�q“6Ž]ˆØŒx˜™‹~¤¨©£Ñ.Ñ.Šñ à�!‰8€Or   c                   ó    • \ rS rSrS rS rSrg)ÚClosingContextManageri  c                 ó   • U $ r˜   rL   )rŽ   s    r   Ú	__enter__ÚClosingContextManager.__enter__  s   € Øˆr   c                 ó$   • U R                  5         g r˜   )Úclose)rŽ   ÚtypeÚvaluerG   s       r   Ú__exit__ÚClosingContextManager.__exit__   s   € Ø�
‰
�r   rL   N)r’   r“   r”   r•   r£   r©   r–   rL   r   r   r¡   r¡     s   † òõr   r¡   c                 ó,   • [        U [        X5      5      $ r˜   )ÚmaxrQ   )ÚminimumÚvalÚmaximums      r   Úclamp_valuer°   $  s   € Üˆwœ˜CÓ)Ó*Ð*r   c                 ó„   •  [        U 5      $ ! [         a(     U R                  5       s $ ! [         a    U s s $ f = ff = f)z2
Coerce to bytes if possible or return unchanged.
)r=   Ú	TypeErrorÚasbytesrA   )r   s    r   r³   r³   (  sJ   € ðô �‹tˆøÜó 	ð	ð —9‘9“;ÒøÜó 	ð ŒHð		úð	ús    ‚
 �
?˜*§?ª;¶?º;»?c                 óª   • [        U [        5      (       a  U $ [        U [        5      (       a  U R                  U5      $ [	        S[        U 5       35      e)zcast unicode or bytes to bytesúExpected unicode or bytes, got )Ú
isinstancer!   ÚstrÚencoder²   r§   ©r   Úencodings     r   r=   r=   >  sG   € ä�!”U×ÑØˆÜ	�A”s×	Ñ	Ø�x‰x˜Ó!Ð!äÐ9¼$¸q»'¸ÐCÓDÐDr   c                 óª   • [        U [        5      (       a  U R                  U5      $ [        U [        5      (       a  U $ [	        S[        U 5       35      e)z cast bytes or unicode to unicoderµ   )r¶   r!   Údecoder·   r²   r§   r¹   s     r   Úur½   I  sG   € ä�!”U×ÑØ�x‰x˜Ó!Ð!Ü	�A”s×	Ñ	ØˆäÐ9¼$¸q»'¸ÐCÓDÐDr   )F)T)r3   )Úutf8)+Ú__doc__r{   r   rI   Ú	threadingrG   Úparamiko.commonr   r   r   r   r   r   Úparamiko.configr	   r   r'   r0   r+   r>   r@   rM   rY   r^   rc   rg   rq   Úlocalrs   rv   ÚLockru   rw   r‰   r‹   rš   rœ   rŸ   r¡   r°   r³   r=   r½   rL   r   r   Ú<module>rÅ      sÓ   ðñ&ó
 Û Û 
Û Û ÷÷ õ &ôô*ô>+ò+òòòLòò>ò(	ò#òð —’Ó"€ØÐ Ø—’Ó!€ò!ð !&ô ÷ ñ ñ ‹9€òò÷ñ ò+òô,EõEr   