summaryrefslogtreecommitdiff
path: root/pct-speedtest.py
diff options
context:
space:
mode:
authorLegrandin <helderijs@gmail.com>2013-05-28 23:57:56 +0200
committerDwayne Litzenberger <dlitz@dlitz.net>2013-10-20 13:30:21 -0700
commit5d7ab24c513fb43a604ad23b23d040a53069c4db (patch)
treeb024034c16e14454e94756690c88b9acb52e0422 /pct-speedtest.py
parent199a9741a1849066d070b114333fcf90bc73c55a (diff)
downloadpycrypto-5d7ab24c513fb43a604ad23b23d040a53069c4db.tar.gz
Add support for GCM mode (AES only).
The main change done by this commit is adding support for MODE_GCM (NIST SP 800 38D). Test vectors are included. The mode uses a C extension (Crypto.Util.galois._ghash) to compute the GHASH step. The C implementation is the most basic one and it is still significantly (5x times) slower than CTR. Optimizations can be introduced using tables (CPU/memory trade-off) or even AES NI instructions on newer x86 CPUs. This patch also simplifies Crypto.Cipher.blockalgo.py by: * removing duplicated code previously shared by digest() and verify(). * removing duplicated code previously shared by Crypto.Hash.CMAC and Crypto.Cipher.block_algo (management of internal buffers for MACs that can only operate on block aligned data, like CMAC, CBCMAC, and now also GHASH). [dlitz@dlitz.net: Included changes from the following commits from the author's pull request:] - [9c13f9c] Rename 'IV' parameter to 'nonce' for AEAD modes. - [ca460a7] Made blockalgo.py more PEP-8 compliant; The second parameter of the _GHASH constructor is now the length of the block (block_size) and not the full module. [dlitz@dlitz.net: Replaced MacMismatchError with ValueError] [dlitz@dlitz.net: Replaced ApiUsageError with TypeError] [dlitz@dlitz.net: Replaced renamed variable `ht` with original `h`] [dlitz@dlitz.net: Whitespace fixed with "git rebase --whitespace=fix"]
Diffstat (limited to 'pct-speedtest.py')
-rw-r--r--pct-speedtest.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/pct-speedtest.py b/pct-speedtest.py
index 56b352b..9308ccc 100644
--- a/pct-speedtest.py
+++ b/pct-speedtest.py
@@ -365,6 +365,8 @@ class Benchmark:
self.test_encryption("%s-CCM" % (cipher_name,), module, key_bytes, module.MODE_CCM)
if hasattr(module, "MODE_EAX"):
self.test_encryption("%s-EAX" % (cipher_name,), module, key_bytes, module.MODE_EAX)
+ if hasattr(module, "MODE_GCM"):
+ self.test_encryption("%s-GCM" % (cipher_name,), module, key_bytes, module.MODE_GCM)
# Crypto.Cipher (stream ciphers)
for cipher_name, module, key_bytes in stream_specs: