CVS: crypto/test test_hashes.py,1.4,1.5
"A.M. Kuchling" <[email protected]> Tue, 29 Nov 2005 10:12:14 -0800
| Newsgroups | gmane.comp.python.cryptography.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/pycrypto/crypto/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15214/test
Modified Files:
test_hashes.py
Log Message:
Test SHA256 on 512Mb and 520 Mb of zeros
Index: test_hashes.py
===================================================================
RCS file: /cvsroot/pycrypto/crypto/test/test_hashes.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- test_hashes.py 13 Aug 2004 22:23:12 -0000 1.4
+++ test_hashes.py 29 Nov 2005 18:12:11 -0000 1.5
@@ -39,7 +39,20 @@
self.test_val('obj.digest()', result)
self.test_val('obj.copy().digest()', result)
+ def hash_large_file (self, hash_mod, size, hex_result):
+ obj = hash_mod.new()
+ zeros = 1024*1024*10*'\0'
+ count = 0
+ while count < size:
+ diff = size-count
+ block_size = min(diff, len(zeros))
+ obj.update(zeros[:block_size])
+ count += block_size
+
+ self.test_val('obj.hexdigest()', hex_result)
+
+
def run_test_suite (self, hash_mod, test_vectors):
for text, digest in test_vectors:
self.compare(hash_mod, text, digest)
@@ -84,8 +97,12 @@
def check_sha256 (self):
"SHA256 module"
self.run_test_suite(SHA256,testdata.sha256)
+ self.hash_large_file(SHA256, 512 * 1024 * 1024,
+ '9acca8e8c22201155389f65abbf6bc9723edc7384ead80503839f49dcc56d767')
+ self.hash_large_file(SHA256, 520 * 1024 * 1024,
+ 'abf51ad954b246009dfe5a50ecd582fd5b8f1b8b27f30393853c3ef721e7fa6e')
self.benchmark(SHA256)
-
+
# class HashTest
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click