f,dZddlZddlZddlZddlZddlZddlZddlZddl ZGddejjZ GddejjZ GddejjZGd d ejjZGd d ejjZGd deZGddeZGddeZGddeZej*j-dZej*j-dZej*j-dZej*j-dZej*j-dZej*j-dZej*j-dZej*j-dZej*j-dZej*j-dZ 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( d6d0Z)d1Z*Gd2d3Z+y)7zDNS TSIG support.NceZdZdZy)BadTimez8The current time is not within the TSIG's validity time.N__name__ __module__ __qualname____doc__Q/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/dns/tsig.pyrrsBr rceZdZdZy) BadSignaturez#The TSIG signature fails to verify.Nrr r r rr#s-r rceZdZdZy)BadKeyz2The TSIG record owner name does not match the key.Nrr r r rr'ss r r.zGSSTSigAdapter.__init__s  r c||jvrM|j|}t|tr,|jtk(r|rt j ||||Syr0)r> isinstanceKey algorithmGSS_TSIGr<parse_tkey_and_step)r-messagekeynamekeys r __call__zGSSTSigAdapter.__call__sN dll ",,w'C#s# (A"66sGWMJr c |j|j|tjjtj j }|r,|dj}|j}|j|Sy#t$rYywxYw)Nr) find_rrsetanswerdns rdataclassANY rdatatypeTKEYrGsecretstepKeyError)clsrGrErFrrsettokenr*s r rDz"GSSTSigAdapter.parse_tkey_and_steps} &&););S]]=O=OEa !$%**511   sA;A?? B  B N)rrrr.rH classmethodrDr r r r<r<s r r<ceZdZdZeej eeje eje ejdfe ejeejdfeej eej dfeej&i ZdZdZdZdZy ) HMACTSigzo HMAC TSIG implementation. This uses the HMAC python module to handle the sign/verify operations. r&c |j|}t|tr*t j ||d|_|d|_n#t j |||_d|_|jj|_ |jr#|xjd|jz c_ yy#t$rtd|dwxYw)NzTSIG algorithm z is not supportedr) digestmod-) _hashesrSNotImplementedErrorr@tuplehmacnew hmac_contextsizer,)r-rGrBhashinfos r r.zHMACTSig.__init__s V||I.H h & $ DD   DI $ AD DI%%** 99 II1TYYK (I  V% {BS&TU U Vs B99Cc8|jj|Sr0)rer2r1s r r2zHMACTSig.updates  ''--r cv|jj}|jr|d|jdz}|S)N)redigestrf)r-rks r r5z HMACTSig.signs7""))+ 99.tyyA~/F r c\|j}tj||styr0)r5rccompare_digestr)r-r9macs r r:zHMACTSig.verifys(iik""31 2r N)rrrr HMAC_SHA1hashlibsha1 HMAC_SHA224sha224 HMAC_SHA256sha256HMAC_SHA256_128 HMAC_SHA384sha384HMAC_SHA384_192 HMAC_SHA512sha512HMAC_SHA512_256HMAC_MD5md5r`r.r2r5r:r r r rYrYs 7<<W^^W^^'..#.W^^'..#.W^^'..#.'++ G)".r rYc|xr| }|rLt|}|r?|jtjdt ||j||jtjd|j |j|dd|r|j|j j|jtjdtjj|jtjdd| |j}|dz dz}|dz} tjd || |j} t |j} | dkDr td |rk|j|jj| z|jtjd |j | |jz|S|j| |S) 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 !HNz!Irr!ilz!HIHz TSIG Other Data is > 65535 bytesz!HH) get_contextr2structpacklen original_idr, to_digestablerLrMrN time_signedfudgeother ValueErrorrBerror) wirerGrdatatime request_macctxmultifirst upper_time lower_time time_encoded other_lens r _digestrs E #  JJv{{4[)9: ; JJ{ #JJv{{4!2!234JJtABx  388))+, 6;;tS^^%7%789 6;;tQ'( |  "*&J "J;;vz:u{{KLEKK I5;<<  3==..0<?@ 6;;uekk9= KL J < Jr c|rLt|}|jtjdt ||j||Sy)zIf this is the first message in a multi-message sequence, start a new context. @rtype: dns.tsig.HMACTSig or dns.tsig.GSSTSig object rN)rr2rrr)rGrnrrs r _maybe_start_digestrs?  # 6;;tSX./ 3 r c 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 )rrn)rr5replacer) rrGrrrrrrntsigs r r5r5sL $UD+sE BC ((*C ==Ts= 3D %c36 77r c tjd|dd\} | dk(rtjj| dz} |ddtj d| z|d|z} |j dk7r|j tjjk(rt|j tjjk(rt|j tjjk(rt|j tjjk(rtt!d|j zt#|j$|z |j&kDrt(|j*|k7rt,|j.|j.k7rt0t3| ||d|||}|j5|j6t9||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)runpackrL exception FormErrorrrrcodeBADSIGrBADKEYrBADTIMErBADTRUNCrrabsrrrr,rrBrrr:rnr) rrGownerrnowr tsig_startrradcountnew_wires r validatersutT"R[1JW!|mm%%% qLGAbzFKKg66b9LLH {{a ;;#))** *" " [[CII,, ,  [[CII-- -  [[CII.. .# #85;;FG G 5  s "#ekk1  xx5  }}' (Ck3 FCJJuyy sEIIu 55r c|jtk(rt|jSt |j|jS)zReturns an HMAC context for the specified key. @rtype: HMAC context @raises NotImplementedError: I{algorithm} is not supported )rBrCr(rQrY)rGs r rr:s4 }} szz"" CMM22r c"eZdZefdZdZdZy)rAcPt|trtjj |}||_t|tr#t j |j}||_t|trtjj |}||_ yr0) r@strrLr, from_textbase64 decodebytesencoderQrB)r-r,rQrBs r r.z Key.__init__Hss dC 88%%d+D fc "'' 8F i %**95I"r ct|txrO|j|jk(xr4|j|jk(xr|j|jk(Sr0)r@rAr,rQrB)r-rs r __eq__z Key.__eq__SsR uc " 2 UZZ' 2 u||+ 2%//1  r cd|jdd|jdz}|jtk7r4|dtj|j j dz }|dz }|S)Nz@11h F  8"LQ#6L 3r