o
    ¯b¢  ã                   @   s‚   d Z ddlZddlmZ ddlmZ ddlmZ g d¢Zdd„ Z	dd
d„Z
dd„ Zddd„Zdd„ Zeeddddƒƒdd„ ƒZdS )z@
Common functions for the SSH classes.

Maintainer: Paul Swartz
é    N)Úint_to_bytes)Ú
deprecated)ÚVersion)ÚNSÚgetNSÚMPÚgetMPÚffsc                 C   s(   t | tƒr
|  d¡} t dt| ƒ¡|  S )z
    net string
    zutf-8ú!L)Ú
isinstanceÚstrÚencodeÚstructÚpackÚlen)Út© r   ú:/usr/lib/python3/dist-packages/twisted/conch/ssh/common.pyr      s   

r   é   c                 C   sp   g }d}t |ƒD ]$}t d| ||d … ¡\}| | |d d| | … ¡ |d| 7 }qt|ƒ| |d… f S )z
    get net string
    r   r
   é   N)Úranger   ÚunpackÚappendÚtuple)ÚsÚcountÚnsÚcÚiÚlr   r   r   r      s   r   c                 C   sP   | dkrdS | dksJ ‚t | ƒ}t|dd… ƒd@ rd| }t dt|ƒ¡| S )Nr   s       r   é€   ó    ú>L)r   Úordr   r   r   )ÚnumberÚbnr   r   r   r   ,   s   r   c              	   C   sx   g }d}t |ƒD ](}t d| ||d … ¡\}| t | |d |d | … d¡¡ |d| 7 }qt|ƒ| |d… f S )a=  
    Get multiple precision integer out of the string.  A multiple precision
    integer is stored as a 4-byte length followed by length bytes of the
    integer.  If count is specified, get count integers out of the string.
    The return value is a tuple of count integers followed by the rest of
    the data.
    r   r"   r   ÚbigN)r   r   r   r   ÚintÚ
from_bytesr   )Údatar   Úmpr   r   Úlengthr   r   r   r   6   s   &r   c                 C   s   | D ]
}||v r|  S qdS )zs
    first from second
    goes through the first list, looking for items in the second, returns the first one
    Nr   )r   r   r   r   r   r   r	   G   s
   ÿÿr	   ÚTwistedé   é   c                   C   s   d S )Nr   r   r   r   r   ÚinstallQ   s   r/   )r   )Ú__doc__r   Úcryptography.utilsr   Útwisted.python.deprecater   Útwisted.python.versionsr   Ú__all__r   r   r   r   r	   r/   r   r   r   r   Ú<module>   s   
	


