HEX
Server: LiteSpeed
System: Linux srv146.niagahoster.com 4.18.0-553.30.1.lve.el8.x86_64 #1 SMP Tue Dec 3 01:21:19 UTC 2024 x86_64
User: kodi1989 (1633)
PHP: 8.1.34
Disabled: symlink,shell_exec,exec,popen,system,dl,passthru,escapeshellarg,escapeshellcmd,show_source,pcntl_exec
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/dns/__pycache__/tsig.cpython-37.pyc
B

��f�,�@s�dZddlZddlZddlZddlZddlZddlZddlZddl	ZGdd�dej
j�ZGdd�dej
j�Z
Gdd�dej
j�ZGd	d
�d
ej
j�ZGdd�dej
j�ZGd
d�de�ZGdd�de�ZGdd�de�ZGdd�de�Zej�d�Zej�d�Zej�d�Zej�d�Zej�d�Zej�d�Zej�d�Zej�d�Zej�d�Zej�d�Z eZ!eded ed!ed"ed#ed$ed%ed!ed"e d&i
Z"Gd'd(�d(�Z#Gd)d*�d*�Z$Gd+d,�d,�Z%d:d-d.�Z&d/d0�Z'd;d2d3�Z(d<d4d5�Z)d6d7�Z*Gd8d9�d9�Z+dS)=zDNS TSIG support.�Nc@seZdZdZdS)�BadTimez8The current time is not within the TSIG's validity time.N)�__name__�
__module__�__qualname__�__doc__�rr�9/opt/alt/python37/lib/python3.7/site-packages/dns/tsig.pyrsrc@seZdZdZdS)�BadSignaturez#The TSIG signature fails to verify.N)rrrrrrrrr	$sr	c@seZdZdZdS)�BadKeyz2The TSIG record owner name does not match the key.N)rrrrrrrrr
)sr
c@seZdZdZdS)�BadAlgorithmz*The TSIG algorithm does not match the key.N)rrrrrrrrr.src@seZdZdZdS)�	PeerErrorz;Base class for all TSIG errors generated by the remote peerN)rrrrrrrrr3src@seZdZdZdS)�
PeerBadKeyz$The peer didn't know the key we usedN)rrrrrrrrr
8sr
c@seZdZdZdS)�PeerBadSignaturez*The peer didn't like the signature we sentN)rrrrrrrrr=src@seZdZdZdS)�PeerBadTimez%The peer didn't like the time we sentN)rrrrrrrrrBsrc@seZdZdZdS)�PeerBadTruncationz=The peer didn't like amount of truncation in the TSIG we sentN)rrrrrrrrrGsrzHMAC-MD5.SIG-ALG.REG.INTz	hmac-sha1zhmac-sha224zhmac-sha256zhmac-sha256-128zhmac-sha384zhmac-sha384-192zhmac-sha512zhmac-sha512-256zgss-tsig��� ��0��@�c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�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.
    cCs||_d|_d|_dS)N�zgss-tsig)�gssapi_context�data�name)�selfrrrr�__init__sszGSSTSig.__init__cCs|j|7_dS)N)r)rrrrr�updatexszGSSTSig.updatecCs|j�|j�S)N)rZ
get_signaturer)rrrr�sign{szGSSTSig.signcCs.y|j�|j|�Stk
r(t�YnXdS)N)rZverify_signaturer�	Exceptionr	)r�expectedrrr�verifyszGSSTSig.verifyN)rrrrrr r!r$rrrrris
rc@s(eZdZdd�Zdd�Zedd��ZdS)�GSSTSigAdaptercCs
||_dS)N)�keyring)rr&rrrr�szGSSTSigAdapter.__init__cCsF||jkr>|j|}t|t�r:|jtkr:|r:t�|||�|SdSdS)N)r&�
isinstance�Key�	algorithm�GSS_TSIGr%�parse_tkey_and_step)r�message�keyname�keyrrr�__call__�s

