/
usr
/
lib
/
python2.6
/
site-packages
/
rsa
/
/usr/lib/python2.6/site-packages/rsa
mkdir
upload
Name
Size
Mode
Actions
asn1.py
1781
0644
edit
dl
rm
asn1.pyc
1653
0644
edit
dl
rm
asn1.pyo
1653
0644
edit
dl
rm
bigfile.py
5185
0644
edit
dl
rm
bigfile.pyc
4786
0644
edit
dl
rm
bigfile.pyo
4786
0644
edit
dl
rm
cli.py
12185
0644
edit
dl
rm
cli.pyc
13319
0644
edit
dl
rm
cli.pyo
13319
0644
edit
dl
rm
common.py
4640
0644
edit
dl
rm
common.pyc
4235
0644
edit
dl
rm
common.pyo
4235
0644
edit
dl
rm
core.py
1656
0644
edit
dl
rm
core.pyc
1485
0644
edit
dl
rm
core.pyo
1485
0644
edit
dl
rm
key.py
22867
0644
edit
dl
rm
key.pyc
23986
0644
edit
dl
rm
key.pyo
23986
0644
edit
dl
rm
parallel.py
2299
0644
edit
dl
rm
parallel.pyc
2098
0644
edit
dl
rm
parallel.pyo
2098
0644
edit
dl
rm
pem.py
3537
0644
edit
dl
rm
pem.pyc
2843
0644
edit
dl
rm
pem.pyo
2843
0644
edit
dl
rm
pkcs1.py
12230
0644
edit
dl
rm
pkcs1.pyc
11173
0644
edit
dl
rm
pkcs1.pyo
11126
0644
edit
dl
rm
prime.py
4560
0644
edit
dl
rm
prime.pyc
3664
0644
edit
dl
rm
prime.pyo
3618
0644
edit
dl
rm
randnum.py
2643
0644
edit
dl
rm
randnum.pyc
2074
0644
edit
dl
rm
randnum.pyo
2074
0644
edit
dl
rm
transform.py
6892
0644
edit
dl
rm
transform.pyc
5856
0644
edit
dl
rm
transform.pyo
5856
0644
edit
dl
rm
util.py
3059
0644
edit
dl
rm
util.pyc
2520
0644
edit
dl
rm
util.pyo
2449
0644
edit
dl
rm
varblock.py
5406
0644
edit
dl
rm
varblock.pyc
4856
0644
edit
dl
rm
varblock.pyo
4856
0644
edit
dl
rm
_compat.py
3890
0644
edit
dl
rm
_compat.pyc
3655
0644
edit
dl
rm
_compat.pyo
3655
0644
edit
dl
rm
_version133.py
11764
0644
edit
dl
rm
_version133.pyc
13639
0644
edit
dl
rm
_version133.pyo
13639
0644
edit
dl
rm
_version200.py
15123
0644
edit
dl
rm
_version200.pyc
15264
0644
edit
dl
rm
_version200.pyo
15264
0644
edit
dl
rm
__init__.py
1476
0644
edit
dl
rm
__init__.pyc
1112
0644
edit
dl
rm
__init__.pyo
1112
0644
edit
dl
rm
Edit:
/usr/lib/python2.6/site-packages/rsa/bigfile.py
(5185B)
# -*- coding: utf-8 -*- # # Copyright 2011 Sybren A. Stüvel <sybren@stuvel.eu> # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """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. """ import warnings from rsa import key, common, pkcs1, varblock from rsa._compat import byte def encrypt_bigfile(infile, outfile, pub_key): """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 """ warnings.warn("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.", DeprecationWarning, stacklevel=2) if not isinstance(pub_key, key.PublicKey): raise TypeError('Public key required, but got %r' % pub_key) key_bytes = common.bit_size(pub_key.n) // 8 blocksize = key_bytes - 11 # keep space for PKCS#1 padding # Write the version number to the VARBLOCK file outfile.write(byte(varblock.VARBLOCK_VERSION)) # Encrypt and write each block for block in varblock.yield_fixedblocks(infile, blocksize): crypto = pkcs1.encrypt(block, pub_key) varblock.write_varint(outfile, len(crypto)) outfile.write(crypto) def decrypt_bigfile(infile, outfile, priv_key): """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 """ warnings.warn("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.", DeprecationWarning, stacklevel=2) if not isinstance(priv_key, key.PrivateKey): raise TypeError('Private key required, but got %r' % priv_key) for block in varblock.yield_varblocks(infile): cleartext = pkcs1.decrypt(block, priv_key) outfile.write(cleartext) __all__ = ['encrypt_bigfile', 'decrypt_bigfile']
Save
cmd:
run