σ 9(Zc@`s#ddlmZmZmZddlZddlZddlmZddlm Z m Z m Z m Z m Z ddlmZddlmZejejƒdefd„ƒYƒZejejƒd efd „ƒYƒZejejƒd efd „ƒYƒZejejƒd efd„ƒYƒZejejƒdefd„ƒYƒZejejƒdefd„ƒYƒZdefd„ƒYZejeƒdefd„ƒYƒZejeƒejeƒejeƒdefd„ƒYƒƒƒZejeƒdefd„ƒYƒZdS(i(tabsolute_importtdivisiontprint_functionN(tutils(tAlreadyFinalizedtAlreadyUpdatedtNotYetFinalizedtUnsupportedAlgorithmt_Reasons(t CipherBackend(tmodestCipherAlgorithmcB`s,eZejd„ƒZejd„ƒZRS(cC`sdS(sE A string naming this mode (e.g. "AES", "Camellia"). N((tself((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pytnamescC`sdS(sW The size of the key being used as an integer in bits (e.g. 128, 256). N((R ((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pytkey_sizes(t__name__t __module__tabctabstractpropertyR R(((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pyR stBlockCipherAlgorithmcB`seZejd„ƒZRS(cC`sdS(sK The size of a block as an integer in bits (e.g. 64, 128). N((R ((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pyt block_size%s(RRRRR(((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pyR#st CipherContextcB`s>eZejd„ƒZejd„ƒZejd„ƒZRS(cC`sdS(sk Processes the provided bytes through the cipher and returns the results as bytes. N((R tdata((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pytupdate.scC`sdS(s“ Processes the provided bytes and writes the resulting data into the provided buffer. Returns the number of bytes written. N((R Rtbuf((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pyt update_into5scC`sdS(sM Returns the results of processing the final block as bytes. N((R ((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pytfinalize<s(RRRtabstractmethodRRR(((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pyR,stAEADCipherContextcB`seZejd„ƒZRS(cC`sdS(s3 Authenticates the provided bytes. N((R R((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pytauthenticate_additional_dataEs(RRRRR(((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pyRCstAEADDecryptionContextcB`seZejd„ƒZRS(cC`sdS(sŠ Returns the results of processing the final block as bytes and allows delayed passing of the authentication tag. N((R ttag((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pytfinalize_with_tagNs(RRRRR (((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pyRLstAEADEncryptionContextcB`seZejd„ƒZRS(cC`sdS(sb Returns tag bytes. This is only available after encryption is finalized. N((R ((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pyRXs(RRRRR(((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pyR!VstCiphercB`s,eZd„Zd„Zd„Zd„ZRS(cC`s}t|tƒs$tdtjƒ‚nt|tƒsBtdƒ‚n|dk r^|j|ƒn||_ ||_ ||_ dS(Ns0Backend object does not implement CipherBackend.s&Expected interface of CipherAlgorithm.( t isinstanceR RRtBACKEND_MISSING_INTERFACER t TypeErrortNonetvalidate_for_algorithmt algorithmtmodet_backend(R R(R)tbackend((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pyt__init__as   cC`sgt|jtjƒr9|jjdk r9tdƒ‚q9n|jj|j |jƒ}|j |dt ƒS(Ns0Authentication tag must be None when encrypting.tencrypt( R#R)R tModeWithAuthenticationTagRR&t ValueErrorR*tcreate_symmetric_encryption_ctxR(t _wrap_ctxtTrue(R tctx((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pyt encryptorrs cC`s.|jj|j|jƒ}|j|dtƒS(NR-(R*tcreate_symmetric_decryption_ctxR(R)R1tFalse(R R3((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pyt decryptor}s cC`s@t|jtjƒr2|r%t|ƒSt|ƒSn t|ƒSdS(N(R#R)R R.t_AEADEncryptionContextt_AEADCipherContextt_CipherContext(R R3R-((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pyR1ƒs   (RRR,R4R7R1(((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pyR"`s  R:cB`s,eZd„Zd„Zd„Zd„ZRS(cC`s ||_dS(N(t_ctx(R R3((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pyR,scC`s.|jdkrtdƒ‚n|jj|ƒS(NsContext was already finalized.(R;R&RR(R R((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pyR’scC`s1|jdkrtdƒ‚n|jj||ƒS(NsContext was already finalized.(R;R&RR(R RR((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pyR—scC`s:|jdkrtdƒ‚n|jjƒ}d|_|S(NsContext was already finalized.(R;R&RR(R R((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pyRœs  (RRR,RRR(((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pyR:s   R9cB`sGeZd„Zd„Zd„Zd„Zd„Zd„Zd„ZRS(cC`s1||_d|_d|_d|_t|_dS(Ni(R;t_bytes_processedt_aad_bytes_processedR&t_tagR6t_updated(R R3((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pyR,¨s     cC`s|jdkrtdƒ‚nt|_|j|7_|j|jjjkr{tdj |jjj |jjjƒƒ‚ndS(NsContext was already finalized.s-{0} has a maximum encrypted byte limit of {1}( R;R&RR2R?R<t_modet_MAX_ENCRYPTED_BYTESR/tformatR (R t data_size((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pyt _check_limit―s cC`s#|jt|ƒƒ|jj|ƒS(N(RDtlenR;R(R R((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pyR»scC`s&|jt|ƒƒ|jj||ƒS(N(RDRER;R(R RR((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pyRΏscC`sI|jdkrtdƒ‚n|jjƒ}|jj|_d|_|S(NsContext was already finalized.(R;R&RRRR>(R R((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pyRΓs  cC`sL|jdkrtdƒ‚n|jj|ƒ}|jj|_d|_|S(NsContext was already finalized.(R;R&RR RR>(R RR((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pyR Λs  cC`s€|jdkrtdƒ‚n|jr6tdƒ‚n|jt|ƒ7_|j|jjjkrt dj |jjj |jjjƒƒ‚n|jj |ƒdS(NsContext was already finalized.s'Update has been called on this context.s'{0} has a maximum AAD byte limit of {1}( R;R&RR?RR=RER@t_MAX_AAD_BYTESR/RBR R(R R((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pyRΣs $( RRR,RDRRRR R(((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pyR9€s     R8cB`seZed„ƒZRS(cC`s%|jdk rtdƒ‚n|jS(Ns4You must finalize encryption before getting the tag.(R;R&RR>(R ((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pyRζs(RRtpropertyR(((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pyR8δs( t __future__RRRRtsixt cryptographyRtcryptography.exceptionsRRRRRt'cryptography.hazmat.backends.interfacesR t&cryptography.hazmat.primitives.ciphersR t add_metaclasstABCMetatobjectR RRRRR!R"tregister_interfaceR:R9R8(((sQ/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/base.pyts6  (  -  =