zGSSTSigAdapter.__call__cCsVy<|�|j|tjjtjj�}|r:|dj}|j}|�	|�SWnt
k
rPYnXdS)Nr)Z
find_rrsetZanswer�dns�
rdataclass�ANYZ	rdatatypeZTKEYr.�secret�step�KeyError)�clsr.r,r-Zrrset�tokenrrrrr+�s
z"GSSTSigAdapter.parse_tkey_and_stepN)rrrrr/�classmethodr+rrrrr%�s
r%c@sveZdZdZeejeeje	ej
eej
dfeej
eej
dfeejeejdfeeji	Zdd�Zdd�Zd	d
�Zdd�Zd
S)�HMACTSigzo
    HMAC TSIG implementation.  This uses the HMAC python module to handle the
    sign/verify operations.
    r��cCs�y|j|}Wn(tk
r6td|�d�d��YnXt|t�rbtj||dd�|_|d|_ntj||d�|_d|_|jj	|_	|jr�|j	d|j��7_	dS)NzTSIG algorithm � zis not supportedr)�	digestmod��-)
�_hashesr5�NotImplementedErrorr'�tuple�hmac�new�hmac_context�sizer)rr.r)Zhashinforrrr�s

zHMACTSig.__init__cCs|j�|�S)N)rEr )rrrrrr �szHMACTSig.updatecCs&|j��}|jr"|d|jd�}|S)N�)rE�digestrF)rrHrrrr!�s
z
HMACTSig.signcCs|��}t�||�st�dS)N)r!rC�compare_digestr	)rr#�macrrrr$�szHMACTSig.verifyN)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@rr r!r$rrrrr9�s



r9cCs0|o|}|r:t|�}|r:|�t�dt|���|�|�|�t�d|j��|�|dd��|r�|�|j���|�t�dtj	j
��|�t�dd��|dkr�|j}|d?d@}|d@}	t�d	||	|j�}
t|j
�}|dkr�td
��|�r"|�|j��|
�|�t�d|j|�|j
�n
|�|
�|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
    z!H�Nz!Irri��l��z!HIHz TSIG Other Data is > 65535 bytesz!HH)�get_contextr �struct�pack�lenZoriginal_idrZ
to_digestabler0r1r2�time_signed�fudge�other�
ValueErrorr)�error)�wirer.�rdata�time�request_mac�ctx�multi�firstZ
upper_timeZ
lower_timeZtime_encodedZ	other_lenrrr�_digest�s2



rlcCs8|r0t|�}|�t�dt|���|�|�|SdSdS)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
    z!HN)r\r r]r^r_)r.rJrjrirrr�_maybe_start_digests
rmFc	Cs:t|||||||�}|��}|j||d�}|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`rJ)rlr!�replacerm)	rer.rfrgrhrirjrJZtsigrrrr!s	r!c	Cst�d|dd��\}	|	dkr&tjj�|	d8}	|dd�t�d|	�|d|�}
|jdkr�|jtjjkrpt	�nJ|jtjj
kr�t�n6|jtjjkr�t
�n"|jtjjkr�t�ntd|j��t|j|�|jkr�t�|j|kr�t�|j|jkr�t�t|
||d|||�}|�|j�t||j|�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 objectz!H�
�rr>zunknown TSIG error code %dN)r]�unpackr0�	exceptionZ	FormErrorr^rdZrcodeZBADSIGrZBADKEYr
ZBADTIMErZBADTRUNCrr�absr`rarrr
r)rrlr$rJrm)rer.�ownerrf�nowrhZ
tsig_startrirjZadcountZnew_wirerrr�validates0$

rvcCs&|jtkrt|j�St|j|j�SdS)z�Returns an HMAC context for the specified key.

    @rtype: HMAC context
    @raises NotImplementedError: I{algorithm} is not supported
    N)r)r*rr3r9)r.rrrr\Es

r\c@s(eZdZefdd�Zdd�Zdd�ZdS)r(cCsZt|t�rtj�|�}||_t|t�r4t�|���}||_t|t�rPtj�|�}||_	dS)N)
r'�strr0r�	from_text�base64�decodebytes�encoder3r))rrr3r)rrrrSs


zKey.__init__cCs.t|t�o,|j|jko,|j|jko,|j|jkS)N)r'r(rr3r))rrbrrr�__eq__^s
z
Key.__eq__cCsNd|j�d�d|j�d�}|jtkrB|dt�|j����d�7}|d7}|S)Nz<DNS key name='z', zalgorithm='�'z
, secret='�>)rr)r*ry�	b64encoder3�decode)r�rrrr�__repr__fs

zKey.__repr__N)rrr�default_algorithmrr|r�rrrrr(Rsr()NNNN)NNNF)NF),rryrLrCr]Z
dns.exceptionr0Zdns.rdataclassZdns.nameZ	dns.rcoderrZDNSExceptionrr	r
rrr
rrrrrxrYrKrNrPrRrSrUrVrXr*r�Z	mac_sizesrr%r9rlrmr!rvr\r(rrrr�<module>s^ 6
#

%