
    _?i8-                        S r SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK	rSSK
r " S S\R                  R                  5      r " S S\R                  R                  5      r " S S\R                  R                  5      r " S	 S
\R                  R                  5      r " S S\R                  R                  5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r\R,                  R/                  S5      r\R,                  R/                  S5      r\R,                  R/                  S5      r\R,                  R/                  S5      r\R,                  R/                  S5      r\R,                  R/                  S5      r\R,                  R/                  S5      r\R,                  R/                  S5      r\R,                  R/                  S5      r \R,                  R/                  S5      r!\r"\S\S \S!\S"\S#\S$\S%\ S!\S"\!S&0
r# " S' S(5      r$ " S) S*5      r% " S+ S,5      r&S4S- jr'S. r(S5S/ jr) S6S0 jr*S1 r+ " S2 S35      r,g)7zDNS TSIG support.    Nc                       \ rS rSrSrSrg)BadTime    z8The current time is not within the TSIG's validity time. N__name__
__module____qualname____firstlineno____doc____static_attributes__r       L/var/www/html/livechat/backend/venv/lib/python3.13/site-packages/dns/tsig.pyr   r       s    Br   r   c                       \ rS rSrSrSrg)BadSignature$   z#The TSIG signature fails to verify.r   Nr   r   r   r   r   r   $   s    -r   r   c                       \ rS rSrSrSrg)BadKey(   z2The TSIG record owner name does not match the key.r   Nr   r   r   r   r   r   (   s    <r   r   c                       \ rS rSrSrSrg)BadAlgorithm,   z*The TSIG algorithm does not match the key.r   Nr   r   r   r   r   r   ,       4r   r   c                       \ rS rSrSrSrg)	PeerError0   z;Base class for all TSIG errors generated by the remote peerr   Nr   r   r   r   r   r   0   s    Er   r   c                       \ rS rSrSrSrg)
PeerBadKey4   z$The peer didn't know the key we usedr   Nr   r   r   r   r   r   4   s    .r   r   c                       \ rS rSrSrSrg)PeerBadSignature8   z*The peer didn't like the signature we sentr   Nr   r   r   r   r!   r!   8   r   r   r!   c                       \ rS rSrSrSrg)PeerBadTime<   z%The peer didn't like the time we sentr   Nr   r   r   r   r$   r$   <   s    /r   r$   c                       \ rS rSrSrSrg)PeerBadTruncation@   z=The peer didn't like amount of truncation in the TSIG we sentr   Nr   r   r   r   r'   r'   @   s    Gr   r'   zHMAC-MD5.SIG-ALG.REG.INTz	hmac-sha1zhmac-sha224zhmac-sha256zhmac-sha256-128zhmac-sha384zhmac-sha384-192zhmac-sha512zhmac-sha512-256gss-tsig      r      r      r(      c                   0    \ rS rSrSrS rS rS rS rSr	g)	GSSTSiga   a/  
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                 ,    Xl         SU l        SU l        g )Nr   r)   )gssapi_contextdataname)selfr3   s     r   __init__GSSTSig.__init__k   s    ,		r   c                 .    U =R                   U-  sl         g N)r4   r6   r4   s     r   updateGSSTSig.updatep   s    		T	r   c                 L    U R                   R                  U R                  5      $ r:   )r3   get_signaturer4   )r6   s    r   signGSSTSig.signs   s    ""00;;r   c                 x     U R                   R                  U R                  U5      $ ! [         a    [        ef = fr:   )r3   verify_signaturer4   	Exceptionr   )r6   expecteds     r   verifyGSSTSig.verifyw   s9    	&&77		8LL 		s   %( 9)r4   r3   r5   N)
r   r	   r
   r   r   r7   r<   r@   rF   r   r   r   r   r0   r0   a   s    
