ó õùPc@sœdZddlZejddkrEejddkrEddlTnddlTdZdZdZdZd Z d Z d Z dd „Z d dd„ƒYZdS(s4Module with definitions common to all block ciphers.iÿÿÿÿNiii(t*iiiiicCsQ|j|ƒ}t|ƒ|krG|r:td|ƒ‚n||}n|pP|S(sFFind a parameter in tuple and dictionary arguments a function receivess!Parameter '%s' is specified twice(tgettlent ValueError(tnametindextargstkwargstdefaulttparam((s2..\python\site-packages\Crypto\Cipher\blockalgo.pyt _getParameter|s  t BlockAlgocBs)eZdZd„Zd„Zd„ZRS(s)Class modelling an abstract block cipher.cOstdd||dtƒ|_|j|_|jtkrc|j|||Ž|_|jj|_n¸t|_ t|_ tdd||ƒ|_|js¥t dƒ‚n|j|t t dƒ|jd|jd ƒ}t|jƒ|jkr/|j|j|jd t dƒ|jd ƒ|jd  |_n¼t|jƒ|jd krË|j|_|j|jt dƒ|jd ƒ|jd  |_|jd |jd d !kr¸t d ƒ‚n|jd |_n t d|j|jd fƒ‚|j|t |j|j d|jd ƒ|_dS(NtmodeiRtivisMODE_OPENPGP requires an IVtt segment_sizeiiþÿÿÿiiüÿÿÿs%Failed integrity check for OPENPGP IVs4Length of IV must be %d or %d bytes for MODE_OPENPGP(R tMODE_ECBR t block_sizet MODE_OPENPGPtnewt_ciphertIVtFalset_done_first_blockt_done_last_blockRtMODE_CFBtbRtencryptt _encrypted_IVtdecrypt(tselftfactorytkeyRRt IV_cipher((s2..\python\site-packages\Crypto\Cipher\blockalgo.pyt__init__ˆs>        cCsÞ|jtkrÎ|jt|ƒ|j|j}|dkr–|jrZtd|jƒ‚nt|_|tdƒ|}|jj |ƒt|ƒ }n|jj |ƒ}|j sÊ|j |}t|_ n|S|jj |ƒS(sXEncrypt data with the key and the parameters set at initialization. The cipher object is stateful; encryption of a long block of data can be broken up in two or more calls to `encrypt()`. That is, the statement: >>> c.encrypt(a) + c.encrypt(b) is always equivalent to: >>> c.encrypt(a+b) That also means that you cannot reuse an object for encrypting or decrypting other data with the same key. This function does not perform any padding. - For `MODE_ECB`, `MODE_CBC`, and `MODE_OFB`, *plaintext* length (in bytes) must be a multiple of *block_size*. - For `MODE_CFB`, *plaintext* length (in bytes) must be a multiple of *segment_size*/8. - For `MODE_CTR`, *plaintext* can be of any length. - For `MODE_OPENPGP`, *plaintext* must be a multiple of *block_size*, unless it is the last chunk of the message. :Parameters: plaintext : byte string The piece of data to encrypt. :Return: the encrypted data, as a byte string. It is as long as *plaintext* with one exception: when encrypting the first message chunk with `MODE_OPENPGP`, the encypted IV is prepended to the returned ciphertext. isFOnly the last chunk is allowed to have length not multiple of %d bytesR( R RRRRRtTrueRRRRR(Rt plaintexttpadding_lengthtpaddedtres((s2..\python\site-packages\Crypto\Cipher\blockalgo.pyR»s'!      cCs¼|jtkr¬|jt|ƒ|j|j}|dkr–|jrZtd|jƒ‚nt|_|tdƒ|}|jj |ƒt|ƒ }n|jj |ƒ}|S|jj |ƒS(sšDecrypt data with the key and the parameters set at initialization. The cipher object is stateful; decryption of a long block of data can be broken up in two or more calls to `decrypt()`. That is, the statement: >>> c.decrypt(a) + c.decrypt(b) is always equivalent to: >>> c.decrypt(a+b) That also means that you cannot reuse an object for encrypting or decrypting other data with the same key. This function does not perform any padding. - For `MODE_ECB`, `MODE_CBC`, and `MODE_OFB`, *ciphertext* length (in bytes) must be a multiple of *block_size*. - For `MODE_CFB`, *ciphertext* length (in bytes) must be a multiple of *segment_size*/8. - For `MODE_CTR`, *ciphertext* can be of any length. - For `MODE_OPENPGP`, *plaintext* must be a multiple of *block_size*, unless it is the last chunk of the message. :Parameters: ciphertext : byte string The piece of data to decrypt. :Return: the decrypted data (byte string, as long as *ciphertext*). isFOnly the last chunk is allowed to have length not multiple of %d bytesR( R RRRRRR#RRR(Rt ciphertextR%R&R'((s2..\python\site-packages\Crypto\Cipher\blockalgo.pyRös"!   (t__name__t __module__t__doc__R"RR(((s2..\python\site-packages\Crypto\Cipher\blockalgo.pyR …s 3 ;((R+tsyst version_infotCrypto.Util.py21compattCrypto.Util.py3compatRtMODE_CBCRtMODE_PGPtMODE_OFBtMODE_CTRRtNoneR R (((s2..\python\site-packages\Crypto\Cipher\blockalgo.pyts &