From 57104488faa9fc386ea1aee249bafb6e2a529a57 Mon Sep 17 00:00:00 2001 From: Legrandin Date: Wed, 23 Jan 2013 22:37:53 +0100 Subject: Add support for CCM mode (AES only). [dlitz@dlitz.net: Included changes from the following commits from the author's pull request:] - [5306cf3] Added support for CCM mode (AES cipher only) - [9abe301] Added CCM tests - [f0c1395] Add MacMismatchError and ApiUsageError - [fb62fae] ApiUsageError becomes TypeError - [9c13f9c] Rename 'IV' parameter to 'nonce' for AEAD modes. - [4ec64d8] Removed last references to ApiUsageError - [80bfd35] Corrected AES-CCM examples [dlitz@dlitz.net: Removed unrelated documentation change] [dlitz@dlitz.net: Renamed 'targs' back to 'args'] [dlitz@dlitz.net: Whitespace fixed with "git rebase --whitespace=fix"] --- pct-speedtest.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'pct-speedtest.py') diff --git a/pct-speedtest.py b/pct-speedtest.py index e84cf81..378604f 100644 --- a/pct-speedtest.py +++ b/pct-speedtest.py @@ -167,6 +167,8 @@ 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 hasattr(module, 'MODE_CCM') and mode==module.MODE_CCM: + cipher = module.new(key, mode, iv[:8], msg_len=len(rand)*len(blocks)) elif mode==module.MODE_CTR: ctr = Crypto.Util.Counter.new(module.block_size*8, initial_value=bytes_to_long(iv), @@ -359,6 +361,8 @@ class Benchmark: 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") + if hasattr(module, "MODE_CCM"): + self.test_encryption("%s-CCM" % (cipher_name,), module, key_bytes, module.MODE_CCM) # Crypto.Cipher (stream ciphers) for cipher_name, module, key_bytes in stream_specs: -- cgit v1.2.1