o
    'èhI
  ã                   @   s€   d Z ddlZddlmZmZ ddlZddlZdeeef deej	j
ejjf fdd„Zdeej	j
ef deeef fd	d
„ZdS )zA place to store TSIG keys.é    N)ÚAnyÚDictÚtextringÚreturnc                 C   sb   i }|   ¡ D ](\}}tj |¡}t|tƒr tj ||¡j||< q|\}}tj |||¡||< q|S )a7  Convert a dictionary containing (textual DNS name, base64 secret)
    pairs into a binary keyring which has (dns.name.Name, bytes) pairs, or
    a dictionary containing (textual DNS name, (algorithm, base64 secret))
    pairs into a binary keyring which has (dns.name.Name, dns.tsig.Key) pairs.
    @rtype: dict)	ÚitemsÚdnsÚnameÚ	from_textÚ
isinstanceÚstrÚtsigÚKeyÚsecret)r   Úkeyringr   ÚvalueÚknameÚ	algorithmr   © r   úK/var/www/html/olx_land/venv/lib/python3.10/site-packages/dns/tsigkeyring.pyr	      s   
r	   r   c                 C   sv   i }dd„ }|   ¡ D ].\}}| ¡ }t|tƒr||ƒ||< q
t|jtƒr*||jƒ}nt|jƒ}|j ¡ |f||< q
|S )a;  Convert a dictionary containing (dns.name.Name, dns.tsig.Key) pairs
    into a text keyring which has (textual DNS name, (textual algorithm,
    base64 secret)) pairs, or a dictionary containing (dns.name.Name, bytes)
    pairs into a text keyring which has (textual DNS name, base64 secret) pairs.
    @rtype: dictc                 S   s   t  | ¡ ¡  ¡ S )N)Úbase64ÚencodebytesÚdecodeÚrstrip)r   r   r   r   Ú	b64encode6   s   zto_text.<locals>.b64encode)r   Úto_textr
   Úbytesr   r   r   )r   r   r   r   ÚkeyÚtnameÚtext_secretr   r   r   r   -   s   

r   )Ú__doc__r   Útypingr   r   Údns.namer   Údns.tsigr   r   ÚNamer   r   r	   r   r   r   r   r   Ú<module>   s   **