summaryrefslogtreecommitdiff
path: root/rsa/pkcs1.py
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@stuvel.eu>2016-03-17 15:04:04 +0100
committerSybren A. Stüvel <sybren@stuvel.eu>2016-03-17 15:16:23 +0100
commit83a81107342ba414064703e5919978782d6bee01 (patch)
treebb1963b7a03849ff4523accab2bbda49d0846611 /rsa/pkcs1.py
parent5d6603258881710fdd7aac866f6ec7445c864d50 (diff)
downloadrsa-git-83a81107342ba414064703e5919978782d6bee01.tar.gz
Removed deprecated functionality.
The following modules have been removed: - rsa._version133 - rsa._version200 - rsa.bigfile - rsa.varblock The encrypt/decrypt-bigfile CLI commands have also been removed.
Diffstat (limited to 'rsa/pkcs1.py')
-rw-r--r--rsa/pkcs1.py26
1 files changed, 22 insertions, 4 deletions
diff --git a/rsa/pkcs1.py b/rsa/pkcs1.py
index 28f0dc5..fdbf093 100644
--- a/rsa/pkcs1.py
+++ b/rsa/pkcs1.py
@@ -317,6 +317,27 @@ def verify(message, signature, pub_key):
return True
+def yield_fixedblocks(infile, blocksize):
+ """Generator, yields each block of ``blocksize`` bytes in the input file.
+
+ :param infile: file to read and separate in blocks.
+ :param blocksize: block size in bytes.
+ :returns: a generator that yields the contents of each block
+ """
+
+ while True:
+ block = infile.read(blocksize)
+
+ read_bytes = len(block)
+ if read_bytes == 0:
+ break
+
+ yield block
+
+ if read_bytes < blocksize:
+ break
+
+
def _hash(message, method_name):
"""Returns the message digest.
@@ -335,11 +356,8 @@ def _hash(message, method_name):
hasher = method()
if hasattr(message, 'read') and hasattr(message.read, '__call__'):
- # Late import to prevent DeprecationWarnings.
- from . import varblock
-
# read as 1K blocks
- for block in varblock.yield_fixedblocks(message, 1024):
+ for block in yield_fixedblocks(message, 1024):
hasher.update(block)
else:
# hash the message object itself.