ó |~úVc@sfdZddlZddlmZmZmZmZddlmZd„Z d„Z ddgZ dS( s_Large file support .. deprecated:: 3.4 The VARBLOCK format is NOT recommended for general use, has been deprecated since Python-RSA 3.4, and will be removed in a future release. It's vulnerable to a number of attacks: 1. decrypt/encrypt_bigfile() does not implement `Authenticated encryption`_ nor uses MACs to verify messages before decrypting public key encrypted messages. 2. decrypt/encrypt_bigfile() does not use hybrid encryption (it uses plain RSA) and has no method for chaining, so block reordering is possible. See `issue #19 on Github`_ for more information. .. _Authenticated encryption: https://en.wikipedia.org/wiki/Authenticated_encryption .. _issue #19 on Github: https://github.com/sybrenstuvel/python-rsa/issues/13 This module contains functions to: - break a file into smaller blocks, and encrypt them, and store the encrypted blocks in another file. - take such an encrypted files, decrypt its blocks, and reconstruct the original file. The encrypted file format is as follows, where || denotes byte concatenation: FILE := VERSION || BLOCK || BLOCK ... BLOCK := LENGTH || DATA LENGTH := varint-encoded length of the subsequent data. Varint comes from Google Protobuf, and encodes an integer into a variable number of bytes. Each byte uses the 7 lowest bits to encode the value. The highest bit set to 1 indicates the next byte is also part of the varint. The last byte will have this bit set to 0. This file format is called the VARBLOCK format, in line with the varint format used to denote the block sizes. i˙˙˙˙N(tkeytcommontpkcs1tvarblock(tbytecCsÇtjdtddƒt|tjƒs;td|ƒ‚ntj|j ƒd}|d}|j t t j ƒƒxOt j||ƒD];}tj||ƒ}t j|t|ƒƒ|j |ƒq„WdS(s&Encrypts a file, writing it to 'outfile' in VARBLOCK format. .. deprecated:: 3.4 This function was deprecated in Python-RSA version 3.4 due to security issues in the VARBLOCK format. See the documentation_ for more information. .. _documentation: https://stuvel.eu/python-rsa-doc/usage.html#working-with-big-files :param infile: file-like object to read the cleartext from :param outfile: file-like object to write the crypto in VARBLOCK format to :param pub_key: :py:class:`rsa.PublicKey` to encrypt with sßThe 'rsa.bigfile.encrypt_bigfile' function was deprecated in Python-RSA version 3.4 due to security issues in the VARBLOCK format. See https://stuvel.eu/python-rsa-doc/usage.html#working-with-big-files for more information.t stacklevelisPublic key required, but got %rii N(twarningstwarntDeprecationWarningt isinstanceRt PublicKeyt TypeErrorRtbit_sizetntwriteRRtVARBLOCK_VERSIONtyield_fixedblocksRtencryptt write_varinttlen(tinfiletoutfiletpub_keyt key_bytest blocksizetblocktcrypto((s6/opt/awscli/lib/python2.7/site-packages/rsa/bigfile.pytencrypt_bigfileDs   cCsxtjdtddƒt|tjƒs;td|ƒ‚nx6tj|ƒD]%}t j ||ƒ}|j |ƒqKWdS(s(Decrypts an encrypted VARBLOCK file, writing it to 'outfile' .. deprecated:: 3.4 This function was deprecated in Python-RSA version 3.4 due to security issues in the VARBLOCK format. See the documentation_ for more information. .. _documentation: https://stuvel.eu/python-rsa-doc/usage.html#working-with-big-files :param infile: file-like object to read the crypto in VARBLOCK format from :param outfile: file-like object to write the cleartext to :param priv_key: :py:class:`rsa.PrivateKey` to decrypt with sßThe 'rsa.bigfile.decrypt_bigfile' function was deprecated in Python-RSA version 3.4 due to security issues in the VARBLOCK format. See https://stuvel.eu/python-rsa-doc/usage.html#working-with-big-files for more information.Ris Private key required, but got %rN( RRRR Rt PrivateKeyR Rtyield_varblocksRtdecryptR(RRtpriv_keyRt cleartext((s6/opt/awscli/lib/python2.7/site-packages/rsa/bigfile.pytdecrypt_bigfilejs  RR!( t__doc__RtrsaRRRRt rsa._compatRRR!t__all__(((s6/opt/awscli/lib/python2.7/site-packages/rsa/bigfile.pyt<s  " &