ó 9(Zc@`sĖddlmZmZmZddlZddlZddlmZejej ƒde fd„ƒYƒZ ejej ƒde fd„ƒYƒZ ejej ƒde fd „ƒYƒZ ejej ƒd e fd „ƒYƒZejej ƒd e fd „ƒYƒZd„Zd„Zd„Zeje ƒeje ƒde fd„ƒYƒƒZeje ƒeje ƒde fd„ƒYƒƒZeje ƒde fd„ƒYƒZeje ƒeje ƒde fd„ƒYƒƒZeje ƒeje ƒde fd„ƒYƒƒZeje ƒeje ƒde fd„ƒYƒƒZeje ƒejeƒde fd„ƒYƒƒZeje ƒeje ƒejeƒde fd „ƒYƒƒƒZdS(!i(tabsolute_importtdivisiontprint_functionN(tutilstModecB`s,eZejd„ƒZejd„ƒZRS(cC`sdS(s@ A string naming this mode (e.g. "ECB", "CBC"). N((tself((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pytnamescC`sdS(sq Checks that all the necessary invariants of this (mode, algorithm) combination are met. N((Rt algorithm((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pytvalidate_for_algorithms(t__name__t __module__tabctabstractpropertyRtabstractmethodR(((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyRstModeWithInitializationVectorcB`seZejd„ƒZRS(cC`sdS(sP The value of the initialization vector for this mode as bytes. N((R((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pytinitialization_vector s(R R R R R(((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyRst ModeWithTweakcB`seZejd„ƒZRS(cC`sdS(s@ The value of the tweak for this mode as bytes. N((R((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyttweak)s(R R R R R(((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyR'st ModeWithNoncecB`seZejd„ƒZRS(cC`sdS(s@ The value of the nonce for this mode as bytes. N((R((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pytnonce2s(R R R R R(((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyR0stModeWithAuthenticationTagcB`seZejd„ƒZRS(cC`sdS(sP The value of the tag supplied to the constructor of this mode. N((R((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyttag;s(R R R R R(((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyR9scC`s1|jdkr-|jdkr-tdƒ‚ndS(NitAESs=Only 128, 192, and 256 bit keys are allowed for this AES mode(tkey_sizeRt ValueError(RR((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyt_check_aes_key_lengthBscC`sGt|jƒd|jkrCtdjt|jƒ|jƒƒ‚ndS(NisInvalid IV size ({0}) for {1}.(tlenRt block_sizeRtformatR(RR((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyt_check_iv_lengthIs cC`st||ƒt||ƒdS(N(RR(RR((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyt_check_iv_and_key_lengthPs tCBCcB`s,eZdZd„ZejdƒZeZRS(RcC`s+t|tƒstdƒ‚n||_dS(Ns#initialization_vector must be bytes(t isinstancetbytest TypeErrort_initialization_vector(RR((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyt__init__ZsR#( R R RR$Rtread_only_propertyRRR(((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyRUs tXTScB`s/eZdZd„ZejdƒZd„ZRS(R&cC`sLt|tƒstdƒ‚nt|ƒdkr?tdƒ‚n||_dS(Nstweak must be bytesis!tweak must be 128-bits (16 bytes)(R R!R"RRt_tweak(RR((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyR$is R'cC`s"|jdkrtdƒ‚ndS(Niis\The XTS specification requires a 256-bit key for AES-128-XTS and 512-bit key for AES-256-XTS(ii(RR(RR((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyRts(R R RR$RR%RR(((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyR&ds tECBcB`seZdZeZRS(R((R R RRR(((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyR(|stOFBcB`s,eZdZd„ZejdƒZeZRS(R)cC`s+t|tƒstdƒ‚n||_dS(Ns#initialization_vector must be bytes(R R!R"R#(RR((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyR$ˆsR#( R R RR$RR%RRR(((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyR)ƒs tCFBcB`s,eZdZd„ZejdƒZeZRS(R*cC`s+t|tƒstdƒ‚n||_dS(Ns#initialization_vector must be bytes(R R!R"R#(RR((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyR$—sR#( R R RR$RR%RRR(((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyR*’s tCFB8cB`s,eZdZd„ZejdƒZeZRS(R+cC`s+t|tƒstdƒ‚n||_dS(Ns#initialization_vector must be bytes(R R!R"R#(RR((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyR$¦sR#( R R RR$RR%RRR(((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyR+”s tCTRcB`s/eZdZd„ZejdƒZd„ZRS(R,cC`s+t|tƒstdƒ‚n||_dS(Nsnonce must be bytes(R R!R"t_nonce(RR((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyR$µsR-cC`sTt||ƒt|jƒd|jkrPtdjt|jƒ|jƒƒ‚ndS(Nis!Invalid nonce size ({0}) for {1}.(RRRRRRR(RR((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyR½s  (R R RR$RR%RR(((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyR,°s tGCMcB`sPeZdZd ZdZddd„ZejdƒZ ejd ƒZ d „Z RS(R.ii'iii@icC`s¦t|tƒstdƒ‚n||_|dk r™t|tƒsQtdƒ‚n|dkrltdƒ‚nt|ƒ|kr™tdj|ƒƒ‚q™n||_dS(Ns#initialization_vector must be bytesstag must be bytes or Noneismin_tag_length must be >= 4s/Authentication tag must be {0} bytes or longer.( R R!R"R#tNoneRRRt_tag(RRRtmin_tag_length((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyR$Ķs   R0R#cC`st||ƒdS(N(R(RR((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyRćsI€I’’’Ią’’’llN( R R Rt_MAX_ENCRYPTED_BYTESt_MAX_AAD_BYTESR/R$RR%RRR(((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pyR.Ås(t __future__RRRR tsixt cryptographyRt add_metaclasstABCMetatobjectRRRRRRRRtregister_interfaceRR&R(R)R*R+R,R.(((sR/tmp/pip-build-wDUJoH/cryptography/cryptography/hazmat/primitives/ciphers/modes.pytsP