BLAKE: a new hash algorithm

BLAKE is a NIST SHA3 competition finalist designed and submitted by Jean-Philippe Aumasson, Luca Henzen, Willi Meier, and Raphael C.-W. Phan. At the core of BLAKE is a ChaCha-like mixer, very similar to that found in the stream cipher, ChaCha, a tweak of Salsa20. Besides being a very good mixer, ChaCha is fast. More at:
            http://www.131002.net/blake/
            http://csrc.nist.gov/groups/ST/hash/sha-3/index.html
            http://en.wikipedia.org/wiki/BLAKE_(hash_function)

This page introduces blake.py, a pure Python implementation of BLAKE-224, -256, -384, -512, and blake_wrapper.py, a ctypes wrapper for a shared library using the official C reference APIs. Also, you might find use for the test program blake_test.py. All of these should run nicely under Python 2.6 and later. This includes Python3 and PyPy.

These implementations assume all data is in increments of whole bytes. (The formal definition of BLAKE allows for hashing in increments of individual bits.) Note too that this implementation does include the round-3 tweaks where the number of rounds was increased from 10/14 to 14/16.

Here are some comparative run times for different versions of Python:
32-bit:
2.7 13.65s
3.2 12.57s
64-bit:
2.6   6.28s
2.7   6.34s
3.2   7.62s
pypy (2.7)     2.08s
One test of the pure Python implementation of BLAKE-256 running on a 2.0GHz Core 2 Duo, 10,000 iterations of a short message, produced a time of 5.7 seconds. Not bad, but if raw speed is what you want, look to C. The reference implemenation is 40 times faster performing the same 10,000 iterations in 0.13 seconds!

To make your learning and experimentation less cumbersome, blake.py, blake_wrapper.py, and blake_test.py are free for any use, but they are copyrighted.
Copyright (c) 2011-2014 by Larry Bugbee, Kent, WA
ALL RIGHTS RESERVED.

blake.py, blake_wrapper.py, and blake_test.py ARE EXPERIMENTAL SOFTWARE FOR EDUCATIONAL PURPOSES ONLY. THEY ARE MADE AVAILABLE "AS-IS" WITHOUT WARRANTY OR GUARANTEE OF ANY KIND, NO EXCEPTIONS. USE SIGNIFIES ACCEPTANCE OF ALL RISK.
blake.py   (version 5, 2-Apr-2014)
blake_wrapper.py
blake_test.py

Enjoy,

Larry Bugbee
bugbee@seanet.com
Mar 2011
rev Jul 2011, Apr 2012, Apr 2014