<r   r0   c                   0    \ rS rSrS rS r\S 5       rSrg)GSSTSigAdapterr.   c                     Xl         g r:   keyring)r6   rL   s     r   r7   GSSTSigAdapter.__init__   s    r   c                     X R                   ;   aW  U R                   U   n[        U[        5      (       a1  UR                  [        :X  a  U(       a  [
        R                  X1U5        U$ g r:   )rL   
isinstanceKey	algorithmGSS_TSIGrI   parse_tkey_and_step)r6   messagekeynamekeys       r   __call__GSSTSigAdapter.__call__   sM    ll",,w'C#s##(A"66sWMJr   c                 (    UR                  UR                  U[        R                  R                  [        R
                  R                  5      nU(       a,  US   R                  nUR                  nUR                  U5      $ g ! [         a     g f = f)Nr   )
find_rrsetanswerdns
rdataclassANY	rdatatypeTKEYrV   secretstepKeyError)clsrV   rT   rU   rrsettokenr3   s          r   rS   "GSSTSigAdapter.parse_tkey_and_step   s}    		&&););S]]=O=OE a!$%**511   		s   B B 
BBrK   N)	r   r	   r
   r   r7   rW   classmethodrS   r   r   r   r   rI   rI      s       r   rI   c                      \ rS rSrSr\\R                  \\R                  \
\R                  \\R                  S4\\R                  \\R                  S4\\R"                  \\R"                  S4\\R(                  0	rS rS rS rS	 rS
rg)HMACTSig   zc
HMAC TSIG implementation.  This uses the HMAC python module to handle the
sign/verify operations.
r.         c                     U R                   U   n[        U[        5      (       a'  [
        R                  " XS   S9U l        US   U l        O [
        R                  " XS9U l        S U l        U R                  R                  U l	        U R                  (       a#  U =R                  SU R                   3-  sl	        g g ! [         a    [        SU S35      ef = f)NzTSIG algorithm z is not supportedr   )	digestmod   -)
_hashesrc   NotImplementedErrorrO   tuplehmacnewhmac_contextsizer5   )r6   rV   rQ   hashinfos       r   r7   HMACTSig.__init__   s    	V||I.H
 h&& $ DD DI $ ADDI%%**	99II1TYYK(I   	V%	{BS&TUU	Vs   B= =Cc                 8    U R                   R                  U5      $ r:   )rw   r<   r;   s     r   r<   HMACTSig.update   s      ''--r   c                     U R                   R                  5       nU R                  (       a  US U R                  S-   nU$ )N   )rw   digestrx   )r6   r   s     r   r@   HMACTSig.sign   s7    ""))+99.tyyA~/Fr   c                 f    U R                  5       n[        R                  " X!5      (       d  [        eg r:   )r@   ru   compare_digestr   )r6   rE   macs      r   rF   HMACTSig.verify   s)    iik""311 2r   )rw   r5   rx   N)r   r	   r
   r   r   	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md5rr   r7   r<   r@   rF   r   r   r   r   rj   rj      s     	7<<W^^W^^'..#.W^^'..#.W^^'..#.'++
G)".r   rj   c                 b   U=(       a    U(       + nU(       aR  [        U5      nU(       a@  UR                  [        R                  " S[	        U5      5      5        UR                  U5        Uc   eUR                  [        R                  " SUR
                  5      5        UR                  U SS 5        U(       a  UR                  UR                  R                  5       5        UR                  [        R                  " S[        R                  R                  5      5        UR                  [        R                  " SS5      5        Uc  UR                  nUS-	  S-  nUS-  n	[        R                  " S	XUR                  5      n
[	        UR                  5      nUS:  a  [        S
5      eU(       al  UR                  UR                  R                  5       U
-   5        UR                  [        R                  " SUR                   U5      UR                  -   5        U$ UR                  U
5        U$ )zReturn 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
!HN   z!Ir   r   i  l    z!HIHz TSIG Other Data is > 65535 bytesz!HH)get_contextr<   structpacklenoriginal_idr5   to_digestabler\   r]   r^   time_signedfudgeother
ValueErrorrQ   error)wirerV   rdatatimerequest_macctxmultifirst
upper_time
lower_timetime_encoded	other_lens               r   _digestr      s    E#JJv{{4[)9:;JJ{#??JJv{{4!2!234JJtABx

388))+,

6;;tS^^%7%789

6;;tQ'(|  "*&J
"J;;vzu{{KLEKK I5;<<

3==..0<?@

6;;uekk9=KL J 	

< Jr   c                     U(       aM  [        U 5      nUR                  [        R                  " S[	        U5      5      5        UR                  U5        U$ g)zIf 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   r<   r   r   r   )rV   r   r   r   s       r   _maybe_start_digestr      s?    
 #

6;;tSX./

3
r   c           	      x    [        XX#XEU5      nUR                  5       nUR                  X7S9nU[        XU5      4$ )af  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   r   )r   r@   replacer   )	r   rV   r   r   r   r   r   r   tsigs	            r   r@   r@     sB     $U+E
BC
((*C==T=3D%c677r   c	           	         [         R                  " SU SS 5      u  n	U	S:X  a  [        R                  R                  eU	S-  n	U SS [         R
                  " SU	5      -   U SU -   n
UR                  S:w  a  UR                  [        R                  R                  :X  a  [        eUR                  [        R                  R                  :X  a  [        eUR                  [        R                  R                  :X  a  [        eUR                  [        R                  R                  :X  a  [        e[!        SUR                   35      e[#        UR$                  U-
  5      UR&                  :  a  [(        eUR*                  U:w  a  [,        eUR.                  UR.                  :w  a  [0        e[3        XUSXWU5      nUR5                  UR6                  5        [9        XR6                  U5      $ )a2  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: dns.tsig.HMACTSig or dns.tsig.GSSTSig objectr   
      r   rp   zunknown TSIG error code N)r   unpackr\   	exception	FormErrorr   r   rcodeBADSIGr!   BADKEYr   BADTIMEr$   BADTRUNCr'   r   absr   r   r   r5   r   rQ   r   r   rF   r   r   )r   rV   ownerr   nowr   
tsig_startr   r   adcountnew_wires              r   validater     sq    tT"R[1JW!|mm%%%qLGAbzFKKg66b9LLH{{a;;#))***""[[CII,,,[[CII---[[CII...##6u{{mDEE
5s"#ekk1
xx5
}}'
(k
FCJJuyysIIu55r   c                     U R                   [        :X  a  [        U R                  5      $ [	        U R                  U R                   5      $ )zReturns an HMAC context for the specified key.

@rtype: HMAC context
@raises NotImplementedError: I{algorithm} is not supported
)rQ   rR   r0   ra   rj   )rV   s    r   r   r   <  s4     }} szz""

CMM22r   c                       \ rS rSr\4S\R                  R                  \-  S\	\-  S\R                  R                  \-  4S jjr
S rS rSrg	)
rP   iI  r5   ra   rQ   c                 j   [        U[        5      (       a  [        R                  R	                  U5      nXl        [        U[        5      (       a$  [
        R                  " UR                  5       5      nX l        [        U[        5      (       a  [        R                  R	                  U5      nX0l	        g r:   )
rO   strr\   r5   	from_textbase64decodebytesencodera   rQ   )r6   r5   ra   rQ   s       r   r7   Key.__init__J  sx     dC  88%%d+D	fc""''8Fi%%**95I"r   c                     [        U[        5      =(       aY    U R                  UR                  :H  =(       a9    U R                  UR                  :H  =(       a    U R                  UR                  :H  $ r:   )rO   rP   r5   ra   rQ   )r6   r   s     r   __eq__
Key.__eq__Z  sR    uc" 2		UZZ'2u||+2 %//1		
r   c                     SU R                    S3SU R                   S3-   nU R                  [        :w  a5  US[        R                  " U R
                  5      R                  5        S3-  nUS-  nU$ )Nz<DNS key name='z', zalgorithm=''z
, secret='>)r5   rQ   rR   r   	b64encodera   decode)r6   rs     r   __repr__Key.__repr__b  sm    dii[,T^^<LA/NN>>X%:f..t{{;BBDEQGGA	Sr   )rQ   r5   ra   N)r   r	   r
   r   default_algorithmr\   r5   Namer   bytesr7   r   r   r   r   r   r   rP   rP   I  sP    
 *;	#hhmmc!# # 88==3&	# 
r   rP   )NNNN)NNNF)NF)-r   r   r   ru   r   dns.exceptionr\   dns.name	dns.rcodedns.rdataclassdns.rdatatyper   DNSExceptionr   r   r   r   r   r   r!   r$   r'   r5   r   r   r   r   r   r   r   r   r   r   rR   r   	mac_sizesr0   rI   rj   r   r   r@   r   r   rP   r   r   r   <module>r      s$  $          Ccmm(( C.3==-- .=S]]'' =53==-- 5F** F/ /5y 50) 0H	 H 8889HH{+	hh  /hh  /(($$%67hh  /(($$%67hh  /(($$%6788j)  rRRRbc	 > @1 1h!H8" LQ#6L
3 r   