Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
3 ©ft`;,ã@sôddlmZddlmZddlmZddlmZddlZddlZddlZddl Z ddl m Z ddl Z ddlZ ejdƒZdZGd d „d e jjƒZdd d „ZGdd„deƒZGdd„dƒZGdd„dƒZGdd„dƒZdd„Zdd„ZGdd„dƒZdS)é)Úprint_function)Úabsolute_import)Úunicode_literals)ÚEnumN)Ú_Údnfé=c@seZdZdZdd„ZdS)Ú DnssecErrorz- Exception used in the dnssec module cCsdj|jdk r|jndƒS)Nzz Not specified)ÚformatÚvalue)Úself©r ú/usr/lib/python3.6/dnssec.pyÚ__repr__-szDnssecError.__repr__N)Ú__name__Ú __module__Ú __qualname__Ú__doc__rr r r rr )sr Ú _openpgpkeycCs~|jdƒ}t|ƒdkr"d}t|ƒ‚|d}|d}tjƒ}|j|jdƒƒtj|j ƒdd…ƒj dƒj ƒ}|d|d|S) z‘ Implements RFC 7929, section 3 https://tools.ietf.org/html/rfc7929#section-3 :param email_address: :param tag: :return: ú@éz0Email address must contain exactly one '@' sign.rézutf-8éÚ.) ÚsplitÚlenr ÚhashlibZsha256ÚupdateÚencodeÚbase64Z b16encodeÚdigestÚdecodeÚlower)Z email_addressÚtagrÚmsgZlocalZdomainÚhashr r r rÚemail2location2s   r&c@s(eZdZdZdZdZdZdZdZdZ dS) ÚValidityzå Output of the verification algorithm. TODO: this type might be simplified in order to less reflect the underlying DNS layer. TODO: more specifically the variants from 3 to 5 should have more understandable names rréééé N) rrrrÚVALIDÚREVOKEDÚPROVEN_NONEXISTENCEÚRESULT_NOT_SECUREÚ BOGUS_RESULTÚERRORr r r rr'Jsr'c@seZdZdZdS)ÚNoKeyzŠ This class represents an absence of a key in the cache. It is an expression of non-existence using the Python's type system. N)rrrrr r r rr2Xsr2c@s&eZdZdZddd„Zedd„ƒZdS)ÚKeyInfozv Wrapper class for email and associated verification key, where both are represented in form of a string. NcCs||_||_dS)N)ÚemailÚkey)r r4r5r r rÚ__init__eszKeyInfo.__init__c Csœtjd|ƒ}|dkrt‚|jdƒ}|jdƒjdƒ}d}d}x6tdt|ƒƒD]$}||dkr^|}||dkrJ|}qJWd j||d |d…ƒj dƒ}t ||ƒS) z” Since dnf uses different format of the key than the one used in DNS RR, I need to convert the former one into the new one. z <(.*@.*)>NrÚasciiÚ rz$-----BEGIN PGP PUBLIC KEY BLOCK-----z"-----END PGP PUBLIC KEY BLOCK-----Úr) ÚreÚsearchr Úgroupr!rÚrangerÚjoinrr3) ZuseridZraw_keyZ input_emailr4r5ÚstartÚstopÚiZcat_keyr r rÚfrom_rpm_key_objectis     zKeyInfo.from_rpm_key_object)NN)rrrrr6Ú staticmethodrBr r r rr3`s r3c@s8eZdZdZiZedd„ƒZedd„ƒZedd„ƒZdS) ÚDNSSECKeyVerificationz† The main class when it comes to verification itself. It wraps Unbound context and a cache with already obtained results. cCsZ||krtjdƒtjS|tkr0tjdƒtjStjdj|ƒƒtjdj|ƒƒtjSdS)zD Compare the key in case it was found in the cache. zCache hit, valid keyzCache hit, proven non-existencezKey in cache: {}zInput key : {}N)ÚloggerÚdebugr'r,r2r.r r-)Ú key_unionZinput_key_stringr r rÚ _cache_hit�s  z DNSSECKeyVerification._cache_hitc Csšy ddl}Wn<tk rH}z tdj|ƒƒ}tjj|ƒ‚WYdd}~XnX|jƒ}|jddƒdkrlt j dƒ|jddƒdkr†t j d ƒ|j ƒdkrœt j d ƒ|j d ƒdkr´t j d ƒ|j t|jƒt|jƒ\}}|dkræt j d ƒtjS|jrüt j dƒtjS|j�st j dƒtjS|j�r,t j dƒtjS|j�sDt j dƒtjS|jjƒd}tj|ƒ}||jk�rntj St j dj|ƒƒt j dj|jƒƒtj!SdS)zz In case the key was not found in the cache, create an Unbound context and contact the DNS system rNzLConfiguration option 'gpgkey_dns_verification' requires python3-unbound ({})z verbosity:Ú0z(Unbound context: Failed to set verbosityzqname-minimisation:Úyesz1Unbound context: Failed to set qname minimisationz+Unbound context: Failed to read resolv.confz/var/lib/unbound/root.keyz0Unbound context: Failed to add trust anchor filez%Communication with DNS servers failedzDNSSEC signatures are wrongz!Result is not secured with DNSSECz1Non-existence of this record was proven by DNSSECz"Unknown error in DNS communicationzKey from DNS: {}zInput key : {})"ÚunboundÚ ImportErrorrr rÚ exceptionsÚErrorZub_ctxZ set_optionrErFZ resolvconfZ add_ta_fileZresolver&r4ÚRR_TYPE_OPENPGPKEYZ RR_CLASS_INr'r1Zbogusr0Zsecurer/Znxdomainr.ZhavedataÚdataZ as_raw_datarZ b64encoder5r,r-) Ú input_keyrKÚer$ZctxZstatusÚresultrPZ dns_data_b64r r rÚ _cache_missžsN              z!DNSSECKeyVerification._cache_misscCsztjdj|jƒƒtjj|jƒ}|dk r6tj||jƒStj |ƒ}|t j krZ|jtj|j<n|t j krrt ƒtj|j<|SdS)zI Public API. Use this method to verify a KeyInfo object. z(Running verification for key with id: {}N)rErFr r4rDÚ_cacheÚgetrHr5rTr'r,r.r2)rQrGrSr r rÚverify×s   zDNSSECKeyVerification.verifyN) rrrrrUrCrHrTrWr r r rrDƒs   9rDcCs8tdƒ|jd}|tjkr(|tdƒS|tdƒSdS)zE Inform the user about key validity in a human readable way. zDNSSEC extension: Key for user ú z is valid.zhas unknown status.N)rr4r'r,)ZkiÚvÚprefixr r rÚ nice_user_msgês  r[cCs tdƒ|S)z; Label any given message with DNSSEC extension tag zDNSSEC extension: )r)Úmr r rÚany_msgösr]c@s(eZdZdZedd„ƒZedd„ƒZdS)ÚRpmImportedKeysaQ Wrapper around keys, that are imported in the RPM database. The keys are stored in packages with name gpg-pubkey, where the version and release is different for each of them. The key content itself is stored as an ASCII armored string in the package description, so it needs to be parsed before it can be used. c CsŽtjjjƒ}|jddƒ}g}xl|D]d}tjj|dƒ}tjd|ƒjdƒ}tjj|dƒ}|j dƒdd …}d j |ƒ}|t ||j d ƒƒg7}q"W|S) NÚnamez gpg-pubkeyÚpackagerz <(.*@.*)>rÚ descriptionr8r(r9r7éýÿÿÿ) rZrpmZ transactionZTransactionWrapperZdbMatchZ getheaderr:r;r<rr>r3r) Ztransaction_setZpackagesZ return_listZpkgr`r4raZ key_linesZkey_strr r rÚ_query_db_for_gpg_keyss    z&RpmImportedKeys._query_db_for_gpg_keyscCstjƒ}tjttdƒƒƒxô|D]ì}ytj|ƒ}Wn:tk rl}ztj dj |j |j ƒƒw WYdd}~XnX|t jkr�tjtdj |j ƒƒƒq |t jkr²tjtdj |j ƒƒƒq |t jkrÔtjtdj |j ƒƒƒq |t jkrötjtdj |j ƒƒƒq tjtdj |j ƒƒƒq WdS)Nz1Testing already imported keys for their validity.z%DNSSEC extension error (email={}): {}zGPG Key {} is validz,GPG Key {} does not support DNS verificationzŠGPG Key {} could not be verified, because DNSSEC signatures are bogus. Possible causes: wrong configuration of the DNS server, MITM attackz=GPG Key {} has been revoked and should be removed immediatelyzGPG Key {} could not be tested)r^rcrEÚinfor]rrDrWr Zwarningr r4r r'r,rFr.r0r-)Úkeysr5rSrRr r rÚcheck_imported_keys_validitys,        z,RpmImportedKeys.check_imported_keys_validityN)rrrrrCrcrfr r r rr^þs r^)r)Z __future__rrrÚenumrrrZloggingr:Zdnf.i18nrZdnf.rpmrZdnf.exceptionsZ getLoggerrErOrMrNr r&r'r2r3rDr[r]r^r r r rÚs*       #g