ó 9(Zc@`s{ddlmZmZmZddlmZdZdZd„Zd„Z d„Z d„Z d„Z d „Z d „Zd S( i(tabsolute_importtdivisiontprint_function(t InvalidTagicC`sddlm}m}m}t||ƒr/dSt||ƒradjt|jƒdƒjdƒSt||ƒsvt ‚djt|jƒdƒjdƒSdS(Ni(tAESCCMtAESGCMtChaCha20Poly1305schacha20-poly1305s aes-{0}-ccmitasciis aes-{0}-gcm( t+cryptography.hazmat.primitives.ciphers.aeadRRRt isinstancetformattlent_keytencodetAssertionError(tcipherRRR((sO/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/backends/openssl/aead.pyt_aead_cipher_names#c C`sŐ|jj|ƒ}|j||jjkƒ|jjƒ}|jj||jjƒ}|jj|||jj|jj|jjt |t kƒƒ} |j| dkƒ|jj |t |ƒƒ} |j| dkƒ|jj ||jjt |ƒ|jjƒ} |j| dkƒ|tkr^|jj ||jjt |ƒ|ƒ} |j| dkƒn'|jj ||jj||jjƒ} |jj||jj|jj||t |t kƒƒ} |j| dkƒ|S(Ni(t_libtEVP_get_cipherbynametopenssl_assertt_ffitNULLtEVP_CIPHER_CTX_newtgctEVP_CIPHER_CTX_freetEVP_CipherInit_extintt_ENCRYPTtEVP_CIPHER_CTX_set_key_lengthR tEVP_CIPHER_CTX_ctrltEVP_CTRL_AEAD_SET_IVLENt_DECRYPTtEVP_CTRL_AEAD_SET_TAG( tbackendt cipher_nametkeytnoncettagttag_lent operationt evp_ciphertctxtres((sO/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/backends/openssl/aead.pyt _aead_setups@           cC`sS|jjdƒ}|jj||jj||jj|ƒ}|j|dkƒdS(Nsint *i(RtnewRtEVP_CipherUpdateRR(R!R)tdata_lentintptrR*((sO/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/backends/openssl/aead.pyt _set_lengthEs    cC`sS|jjdƒ}|jj||jj||t|ƒƒ}|j|dkƒdS(Nsint *i(RR,RR-RR R(R!R)tassociated_datatoutlenR*((sO/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/backends/openssl/aead.pyt _process_aadQs !cC`s||jjdƒ}|jjdt|ƒƒ}|jj||||t|ƒƒ}|j|dkƒ|jj||dƒS(Nsint *sunsigned char[]i(RR,R RR-Rtbuffer(R!R)tdataR2tbufR*((sO/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/backends/openssl/aead.pyt _process_dataYs $cC`sEddlm}t|ƒ}t|||j|d|tƒ}t||ƒret||t |ƒƒnt |||ƒt |||ƒ} |j j dƒ} |jj||j j| ƒ} |j| dkƒ|j| ddkƒ|j j d|ƒ} |jj||jj|| ƒ} |j| dkƒ|j j| ƒ} | | S(Ni(Rsint *sunsigned char[](RRRR+R tNoneRR R0R R3R7RR,RtEVP_CipherFinal_exRRRtEVP_CTRL_AEAD_GET_TAGR4(R!RR$R5R1t tag_lengthRR"R)tprocessed_dataR2R*ttag_bufR%((sO/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/backends/openssl/aead.pyt_encryptas$  cC`s§ddlm}t|ƒ|kr+t‚n|| }|| }t|ƒ}t|||j|||tƒ} t||ƒr–t || t|ƒƒnt || |ƒt||ƒrB|j j dƒ} |j j dt|ƒƒ} |j j| | | |t|ƒƒ} | dkr%|jƒt‚n|j j| | dƒ} nat|| |ƒ} |j j dƒ} |j j| |j j| ƒ} | dkrŁ|jƒt‚n| S(Ni(Rsint *sunsigned char[]i(RRR RRR+R RR R0R3RR,RR-t_consume_errorsR4R7R9R(R!RR$R5R1R;RR%R"R)R2R6R*R<((sO/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/backends/openssl/aead.pyt_decrypt|s4    $      N(t __future__RRRtcryptography.exceptionsRRRRR+R0R3R7R>R@(((sO/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/backends/openssl/aead.pyts *