%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/dns/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/dns/__pycache__/tsig.cpython-312.pyc

�

5��e�,���dZddlZddlZddlZddlZddlZddlZddlZddl	ZGd�dejj�ZGd�dejj�Z
Gd�dejj�ZGd	�d
ejj�ZGd�dejj�ZGd
�de�ZGd�de�ZGd�de�ZGd�de�Zej*j-d�Zej*j-d�Zej*j-d�Zej*j-d�Zej*j-d�Zej*j-d�Zej*j-d�Zej*j-d�Zej*j-d�Zej*j-d�Z eZ!eded ed!ed"ed#ed$ed%ed!ed"e d&i
Z"Gd'�d(�Z#Gd)�d*�Z$Gd+�d,�Z%d4d-�Z&d.�Z'd5d/�Z(	d6d0�Z)d1�Z*Gd2�d3�Z+y)7zDNS TSIG support.�Nc��eZdZdZy)�BadTimez8The current time is not within the TSIG's validity time.N��__name__�
__module__�__qualname__�__doc__���*/usr/lib/python3/dist-packages/dns/tsig.pyrrs��Brrc��eZdZdZy)�BadSignaturez#The TSIG signature fails to verify.Nrr
rrrr#s��-rrc��eZdZdZy)�BadKeyz2The TSIG record owner name does not match the key.Nrr
rrrr's��<rrc��eZdZdZy)�BadAlgorithmz*The TSIG algorithm does not match the key.Nrr
rrrr+���4rrc��eZdZdZy)�	PeerErrorz;Base class for all TSIG errors generated by the remote peerNrr
rrrr/s��Errc��eZdZdZy)�
PeerBadKeyz$The peer didn't know the key we usedNrr
rrrr3s��.rrc��eZdZdZy)�PeerBadSignaturez*The peer didn't like the signature we sentNrr
rrrr7rrrc��eZdZdZy)�PeerBadTimez%The peer didn't like the time we sentNrr
rrrr;s��/rrc��eZdZdZy)�PeerBadTruncationz=The peer didn't like amount of truncation in the TSIG we sentNrr
rrrr?s��GrrzHMAC-MD5.SIG-ALG.REG.INTz	hmac-sha1zhmac-sha224zhmac-sha256zhmac-sha256-128zhmac-sha384zhmac-sha384-192zhmac-sha512zhmac-sha512-256�gss-tsig��� ��0��@�c�(�eZdZdZd�Zd�Zd�Zd�Zy)�GSSTSigaG
    GSS-TSIG TSIG implementation.  This uses the GSS-API context established
    in the TKEY message handshake to sign messages using GSS-API message
    integrity codes, per the RFC.

    In order to avoid a direct GSSAPI dependency, the keyring holds a ref
    to the GSSAPI object required, rather than the key itself.
    c�.�||_d|_d|_y)Nrr)�gssapi_context�data�name)�selfr*s  r�__init__zGSSTSig.__init__js��,�����	���	rc�.�|xj|z
