AlkantarClanX12

Your IP : 18.116.89.8


Current Path : /usr/lib64/python2.7/site-packages/dns/
Upload File :
Current File : //usr/lib64/python2.7/site-packages/dns/tsig.pyc

�
;�>Sc@s�dZddlZddlZddlZddlZddlZddlZddlZdej	j
fd��YZdej	j
fd��YZdej	j
fd��YZ
d	e
fd
��YZde
fd��YZd
e
fd��YZde
fd��YZejjd�Zejjd�Zejjd�Zejjd�Zejjd�Zejjd�ZeZdZdZdZdZde e!ed�Z"de e!ed�Z#de e!d�Z$da%d�Z&d�Z'd �Z(d!�Z)dS("sDNS TSIG support.i����NtBadTimecBseZdZRS(sBRaised if the current time is not within the TSIG's validity time.(t__name__t
__module__t__doc__(((s./usr/lib64/python2.7/site-packages/dns/tsig.pyRstBadSignaturecBseZdZRS(s-Raised if the TSIG signature fails to verify.(RRR(((s./usr/lib64/python2.7/site-packages/dns/tsig.pyRst	PeerErrorcBseZdZRS(s;Base class for all TSIG errors generated by the remote peer(RRR(((s./usr/lib64/python2.7/site-packages/dns/tsig.pyR#st
PeerBadKeycBseZdZRS(s.Raised if the peer didn't know the key we used(RRR(((s./usr/lib64/python2.7/site-packages/dns/tsig.pyR'stPeerBadSignaturecBseZdZRS(s4Raised if the peer didn't like the signature we sent(RRR(((s./usr/lib64/python2.7/site-packages/dns/tsig.pyR+stPeerBadTimecBseZdZRS(s/Raised if the peer didn't like the time we sent(RRR(((s./usr/lib64/python2.7/site-packages/dns/tsig.pyR/stPeerBadTruncationcBseZdZRS(sGRaised if the peer didn't like amount of truncation in the TSIG we sent(RRR(((s./usr/lib64/python2.7/site-packages/dns/tsig.pyR	3ssHMAC-MD5.SIG-ALG.REG.INTs	hmac-sha1shmac-sha224shmac-sha256shmac-sha384shmac-sha512iiiic
CsFt|�\}
}|rqtj|d|�}	t|�}|dkrq|	jtjd|��|	j|�qqntjd|�}|	j|�|	j|d�|r�|	j|j��|	jtjdtj	j
��|	jtjdd��n|d}|d?d@}|d	@}tjd
|||�}|
|}t|�}|dkr`td��ntjd
||�|}|r�|	j|�|	j|�n
|	j|�|	j�}tjdt|��}|||||}|
r3tj|d|�}	t|�}|	jtjd|��|	j|�nd}	|||	fS(sjReturn 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, string, hmac.HMAC object)
    @raises ValueError: I{other_data} is too long
    @raises NotImplementedError: I{algorithm} is not supported
    t	digestmodis!His!Ili l�l��s!HIHi��s TSIG Other Data is > 65535 bytess!HHN(t
get_algorithmthmactnewtlentupdatetstructtpackt
to_digestabletdnst
rdataclasstANYt
ValueErrortdigesttNone(twiretkeynametsecretttimetfudgetoriginal_idterrort
other_datatrequest_mactctxtmultitfirstt	algorithmtalgorithm_nameR
tmltidt	long_timet
upper_timet
lower_timettime_mactpre_mactoltpost_mactmactmpackt
tsig_rdata((s./usr/lib64/python2.7/site-packages/dns/tsig.pytsignGsJ





c

Cs.t||||||||||	|
||�
S(N(R3(
RRRRRRRR R!R"R#R$R%((s./usr/lib64/python2.7/site-packages/dns/tsig.pythmac_md5zscCs\tjd|dd!�\}|dkr7tjj�n|d8}|dd!tjd|�|d|!}|}
tjj||
�\}}|
|}
tjd||
|
d!�\}}}}|dd>|d}|
d7}
||
|
|!}|
|7}
tjd	||
|
d
!�\}}}|
d
7}
||
|
|!}|
|7}
|
||krbtjj�n|dkr�|tkr�t	�q�|t
kr�t�q�|tkr�t
�q�|tkr�t�q�td|��n||}||}||ks||kr
t�nt|||||||||||	|
|�
\}}}||krXt�n|S(s*Validate 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: hmac.HMAC objects!Hi
iiis!HIHHli s!HHHisunknown TSIG error code %d(RtunpackRt	exceptiont	FormErrorRtnamet	from_wiretBADSIGRtBADKEYRtBADTIMERtBADTRUNCR	RRR3R(RRRtnowR!t
tsig_startR2t
tsig_rdlenR"R#R$tadcounttnew_wiretcurrenttanametusedR*R+Rtmac_sizeRR0RRt
other_sizeR ttime_lowt	time_hightjunktour_mac((s./usr/lib64/python2.7/site-packages/dns/tsig.pytvalidate�sN

(
)

&

				

			cCs2ytjj|�t|<Wntk
r-nXdS(N(Rthashtgett_hashestKeyError(ttsig_algthash_alg((s./usr/lib64/python2.7/site-packages/dns/tsig.pyt_maybe_add_hash�s
cCsXiattd�ttd�ttd�ttd�ttd�ttd�dS(NtSHA224tSHA256tSHA384tSHA512tSHA1tMD5(RORStHMAC_SHA224tHMAC_SHA256tHMAC_SHA384tHMAC_SHA512t	HMAC_SHA1tHMAC_MD5(((s./usr/lib64/python2.7/site-packages/dns/tsig.pyt
_setup_hashes�s




cCs�tdkrt�nt|ttf�r@tjj|�}nt	j
dkr�|tksg|tkr�t
dt|�d��ny|j�t|fSWn+tk
r�t
dt|�d��nXdS(s�Returns the wire format string and the hash module to use for the
    specified TSIG algorithm

    @rtype: (string, hash constructor)
    @raises NotImplementedError: I{algorithm} is not supported
    isTSIG algorithm s requires Python 2.5.2 or laters is not supportedN(RORR`t
isinstancetstrtunicodeRR8t	from_texttsyst
hexversionR\R]tNotImplementedErrorRRP(R%((s./usr/lib64/python2.7/site-packages/dns/tsig.pyR�s	


cCs�|}tjj||�\}}||}tjd|||d!�\}}}}	|d7}||||	!}
||	7}|||kr�tjj�n||
fS(slReturn the tsig algorithm for the specified tsig_rdata
    @raises FormError: The TSIG is badly formed.
    s!HIHHi
(RR8R9RR5R6R7(RR2R@RCRDRER*R+RRFR0((s./usr/lib64/python2.7/site-packages/dns/tsig.pytget_algorithm_and_mac�s
)

(*RRRRet
dns.exceptionRtdns.hashtdns.rdataclasstdns.nameR6tDNSExceptionRRRRRRR	R8RdR_R^RZR[R\R]tdefault_algorithmR:R;R<R=RtFalsetTrueR3R4RLRORSR`RRh(((s./usr/lib64/python2.7/site-packages/dns/tsig.pyt<module>sF	2	4