o
    ‰Öh—  ã                   @   s¢   U d dl Z d dlZd dlZd dlZd dlZd dlmZ G dd„ dƒZeƒ ZedB e	d< ze 
¡ ZW n ey<   dZY nw defdd„Zd	ed
edefdd„ZdS )é    N)ÚAnyc                   @   s–   e Zd ZddedB fdd„ZdeeB ddfdd„ZdeeB ddfd	d
„Zddd„Zde	fdd„Z
de	fdd„Zde	fdd„Zde	de	de	fdd„ZdS )ÚEntropyPoolNÚseedc                 C   sr   d| _ d | _d| _t ¡ | _t ¡ | _d| _	t
d| j	 ƒ| _|d ur1|  |¡ d| _t ¡ | _d S d| _d| _d S )Nr   é   ó    TF)Ú
pool_indexÚdigestÚ	next_byteÚ	threadingÚLockÚlockÚhashlibÚsha1ÚhashÚhash_lenÚ	bytearrayÚpoolÚ_stirÚseededÚosÚgetpidÚseed_pid)Úselfr   © r   úM/var/www/html/pro-man-master/venv/lib/python3.10/site-packages/dns/entropy.pyÚ__init__    s   



zEntropyPool.__init__ÚentropyÚreturnc                 C   sJ   |D ] }| j | jkrd| _ |d@ }| j| j   |N  < |  j d7  _ qd S )Nr   éÿ   é   )r   r   r   )r   r   ÚcÚbr   r   r   r   0   s   ûzEntropyPool._stirc                 C   s6   | j  |  |¡ W d   ƒ d S 1 sw   Y  d S ©N)r   r   )r   r   r   r   r   Ústir8   s   "ÿzEntropyPool.stirc                 C   sÄ   | j r
| jt ¡ kr`zt d¡}W n8 tyI   ztdddƒ}| d¡}W d   ƒ n1 s/w   Y  W n tyF   tt	 	¡ ƒ 
¡ }Y nw Y nw d| _ t ¡ | _d | _t|ƒ}|  |¡ d S d S )Né   z/dev/urandomÚrbr   T)r   r   r   r   ÚurandomÚ	ExceptionÚopenÚreadÚstrÚtimeÚencoder   r   r   )r   r   Úrr   r   r   Ú_maybe_seed<   s(   ÿ€ÿ€ü
ózEntropyPool._maybe_seedc                 C   s˜   | j ? |  ¡  | jd u s| j| jkr-| j t| jƒ¡ t	| j ¡ ƒ| _|  
| j¡ d| _| j| j }|  jd7  _W d   ƒ |S 1 sEw   Y  |S )Nr   r   )r   r.   r   r	   r   r   ÚupdateÚbytesr   r   r   )r   Úvaluer   r   r   Úrandom_8L   s   
ø	÷	zEntropyPool.random_8c                 C   ó   |   ¡ d |   ¡  S )Né   )r2   ©r   r   r   r   Ú	random_16X   ó   zEntropyPool.random_16c                 C   r3   )Né   )r6   r5   r   r   r   Ú	random_32[   r7   zEntropyPool.random_32ÚfirstÚlastc                 C   sd   || d }|dkrt dƒ‚|dkr| j}d}n|dkr"| j}d}n| j}d}|||ƒ  |d   S )	Nr   l        ztoo bigr8   l   ÿÿ r4   iÿÿ  r   )Ú
ValueErrorr9   r6   r2   )r   r:   r;   ÚsizeÚrandÚmaxr   r   r   Úrandom_between^   s   zEntropyPool.random_betweenr"   )r   N)Ú__name__Ú
__module__Ú__qualname__r0   r   r   r   r#   r.   Úintr2   r6   r9   r@   r   r   r   r   r      s    
r   Úsystem_randomr   c                   C   s   t d ur
t  dd¡S t ¡ S )Nr   r8   )rE   Ú	randranger   r6   r   r   r   r   r6   w   s   r6   r:   r;   c                 C   s$   t d urt  | |d ¡S t | |¡S )Nr   )rE   rF   r   r@   )r:   r;   r   r   r   Úbetween~   s   rG   )r   r   Úrandomr
   r+   Útypingr   r   r   Ú__annotations__ÚSystemRandomrE   r'   rD   r6   rG   r   r   r   r   Ú<module>   s    
Tÿ