bXc@`sddlmZmZmZddlmZddlmZmZm Z ddl m Z m Z ddl mZddlmZmZmZmZeje jdefdYZeje jeje jd efd YZd S( i(tabsolute_importtdivisiontprint_function(tutils(t InvalidTagtUnsupportedAlgorithmt_Reasons(tcipherst constant_time(tmodes(tCFBtCFB8tCTRtOFBt_CipherContextcB`s#eZdZdZdZRS(c C`s||_||_||_||_d|_t|tjrnt|tt t t f rn|j d|_ n d|_ |jj}y&|t|t|f\}}WnAtk rtdj|j|r|jn|tjnX|jjjd}|jjj||jj}t|tjr>|j} n-t|tjr\|j} n|jjj} t|t r|jj j!} nd} |jj j"||||jj j#| |j$t%|j$|jjjdd| | } |jj&| ||_'dS(Niiis8cipher {0} in {1} mode is not supported by this backend.sCCCryptorRef *((t_backendt_ciphert_modet _operationt_bytes_processedt isinstanceRtBlockCipherAlgorithmR R R R t block_sizet_byte_block_sizet_cipher_registryttypetKeyErrorRtformattnameRtUNSUPPORTED_CIPHERt_ffitnewtgct_release_cipher_ctxR tModeWithInitializationVectortinitialization_vectort ModeWithNoncetnoncetNULLt_libtkCCModeOptionCTR_BEtCCCryptorCreateWithModet ccNoPaddingtkeytlent_check_cipher_responset_ctx( tselftbackendtciphertmodet operationtregistryt cipher_enumt mode_enumtctxtiv_noncet mode_optiontres((sW/usr/lib64/python2.7/site-packages/cryptography/hazmat/backends/commoncrypto/ciphers.pyt__init__sF      &    cC`s|jt|7_|jjjdt||jd}|jjjd}|jjj|jd|t||t||jd|}|jj ||jjj ||d S(Nsunsigned char[]issize_t *i( RR,RRRRR'tCCCryptorUpdateR.R-tbuffer(R/tdatatbuftoutlenR:((sW/usr/lib64/python2.7/site-packages/cryptography/hazmat/backends/commoncrypto/ciphers.pytupdateMs  cC`s|j|jrtdn|jjjd|j}|jjjd}|jjj|jd|t ||}|jj ||jj |j|jjj ||d S(NsFThe length of the provided data is not a multiple of the block length.sunsigned char[]ssize_t *i( RRt ValueErrorRRRR'tCCCryptorFinalR.R,R-R!R=(R/R?R@R:((sW/usr/lib64/python2.7/site-packages/cryptography/hazmat/backends/commoncrypto/ciphers.pytfinalizeYs  (t__name__t __module__R;RARD(((sW/usr/lib64/python2.7/site-packages/cryptography/hazmat/backends/commoncrypto/ciphers.pyRs 9 t_GCMCipherContextcB`s;eZdZdZdZdZejdZRS(c C`s||_||_||_||_d|_|jj}y&|t|t|f\}}WnAtk rt dj |j |r|j n|t j nX|jjjd}|jjj||jj}||_|jjj||||jjj|jjj|jt|j|jjjddd|j } |jj| |jjj|jd|jt|j} |jj| |jddS(Ns8cipher {0} in {1} mode is not supported by this backend.sCCCryptorRef *it(RRRRtNonet_tagRRRRRRRRRRR R!R.R'R)R*R&R+R,R-tCCCryptorGCMAddIVR#tauthenticate_additional_data( R/R0R1R2R3R4R5R6R7R:((sW/usr/lib64/python2.7/site-packages/cryptography/hazmat/backends/commoncrypto/ciphers.pyR;ls<      &     !  cC`s|jjjdt|}|jd|t||f}|j|jjjkrm|jjj|}n|jjj |}|jj ||jjj |S(Nsunsigned char[]i( RRRR,R.RR't kCCEncrypttCCCryptorGCMEncrypttCCCryptorGCMDecryptR-R=(R/R>R?targsR:((sW/usr/lib64/python2.7/site-packages/cryptography/hazmat/backends/commoncrypto/ciphers.pyRAscC`s|jd|jjd}|jjjd|}|jjjd|}|jjj|jd||}|jj ||jj |j|jjj ||_ |j |jjjkrtj|j t|jj |jj rtndS(NRHisunsigned char[]ssize_t *i(RARRRRRR'tCCCryptorGCMFinalR.R-R!R=RJRt kCCDecryptRtbytes_eqR,RttagR(R/ttag_sizettag_bufttag_lenR:((sW/usr/lib64/python2.7/site-packages/cryptography/hazmat/backends/commoncrypto/ciphers.pyRDs  & cC`s<|jjj|jd|t|}|jj|dS(Ni(RR'tCCCryptorGCMAddAADR.R,R-(R/R>R:((sW/usr/lib64/python2.7/site-packages/cryptography/hazmat/backends/commoncrypto/ciphers.pyRLs RJ( RERFR;RARDRLRtread_only_propertyRT(((sW/usr/lib64/python2.7/site-packages/cryptography/hazmat/backends/commoncrypto/ciphers.pyRGis  -  N(t __future__RRRt cryptographyRtcryptography.exceptionsRRRtcryptography.hazmat.primitivesRRt&cryptography.hazmat.primitives.ciphersR t,cryptography.hazmat.primitives.ciphers.modesR R R R tregister_interfacet CipherContexttobjectRtAEADCipherContexttAEADEncryptionContextRG(((sW/usr/lib64/python2.7/site-packages/cryptography/hazmat/backends/commoncrypto/ciphers.pyts"V