diff options
author | Legrandin <helderijs@gmail.com> | 2013-06-06 00:10:48 +0200 |
---|---|---|
committer | Dwayne Litzenberger <dlitz@dlitz.net> | 2013-10-20 13:30:21 -0700 |
commit | 92fea1b6065c6ca75381b465f846843494372c4d (patch) | |
tree | 5975f38481d4a7aec173bdb2cedefdfcedeef325 /pct-speedtest.py | |
parent | 7214ce9929afeb98b1a54735d83881f4337cd8b8 (diff) | |
download | pycrypto-92fea1b6065c6ca75381b465f846843494372c4d.tar.gz |
Add CTR mode benchmark
Diffstat (limited to 'pct-speedtest.py')
-rw-r--r-- | pct-speedtest.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/pct-speedtest.py b/pct-speedtest.py index 132736c..365eca2 100644 --- a/pct-speedtest.py +++ b/pct-speedtest.py @@ -33,6 +33,8 @@ from Crypto.Signature import PKCS1_PSS, PKCS1_v1_5 as RSASSA_PKCS1_v1_5 from Crypto.Cipher import AES, ARC2, ARC4, Blowfish, CAST, DES3, DES, XOR from Crypto.Hash import HMAC, MD2, MD4, MD5, SHA224, SHA256, SHA384, SHA512 from Crypto.Random import get_random_bytes +import Crypto.Util.Counter +from Crypto.Util.number import bytes_to_long try: from Crypto.Hash import SHA1 except ImportError: @@ -165,6 +167,11 @@ class Benchmark: elif mode == "CTR-LE": from Crypto.Util import Counter cipher = module.new(key, module.MODE_CTR, counter=Counter.new(module.block_size*8, little_endian=True)) + elif mode==module.MODE_CTR: + ctr = Crypto.Util.Counter.new(module.block_size*8, + initial_value=bytes_to_long(iv), + allow_wraparound=True) + cipher = module.new(key, module.MODE_CTR, counter=ctr) else: cipher = module.new(key, mode, iv) @@ -335,6 +342,7 @@ class Benchmark: self.test_encryption("%s-CFB-8" % (cipher_name,), module, key_bytes, module.MODE_CFB) self.test_encryption("%s-OFB" % (cipher_name,), module, key_bytes, module.MODE_OFB) self.test_encryption("%s-ECB" % (cipher_name,), module, key_bytes, module.MODE_ECB) + self.test_encryption("%s-CTR" % (cipher_name,), module, key_bytes, module.MODE_CTR) self.test_encryption("%s-OPENPGP" % (cipher_name,), module, key_bytes, module.MODE_OPENPGP) self.test_encryption("%s-CTR-BE" % (cipher_name,), module, key_bytes, "CTR-BE") self.test_encryption("%s-CTR-LE" % (cipher_name,), module, key_bytes, "CTR-LE") |