Commit graph

14 commits

Author SHA1 Message Date
Legrandin
d0311fb416 MAC checks are all performed with BLAKE2s 2015-04-16 14:11:50 +02:00
Legrandin
af28deab82 Make benchmark script work again 2015-01-10 21:47:35 +01:00
Legrandin
8675e6f03f Start licensing under BSD 2-Clause 2014-06-23 22:23:38 +02:00
Legrandin
6d11571e1a Replace HMAC code with public domain implementation 2014-06-16 20:38:26 +02:00
Legrandin
ddca00943e Remove block_size attribute from SHA3 digests 2014-05-11 12:45:28 +02:00
Dwayne Litzenberger
141eee1093 hexverify: Fix handling unicode strings on Python 3.2
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
2013-10-20 17:36:06 -07:00
Legrandin
77b0b9123c Add HMAC.verify() and HMAC.hexverify() with constant-time comparison
In the current implementation, it is left up to the caller
to assess if the locally computed MAC matches the MAC associated
to the received message.

However, the most natural way to do that (use == operator)
is also deepy unsecure, see here:

http://seb.dbzteam.org/crypto/python-oauth-timing-hmac.pdf

With this patch, the new HMAC.verify() method accepts
the given MAC and perform the check on behalf of the caller.
The method will use constant-time code (still dependent on the length
of the MAC, but not on the actual content).

[dlitz@dlitz.net: Modified commit message subject line.]
[dlitz@dlitz.net: Whitespace fixed with "git rebase --whitespace=fix"]
2013-10-20 13:30:21 -07:00
Legrandin
2f8a86bd83 Added documentation for all hash algorithms
(including for HMAC which, strictly speaking, does not belong with them).
2012-05-05 23:37:19 +02:00
Dwayne C. Litzenberger
bf38995ffa Merge branch 'master' into py3k
Conflicts:
	setup.py
	src/_fastmath.c
2011-10-10 14:51:07 -04:00
Frédéric Bertolus
577d0dbd7d Add variable block size support to HMAC-SHA384 and HMAC-SHA512 which use
block of 128 bytes long
2011-04-08 18:23:07 +02:00
Thorsten Behrens
cb48387f66 PY3K _fastmath support
o _fastmath now builds and runs on PY3K
o Changes to setup.py to allow /usr/include for gmp.h
o Changes to setup.py to allow linking fastmath w/ static mpir
  on Windows without warning messages
o Changes to test_DSA/test_RSA to throw an exception if _fastmath
  is present but cannot be imported (due to an issue building
  _fastmath or the shared gmp/mpir libraries not being reachable)
o number.py has the code to flag a failing _fastmath, but that
  code is commented out for a better runtime experience
o Clean up the if for py21compat import - should have been == not is
o Clean up some '== None' occurences, now 'is None' instead
2010-12-29 13:21:05 -05:00
Thorsten Behrens
295ce314d9 Changes to allow pycrpyto to work on Python 3.x as well as 2.1 through 2.7 2010-12-28 16:26:52 -05:00
Dwayne C. Litzenberger
bf6772c10f HMAC.py: Add clarified copyright notice 2009-08-02 22:32:18 -04:00
Dwayne C. Litzenberger
ff8a657a8d cleanup: Move modules to "lib/Crypto" subdirectory.
This will avoid the previous situation where scripts like the old "test.py"
get included accidentally in a release.  It also frees us to put additional
build scripts in the top-level directory of the source tree.
2009-02-28 13:14:53 -05:00
Renamed from Hash/HMAC.py (Browse further)