ó Û_e[c@`s¤ddlmZmZmZddlZddlmZmZddlm Z ddl m Z de fd„ƒYZ de fd „ƒYZd e fd „ƒYZdS( i(tabsolute_importtdivisiontprint_functionN(t exceptionstutils(taead(tbackendtChaCha20Poly1305cB`sAeZdZd„Zed„ƒZd„Zd„Zd„ZRS(ii cC`shtj|ƒs*tjdtjjƒ‚ntjd|ƒt|ƒdkr[t dƒ‚n||_ dS(Ns<ChaCha20Poly1305 is not supported by this version of OpenSSLtkeyi s&ChaCha20Poly1305 key must be 32 bytes.( Rtaead_cipher_supportedRtUnsupportedAlgorithmt_ReasonstUNSUPPORTED_CIPHERRt _check_bytestlent ValueErrort_key(tselfR((sS/tmp/pip-install-KP2Jbq/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyt__init__scC`s tjdƒS(Ni (tosturandom(tcls((sS/tmp/pip-install-KP2Jbq/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyt generate_keyscC`s}|dkrd}nt|ƒ|jks?t|ƒ|jkrNtdƒ‚n|j|||ƒtjt||||dƒS(Nts1Data or associated data too long. Max 2**32 bytesi(tNoneRt _MAX_SIZEt OverflowErrort _check_paramsRt_encryptR(Rtnoncetdatatassociated_data((sS/tmp/pip-install-KP2Jbq/cryptography/cryptography/hazmat/primitives/ciphers/aead.pytencrypt"s  * cC`sD|dkrd}n|j|||ƒtjt||||dƒS(NRi(RRRt_decryptR(RRRR((sS/tmp/pip-install-KP2Jbq/cryptography/cryptography/hazmat/primitives/ciphers/aead.pytdecrypt1s   cC`sUtjd|ƒtjd|ƒtjd|ƒt|ƒdkrQtdƒ‚ndS(NRRRi sNonce must be 12 bytes(RR RR(RRRR((sS/tmp/pip-install-KP2Jbq/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyR:s I( t__name__t __module__RRt classmethodRR R"R(((sS/tmp/pip-install-KP2Jbq/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyRs    tAESCCMcB`sMeZd Zdd„Zed„ƒZd„Zd„Zd„Zd„Z RS( ii icC`sªtjd|ƒt|ƒdkr1tdƒ‚n||_t|tƒsXtdƒ‚n|dkrstd ƒ‚n||_t j |ƒs¦t j d t j jƒ‚ndS(NRiii s)AESCCM key must be 128, 192, or 256 bits.stag_length must be an integeriiii isInvalid tag_lengths2AESCCM is not supported by this version of OpenSSL(iii (iiii ii(RR RRRt isinstancetintt TypeErrort _tag_lengthRR RR R R (RRt tag_length((sS/tmp/pip-install-KP2Jbq/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyREs   cC`sJt|tƒstdƒ‚n|dkr9tdƒ‚ntj|dƒS(Nsbit_length must be an integeri€iÀis#bit_length must be 128, 192, or 256i(i€iÀi(R'R(R)RRR(Rt bit_length((sS/tmp/pip-install-KP2Jbq/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyRYs  cC`s–|dkrd}nt|ƒ|jks?t|ƒ|jkrNtdƒ‚n|j|||ƒ|j|t|ƒƒtjt|||||j ƒS(NRs1Data or associated data too long. Max 2**32 bytes( RRRRRt_validate_lengthsRRRR*(RRRR((sS/tmp/pip-install-KP2Jbq/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyR cs  * cC`sG|dkrd}n|j|||ƒtjt|||||jƒS(NR(RRRR!RR*(RRRR((sS/tmp/pip-install-KP2Jbq/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyR"ss   cC`s7dt|ƒ}dd||kr3tdƒ‚ndS(NiiisNonce too long for data(RR(RRtdata_lentl_val((sS/tmp/pip-install-KP2Jbq/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyR-|scC`setjd|ƒtjd|ƒtjd|ƒdt|ƒkoMdknsatdƒ‚ndS(NRRRii s$Nonce must be between 7 and 13 bytes(RR RR(RRRR((sS/tmp/pip-install-KP2Jbq/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyRƒs "I( R#R$RRR%RR R"R-R(((sS/tmp/pip-install-KP2Jbq/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyR&Bs   tAESGCMcB`sAeZdZd„Zed„ƒZd„Zd„Zd„ZRS(ii cC`s>tjd|ƒt|ƒdkr1tdƒ‚n||_dS(NRiii s)AESGCM key must be 128, 192, or 256 bits.(iii (RR RRR(RR((sS/tmp/pip-install-KP2Jbq/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyRŽscC`sJt|tƒstdƒ‚n|dkr9tdƒ‚ntj|dƒS(Nsbit_length must be an integeri€iÀis#bit_length must be 128, 192, or 256i(i€iÀi(R'R(R)RRR(RR,((sS/tmp/pip-install-KP2Jbq/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyR•s  cC`s}|dkrd}nt|ƒ|jks?t|ƒ|jkrNtdƒ‚n|j|||ƒtjt||||dƒS(NRs1Data or associated data too long. Max 2**32 bytesi(RRRRRRRR(RRRR((sS/tmp/pip-install-KP2Jbq/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyR Ÿs  * cC`sD|dkrd}n|j|||ƒtjt||||dƒS(NRi(RRRR!R(RRRR((sS/tmp/pip-install-KP2Jbq/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyR"®s   cC`sUtjd|ƒtjd|ƒtjd|ƒt|ƒdkrQtdƒ‚ndS(NRRRisNonce must be at least 1 byte(RR RR(RRRR((sS/tmp/pip-install-KP2Jbq/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyR·s I( R#R$RRR%RR R"R(((sS/tmp/pip-install-KP2Jbq/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyR0‹s    (t __future__RRRRt cryptographyRRt$cryptography.hazmat.backends.opensslRt,cryptography.hazmat.backends.openssl.backendRtobjectRR&R0(((sS/tmp/pip-install-KP2Jbq/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyts 4I