summaryrefslogtreecommitdiff
path: root/lib/Crypto/Hash/CMAC.py
Commit message (Collapse)AuthorAgeFilesLines
* hexverify: Fix handling unicode strings on Python 3.2Dwayne Litzenberger2013-10-201-1/+1
| | | | | | | | | | | | | | | | We were getting this error on Python 3.2: ERROR: runTest (Crypto.SelfTest.Hash.common.MACSelfTest) CMAC #17: NIST SP 800 38B D.7 Example 17 ---------------------------------------------------------------------- Traceback (most recent call last): File "build/lib.linux-x86_64-3.2/Crypto/SelfTest/Hash/common.py", line 199, in runTest self.assertRaises(ValueError, h.hexverify, "4556") File "/home/dwon/py/pythons/python3.2/lib/python3.2/unittest/case.py", line 557, in assertRaises callableObj(*args, **kwargs) File "build/lib.linux-x86_64-3.2/Crypto/Hash/CMAC.py", line 323, in hexverify self.verify(unhexlify(hex_mac_tag)) TypeError: 'str' does not support the buffer interface
* CMAC: raise TypeError instead of ValueError when ciphermod is missing or ↵Dwayne Litzenberger2013-10-201-2/+3
| | | | | | | | unusable This makes the CMAC module behave more like most Python functions do when a required argument is missing, and reserves ValueError for a MAC failure.
* Add support for GCM mode (AES only).Legrandin2013-10-201-35/+100
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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"]
* Add support for CMACLegrandin2013-10-201-0/+277
This patch adds support for CMAC (RFC4493, NIST SP800-38B). [dlitz@dlitz.net: Replaced MacMismatchError with ValueError] [dlitz@dlitz.net: Whitespace fixed with "git rebase --whitespace=fix"]