a
    kÄ#dt  ã                   @   sš   d Z ddlmZ ddlZddlmZ ddlm  mZ i Z	i Z
G dd„ deƒZG dd„ de ee¡ƒZG d	d
„ d
eƒZG dd„ deƒZG dd„ deƒZdS )z
TLS compression.
é    )Úabsolute_importN©Úwarningc                       s    e Zd ZdZ‡ fdd„Z‡  ZS )Ú_GenericCompMetaclasszR
    Compression classes are automatically registered through this metaclass.
    c                    sB   t t| ƒ | |||¡}| d¡}| d¡}|r>|t|< |t|< |S )NÚnameÚval)Úsuperr   Ú__new__ÚgetÚ_tls_compression_algsÚ_tls_compression_algs_cls)Úclsr   ÚbasesÚdctZ	the_classZ	comp_namer   ©Ú	__class__© úZ/var/www/html/gsl.tools/lib/python3.9/site-packages/scapy/layers/tls/crypto/compression.pyr	      s    ÿ

z_GenericCompMetaclass.__new__)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   Ú__classcell__r   r   r   r   r      s   r   c                   @   s   e Zd ZdS )Ú_GenericCompN)r   r   r   r   r   r   r   r   %   s   r   c                   @   s(   e Zd ZdZdZdZdd„ Zdd„ ZdS )	Ú	Comp_NULLzL
    The default and advised compression method for TLS: doing nothing.
    Únullr   c                 C   s   |S ©Nr   ©ÚselfÚsr   r   r   Úcompress0   s    zComp_NULL.compressc                 C   s   |S r   r   r   r   r   r   Ú
decompress3   s    zComp_NULL.decompressN©r   r   r   r   r   r   r    r!   r   r   r   r   r   )   s
   r   c                   @   s0   e Zd ZdZdZdZdd„ Zdd„ Zdd	„ Zd
S )ÚComp_Deflatez;
    DEFLATE algorithm, specified for TLS by RFC 3749.
    Údeflateé   c                 C   s"   | j  |¡}|| j  tj¡7 }|S r   )Úcompress_stater    ÚflushÚzlibÚZ_FULL_FLUSH)r   r   Útmpr   r   r   r    >   s    zComp_Deflate.compressc                 C   s   | j  |¡S r   )Údecompress_stater!   r   r   r   r   r!   C   s    zComp_Deflate.decompressc                 C   s   t  ¡ | _t  ¡ | _d S r   )r(   Úcompressobjr&   Údecompressobjr+   )r   r   r   r   Ú__init__F   s    
zComp_Deflate.__init__N)	r   r   r   r   r   r   r    r!   r.   r   r   r   r   r#   7   s   r#   c                   @   s(   e Zd ZdZdZdZdd„ Zdd„ ZdS )	ÚComp_LZSze
    Lempel-Zic-Stac (LZS) algorithm, specified for TLS by RFC 3943.
    XXX No support for now.
    ZLZSé@   c                 C   s   t dƒ |S ©Nz0LZS Compression algorithm is not implemented yetr   r   r   r   r   r    S   s    zComp_LZS.compressc                 C   s   t dƒ |S r1   r   r   r   r   r   r!   W   s    zComp_LZS.decompressNr"   r   r   r   r   r/   K   s
   r/   )r   Ú
__future__r   r(   Zscapy.errorr   Zscapy.libs.sixZlibsÚsixr   r   Útyper   Úwith_metaclassÚobjectr   r   r#   r/   r   r   r   r   Ú<module>   s   