c_y�N)r+�r-r+s  r�updatezGSSTSig.updateos���	�	�T��	rc�L�|jj|j�Sr0)r*�
get_signaturer+)r-s r�signzGSSTSig.signrs���"�"�0�0����;�;rc�v�	|jj|j|�S#t$rt�wxYwr0)r*�verify_signaturer+�	Exceptionr)r-�expecteds  r�verifyzGSSTSig.verifyvs9��	��&�&�7�7��	�	�8�L�L���	���	�s�%(�8N)rrrr	r.r2r5r:r
rrr(r(`s����
�<�rr(c�(�eZdZd�Zd�Zed��Zy)�GSSTSigAdapterc��||_yr0)�keyring)r-r>s  rr.zGSSTSigAdapter.__init__�s	����rc��||jvrM|j|}t|t�r,|jtk(r|rt
j
|||�|Syr0)r>�
isinstance�Key�	algorithm�GSS_TSIGr<�parse_tkey_and_step)r-�message�keyname�keys    r�__call__zGSSTSigAdapter.__call__�sN���d�l�l�"��,�,�w�'�C��#�s�#��
�
��(A��"�6�6�s�G�W�M��J�rc��	|j|j|tjjtj
j�}|r,|dj}|j}|j|�Sy#t$rYywxYw)Nr)�
find_rrset�answer�dns�
rdataclass�ANY�	rdatatype�TKEYrG�secret�step�KeyError)�clsrGrErF�rrset�tokenr*s       rrDz"GSSTSigAdapter.parse_tkey_and_step�s}��		��&�&��������);�);�S�]�]�=O�=O��E���a�����!$����%�*�*�5�1�1����	��	�s�A;A?�?	B�
BN)rrrr.rH�classmethodrDr
rrr<r<s �������rr<c��eZdZdZeejeeje	ejeejdfeejeejdfeej eej dfeej&i	Zd�Zd�Zd�Zd�Zy	)
�HMACTSigzo
    HMAC TSIG implementation.  This uses the HMAC python module to handle the
    sign/verify operations.
    r&��c��	|j|}t|t�r*tj||d��|_|d|_n#tj||��|_d|_|jj|_	|jr#|xjd|j��z
c_	yy#t$rtd|�d���wxYw)NzTSIG algorithm z is not supportedr)�	digestmod��-)
�_hashesrS�NotImplementedErrorr@�tuple�hmac�new�hmac_context�sizer,)r-rGrB�hashinfos    rr.zHMACTSig.__init__�s���	V��|�|�I�.�H�
�h��&� $������� D�D�� ���D�I� $����� A�D���D�I��%�%�*�*��	��9�9��I�I�1�T�Y�Y�K��(�I����	V�%��	�{�BS�&T�U�U�	V�s�B9�9Cc�8�|jj|�Sr0)rer2r1s  rr2zHMACTSig.update�s��� � �'�'��-�-rc�v�|jj�}|jr|d|jdz}|S)N�)re�digestrf)r-rks  rr5z
HMACTSig.sign�s7���"�"�)�)�+���9�9��.�t�y�y�A�~�/�F��
rc�\�|j�}tj||�st�yr0)r5rc�compare_digestr)r-r9�macs   rr:zHMACTSig.verify�s(���i�i�k���"�"�3��1���2rN)rrrr	�	HMAC_SHA1�hashlib�sha1�HMAC_SHA224�sha224�HMAC_SHA256�sha256�HMAC_SHA256_128�HMAC_SHA384�sha384�HMAC_SHA384_192�HMAC_SHA512�sha512�HMAC_SHA512_256�HMAC_MD5�md5r`r.r2r5r:r
rrrYrY�s����	�7�<�<��W�^�^��W�^�^��'�.�.�#�.��W�^�^��'�.�.�#�.��W�^�^��'�.�.�#�.��'�+�+�
�G�)�".��rrYc��|xr|}|rLt|�}|r?|jtjdt	|���|j|�|jtjd|j
��|j|dd�|r�|j|jj��|jtjdtjj��|jtjdd��|�|j}|dz	dz}|dz}	tjd	||	|j�}
t	|j�}|dkDrtd
��|rk|j|jj�|
z�|jtjd|j |�|jz�|S|j|
�|S)z�Return a context containing the TSIG rdata for the input parameters
    @rtype: dns.tsig.HMACTSig or dns.tsig.GSSTSig object
    @raises ValueError: I{other_data} is too long
    @raises NotImplementedError: I{algorithm} is not supported
    �!H�Nz!Irr!i��l��z!HIHz TSIG Other Data is > 65535 bytesz!HH)�get_contextr2�struct�pack�len�original_idr,�
to_digestablerLrMrN�time_signed�fudge�other�
ValueErrorrB�error)�wirerG�rdata�time�request_mac�ctx�multi�first�
upper_time�
lower_time�time_encoded�	other_lens            r�_digestr��s�������E���#�����J�J�v�{�{�4��[�)9�:�;��J�J�{�#��J�J�v�{�{�4��!2�!2�3�4��J�J�t�A�B�x����
�
�3�8�8�)�)�+�,��
�
�6�;�;�t�S�^�^�%7�%7�8�9��
�
�6�;�;�t�Q�'�(��|�� � ���"�*��&�J��
�"�J��;�;�v�z�:�u�{�{�K�L��E�K�K� �I��5���;�<�<���
�
�3�=�=�.�.�0�<�?�@��
�
�6�;�;�u�e�k�k�9�=����K�L��J�	�
�
�<� ��Jrc��|rLt|�}|jtjdt	|���|j|�|Sy)z�If this is the first message in a multi-message sequence,
    start a new context.
    @rtype: dns.tsig.HMACTSig or dns.tsig.GSSTSig object
    r�N)r�r2r�r�r�)rGrnr�r�s    r�_maybe_start_digestr��s?��

��#����
�
�6�;�;�t�S��X�.�/��
�
�3���
�rc	��t|||||||�}|j�}|j||��}|t|||�fS)a~Return a (tsig_rdata, mac, ctx) tuple containing the HMAC TSIG rdata
    for the input parameters, the HMAC MAC calculated by applying the
    TSIG signature algorithm, and the TSIG digest context.
    @rtype: (string, dns.tsig.HMACTSig or dns.tsig.GSSTSig object)
    @raises ValueError: I{other_data} is too long
    @raises NotImplementedError: I{algorithm} is not supported
    )r�rn)r�r5�replacer�)	r�rGr�r�r�r�r�rn�tsigs	         rr5r5sL���$��U�D�+�s�E�
B�C�

�(�(�*�C��=�=�T�s�=�3�D��%�c�3��6�7�7rc		��tjd|dd�\}	|	dk(rtjj�|	dz}	|ddtj
d|	�z|d|z}
|jdk7r�|jtjjk(rt�|jtjjk(rt�|jtjjk(rt�|jtjjk(rt�t!d|jz��t#|j$|z
�|j&kDrt(�|j*|k7rt,�|j.|j.k7rt0�t3|
||d|||�}|j5|j6�t9||j6|�S)aFValidate the specified TSIG rdata against the other input parameters.

    @raises FormError: The TSIG is badly formed.
    @raises BadTime: There is too much time skew between the client and the
    server.
    @raises BadSignature: The TSIG signature did not validate
    @rtype: dns.tsig.HMACTSig or dns.tsig.GSSTSig objectr��
�rr^zunknown TSIG error code %dN)r��unpackrL�	exception�	FormErrorr�r��rcode�BADSIGr�BADKEYr�BADTIMEr�BADTRUNCrr�absr�r�rr,rrBrr�r:rnr�)r�rG�ownerr��nowr��
tsig_startr�r��adcount�new_wires           r�validater�su�����t�T�"�R�[�1�J�W��!�|��m�m�%�%�%��q�L�G��A�b�z�F�K�K��g�6�6��b��9L�L�H��{�{�a���;�;�#�)�)�*�*�*�"�"�
�[�[�C�I�I�,�,�
,���
�[�[�C�I�I�-�-�
-���
�[�[�C�I�I�.�.�
.�#�#��8�5�;�;�F�G�G�
�5���s�"�#�e�k�k�1��
�
�x�x�5����
�}�}����'���
�(�C���k�3��
F�C��J�J�u�y�y���s�E�I�I�u�5�5rc��|jtk(rt|j�St	|j|j�S)z�Returns an HMAC context for the specified key.

    @rtype: HMAC context
    @raises NotImplementedError: I{algorithm} is not supported
    )rBrCr(rQrY)rGs rr�r�:s4���}�}�� ��s�z�z�"�"���
�
�C�M�M�2�2rc�"�eZdZefd�Zd�Zd�Zy)rAc�P�t|t�rtjj	|�}||_t|t�r#tj|j��}||_t|t�rtjj	|�}||_	yr0)
r@�strrLr,�	from_text�base64�decodebytes�encoderQrB)r-r,rQrBs    rr.zKey.__init__Hss���d�C� ��8�8�%�%�d�+�D���	��f�c�"��'�'��
�
��8�F�����i��%����*�*�9�5�I�"��rc���t|t�xrO|j|jk(xr4|j|jk(xr|j|jk(Sr0)r@rAr,rQrB)r-r�s  r�__eq__z
Key.__eq__SsR���u�c�"�
2��	�	�U�Z�Z�'�
2����u�|�|�+�
2����%�/�/�1�		
rc���d|j�d�d|j�d�z}|jtk7r4|dtj|j
�j
��d�z
}|dz
}|S)Nz<DNS key name='z', zalgorithm='�'z
, secret='�>)r,rBrCr��	b64encoderQ�decode)r-�rs  r�__repr__zKey.__repr__[sm���d�i�i�[��,��T�^�^�<L�A�/N�N���>�>�X�%�
�:�f�.�.�t�{�{�;�B�B�D�E�Q�G�G�A�	�S����rN)rrr�default_algorithmr.r�r�r
rrrArAGs��/@�	#�
�rrA)NNNN)NNNF)NF),r	r�rprcr��
dns.exceptionrL�dns.name�	dns.rcode�dns.rdataclassr��DNSExceptionrrrrrrrrrr,r�r}rorrrtrvrwryrzr|rCr��	mac_sizesr(r<rYr�r�r5r�r�rAr
rr�<module>r�s!��$�
���
�����C�c�m�m�(�(�C�.�3�=�=�-�-�.�=�S�]�]�
'�
'�=�5�3�=�=�-�-�5�F��
�
�*�*�F�/��/�5�y�5�0�)�0�H�	�H��8�8���8�9���H�H���{�+�	��h�h� � ��/���h�h� � ��/���(�(�$�$�%6�7���h�h� � ��/���(�(�$�$�%6�7���h�h� � ��/���(�(�$�$�%6�7���8�8���j�)�����r������R����R����R��b��c�
�	���>��@1�1�h �F�
8�"LQ�#6�L
3��r

Zerion Mini Shell 1.0