Skip to main content

SHA-3 (Keccak) for Python 2.6 - 3.4

Project description

pysha3
======

SHA-3 wrapper (keccak) for Python. The package is a wrapper around the
optimized reference implementation from http://keccak.noekeon.org/ . Only
the optimizations for 32 and 64bit platforms are used. The optimized SSE and
ARM assembly variants are ignored for now.

The module is a standalone version of the SHA-3 implemention of Python 3.4
(currently under development). The code in sha3module.c has been modified to
be compatible with Python 2.6 to 3.4. Python 2.5 and earlier are not
supported.


Platforms
=========

pysha3 has been successfully tested on several platforms and architectures:

- Linux (GCC 4.3, GCC 4.6, clang 3.0) on X86, X86_64 and ARMv6
- Windows (VS 2008, VS 2010) on X86 and X86_64
- FreeBSD (clang) on X86 and X86_64
- HP-UX (HP C/aC++) on IA64
- Solaris 10 (Oracle Solaris Studio 12.3) on SPARC (big endian)
- AIX (XLC 12.1) on PowerPC (big endian)

Thank you very much to Trent Nelson for the Snakebite network.


Usage
=====

The `sha3` module contains several constructors for hash objects with a
PEP 247 compatible interface. The module provides `sha3_228()`, `sha3_256()`,
`sha3_384()`, and `sha3_512()`.

The `sha3` module monkey patches the `hashlib` module . The monkey patch is
automatically activated with the first import of the `sha3` module. The
`hashlib` module of Python 3.4 will support the four SHA-3 algorithms
on all platforms. Therefore you shouldn't use the sha3 module directly
and rather go through the `hashlib` interface::

>>> import sys
>>> import hashlib
>>> if sys.version_info < (3, 4):
... import sha3
>>> s = hashlib.new("sha3_512")
>>> s = hashlib.sha3_512() # alternative
>>> s.name
'sha3_512'
>>> s.digest_size
64
>>> s.update(b"data")
>>> s.hexdigest()
'1065aceeded3a5e4412e2187e919bffeadf815f5bd73d37fe00d384fe29f55f08462fdabe1007b993ce5b8119630e7db93101d9425d6e352e22ffe3dcb56b825'

**Don't use SHA-3 for HMAC!** HMAC hasn't been specified for SHA-3 yet and no
test vectors are available, too.


Comments from sha3module header
===============================

The code is based on KeccakReferenceAndOptimized-3.2.zip from 29 May 2012.

The reference implementation is altered in this points:
- C++ comments are converted to ANSI C comments.
- All functions and globals are declared static.
- The typedef for UINT64 is commented out.
- brg_endian.h is removed.
- KeccakF-1600-opt[32|64]-settings.h are commented out
- Some unused functions are commented out to silence compiler warnings.

In order to avoid name clashes with other software I have to declare all
Keccak functions and global data as static. The C code is directly
included into this file in order to access the static functions.

Keccak can be tuned with several paramenters. I try to explain all options
as far as I understand them. The reference implementation also contains
assembler code for ARM platforms (NEON instructions).

Common
------

`Unrolling`
loop unrolling (24, 12, 8, 6, 4, 3, 2, 1)

`UseBebigokimisa`
lane complementing

64bit platforms
---------------

default settings of common options

`Unrolling`
24
`UseBebigokimisa`
enabled

Additional optimiation instructions (disabled by default):

`UseSSE`
use Stream SIMD extensions

`UseOnlySIMD64`
limit to 64bit instructions, otherwise 128bit

`w/o UseOnlySIMD64`
requires compiler argument `-mssse3` or `-mtune=core2` or better

`UseMMX`
use 64bit MMX instructions

`UseXOP`
use AMD's eXtended Operations (128bit SSE extension)

When neither `UseSSE`, `UseMMX` nor `UseXOP` is configured, `ROL64`
(rotate left 64) is implemented as:

Windows
_rotl64()

`UseSHLD`
use shld (shift left) asm optimization

otherwise
shift and xor

`UseBebigokimisa` can't be used in combination with `UseSSE`, `UseMMX` or
`UseXOP`. `UseOnlySIMD64` has no effect unless UseSSE is specified.

Tests have shown that `UseSSE` + `UseOnlySIMD64` is about three to four
times SLOWER than `UseBebigokimisa`. `UseSSE` and `UseMMX` are about two
times slower. (tested by CH and AP)

32bit platforms
---------------

default settings of common options

`Unrolling`
2
`UseBebigokimisa`
disabled

`UseSchedule`
`1`
unknown

`2`
unknown

`3` [default]
unknown, no `UseBebigokimisa`, `Unrolling` must be 2

`UseInterleaveTables`
use two 64k lookup tables for (de)interleaving (disabled by default)


Changelog
=========

pysha3 0.3
----------

*Release date: 14-Oct-2012*

- Fix 64bit big endian support

- Add workaround for alignment error on 64bit SPARC machine by using the opt32
implementation.

- block_size now returns NotImplemented to prevent users from using pysha3
with the hmac module.


pysha3 0.2.2
------------

*Release date: 07-Oct-2012*

- Re-add brg_endian.h to fix issue on Solaris (big endian platform)


pysha3 0.2.1
------------

*Release date: 06-Oct-2012*

- Fix MANIFEST.in to include Makefile and tests.py

- Add setup.py test command with hack for inplace builds

- Enhance README.txt and fixed its markup


pysha3 0.2
----------

*Release date: 06-Oct-2012*

- Change directory struct to use the same directory layout as Python 3.4.

- Remove C++ comments from Keccak sources for ANSI C compatibility.

- Declare all Keccak functions and globals as static to avoid name clashes.

- Remove alias sha3() for sha3_512().

- Add block_size attribute. Keccak has a internal sponge size of 1600 bits.

- Release GIL around SHA3_update() calls.

- Monkey patch the hashlib module to support, e.g. hashlib.sha3_512() and
hashlib.new("sha3_512")

- Release GIL around SHA3_update() when the data exceeds a certain size.

- Fix build on platforms with an unsigned 64bit integer type (uint64_t). The
module falls back to 32bit implementation of Keccak with interleave tables.


pysha3 0.1
----------

*Release date: 04-Oct-2012*

- first release

- based on KeccakReferenceAndOptimized-3.2.zip

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

pysha3-0.3.zip (61.2 kB view details)

Uploaded Source

pysha3-0.3.tar.gz (47.5 kB view details)

Uploaded Source

Built Distributions

pysha3-0.3.win-amd64-py3.4.exe (278.6 kB view details)

Uploaded Source

pysha3-0.3.win-amd64-py3.3.exe (277.8 kB view details)

Uploaded Source

pysha3-0.3.win-amd64-py3.2.exe (280.2 kB view details)

Uploaded Source

pysha3-0.3.win-amd64-py2.7.exe (279.7 kB view details)

Uploaded Source

pysha3-0.3.win-amd64-py2.6.exe (248.0 kB view details)

Uploaded Source

pysha3-0.3.win32-py3.4.exe (215.0 kB view details)

Uploaded Source

pysha3-0.3.win32-py3.3.exe (214.1 kB view details)

Uploaded Source

pysha3-0.3.win32-py3.2.exe (219.2 kB view details)

Uploaded Source

pysha3-0.3.win32-py2.7.exe (219.2 kB view details)

Uploaded Source

pysha3-0.3.win32-py2.6.exe (218.2 kB view details)

Uploaded Source

pysha3-0.3-cp34-none-win_amd64.whl (52.9 kB view details)

Uploaded CPython 3.4 Windows x86-64

pysha3-0.3-cp34-none-win32.whl (20.5 kB view details)

Uploaded CPython 3.4 Windows x86

pysha3-0.3-cp33-none-win_amd64.whl (52.9 kB view details)

Uploaded CPython 3.3 Windows x86-64

pysha3-0.3-cp33-none-win32.whl (20.5 kB view details)

Uploaded CPython 3.3 Windows x86

pysha3-0.3-cp32-none-win_amd64.whl (53.3 kB view details)

Uploaded CPython 3.2 Windows x86-64

pysha3-0.3-cp32-none-win32.whl (20.4 kB view details)

Uploaded CPython 3.2 Windows x86

pysha3-0.3-cp27-none-win_amd64.whl (53.4 kB view details)

Uploaded CPython 2.7 Windows x86-64

pysha3-0.3-cp27-none-win32.whl (20.5 kB view details)

Uploaded CPython 2.7 Windows x86

pysha3-0.3-cp26-none-win_amd64.whl (21.6 kB view details)

Uploaded CPython 2.6 Windows x86-64

pysha3-0.3-cp26-none-win32.whl (19.5 kB view details)

Uploaded CPython 2.6 Windows x86

File details

Details for the file pysha3-0.3.zip.

File metadata

  • Download URL: pysha3-0.3.zip
  • Upload date:
  • Size: 61.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pysha3-0.3.zip
Algorithm Hash digest
SHA256 e39e965330c0e9a71b97cb6e0e7b0d1ddafdec07ac5daabf1412cc57f88bde8f
MD5 092da55212eb411845a18bf1d6b80295
BLAKE2b-256 37b67e18b1c96ede8f8bddf07bb52c54f8facd537ce80d94231a539880a33d54

See more details on using hashes here.

File details

Details for the file pysha3-0.3.tar.gz.

File metadata

  • Download URL: pysha3-0.3.tar.gz
  • Upload date:
  • Size: 47.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pysha3-0.3.tar.gz
Algorithm Hash digest
SHA256 191c5f1f77de11fb847c6c825b72f33c81ce67f72055038175fccbbeb891f04d
MD5 150ef07e47b6ef79bdf7717036ceccc7
BLAKE2b-256 d0179fb9efcde17f8fc77e0af0b49281d22eb7c640e326987b0308c88a927ba5

See more details on using hashes here.

File details

Details for the file pysha3-0.3.win-amd64-py3.4.exe.

File metadata

File hashes

Hashes for pysha3-0.3.win-amd64-py3.4.exe
Algorithm Hash digest
SHA256 4125269ab912d93cd038d3d8a618ec05105005c2dfc4a393f2e738e1d3f9e667
MD5 f76ec330bd918d9fc693cf5acb3fc4ca
BLAKE2b-256 82e3976622960783653c2c391256737b486bf7d62847f209059308d1f496c561

See more details on using hashes here.

File details

Details for the file pysha3-0.3.win-amd64-py3.3.exe.

File metadata

File hashes

Hashes for pysha3-0.3.win-amd64-py3.3.exe
Algorithm Hash digest
SHA256 c197bc20a0824f74fab719cd6a022953f20a9a4a399e5a1b8bf336966c17ef25
MD5 8d7cc349b95a3f9f0a8d4532b0976a64
BLAKE2b-256 e09fd2ef724a09b62af014507800b0f24100b2434729d914d2468f6cd67a0561

See more details on using hashes here.

File details

Details for the file pysha3-0.3.win-amd64-py3.2.exe.

File metadata

File hashes

Hashes for pysha3-0.3.win-amd64-py3.2.exe
Algorithm Hash digest
SHA256 ab7769fa72ae86e2d31d1704853bf1e8ad50245cbedfdf2804905978a0ced4e7
MD5 e5626840feb09f8bac10ebb17b4134d1
BLAKE2b-256 2539cb2c381b0e9b3f09306103f51a485dbad127b475bb34a082947cfe04084f

See more details on using hashes here.

File details

Details for the file pysha3-0.3.win-amd64-py2.7.exe.

File metadata

File hashes

Hashes for pysha3-0.3.win-amd64-py2.7.exe
Algorithm Hash digest
SHA256 d9b8b00845a297b0be33d5426be0c1f274276f82acecd6c602bb815e368698ae
MD5 478cb7157d9021016e9752ec15194aff
BLAKE2b-256 81780bec7fb1cabcbfca241e54f3a458cf81b764cadd5cb4c074a1023a590ace

See more details on using hashes here.

File details

Details for the file pysha3-0.3.win-amd64-py2.6.exe.

File metadata

File hashes

Hashes for pysha3-0.3.win-amd64-py2.6.exe
Algorithm Hash digest
SHA256 03029ee7cc0f1236e59f3cc168ab0d36a53a6710355848fa2709f5899f461e7c
MD5 7229f6edb85df0fa4921e5fe5923f140
BLAKE2b-256 0822c235b2510e5b82433a2f64218b1fb8c36a61c0cfb8534245f587292b81f8

See more details on using hashes here.

File details

Details for the file pysha3-0.3.win32-py3.4.exe.

File metadata

File hashes

Hashes for pysha3-0.3.win32-py3.4.exe
Algorithm Hash digest
SHA256 19d662fd8dda9692d7d54c1b8e093dd4f14d1c62ba511e01f0d71250df3becc9
MD5 5457b9b9d286a3e9b06e367aa060a75e
BLAKE2b-256 8aee0cc04c8eb1b93021a7be46138c57d070046f1ec4958f1260eb53e946484e

See more details on using hashes here.

File details

Details for the file pysha3-0.3.win32-py3.3.exe.

File metadata

File hashes

Hashes for pysha3-0.3.win32-py3.3.exe
Algorithm Hash digest
SHA256 99a70889dd50a8078da25056544015edd844082a4792863b8eccf21a54117f1e
MD5 0fdde3f0b7b756b645316fba00532ddd
BLAKE2b-256 28b0324891efad0893482069aa5283363a4bc6d06a67fecb57c8592e2dc880c8

See more details on using hashes here.

File details

Details for the file pysha3-0.3.win32-py3.2.exe.

File metadata

File hashes

Hashes for pysha3-0.3.win32-py3.2.exe
Algorithm Hash digest
SHA256 e2b3e9d8a870c0f309c46e44992573fd9c128c6dfdf793f8f71d1d63dcf0e7e7
MD5 228e7a5127ca0eacd859f7c9b6fe7415
BLAKE2b-256 5e73075637101b4c89a6645ca974788789c81331ebc7fcda0f21863ad014aad0

See more details on using hashes here.

File details

Details for the file pysha3-0.3.win32-py2.7.exe.

File metadata

File hashes

Hashes for pysha3-0.3.win32-py2.7.exe
Algorithm Hash digest
SHA256 07f7ca24335fa3d7392ebd3103c1ceecba3285c53437ecad3a2467d74e11f33a
MD5 7a8f93c823911e2caa7573b7ca3f810c
BLAKE2b-256 a9065bb393552f5a57aaf402c1725af49b895b139e68e23a8b3c6dfb6f2dcb48

See more details on using hashes here.

File details

Details for the file pysha3-0.3.win32-py2.6.exe.

File metadata

File hashes

Hashes for pysha3-0.3.win32-py2.6.exe
Algorithm Hash digest
SHA256 688fee61631d3e6b6245f5c6158bdb1df443ed2e1336e80b27ce1788490c5aa4
MD5 9666e460f88b174bf40457f40cf86766
BLAKE2b-256 d8de5b29f8d663a3f7fa350d9e38bd998351810c656e1f22b1cc0eac5adee7ff

See more details on using hashes here.

File details

Details for the file pysha3-0.3-cp34-none-win_amd64.whl.

File metadata

File hashes

Hashes for pysha3-0.3-cp34-none-win_amd64.whl
Algorithm Hash digest
SHA256 ac6a8219d44b106cc3ddb48d7ded6f0b081d160665efad4b42268d21a953d958
MD5 47a9403b214c8a43d19e681daf86ce42
BLAKE2b-256 5aae53f9430a53765636c11ad75ffc55052a81da5a3774884b42d50a4ae595a5

See more details on using hashes here.

File details

Details for the file pysha3-0.3-cp34-none-win32.whl.

File metadata

File hashes

Hashes for pysha3-0.3-cp34-none-win32.whl
Algorithm Hash digest
SHA256 152ed517b078b39ddbd3c9d920beaff49ed0e6dfdb4f70b3ee073a394cb731bf
MD5 93bec3c02225ac5ac41022289350a8d7
BLAKE2b-256 75c15e45ff13ae73df0c4d819d9d6628cd6374e1bcc261e2989777d6fdc658ed

See more details on using hashes here.

File details

Details for the file pysha3-0.3-cp33-none-win_amd64.whl.

File metadata

File hashes

Hashes for pysha3-0.3-cp33-none-win_amd64.whl
Algorithm Hash digest
SHA256 198f643efc7843fcd4079ffef442f73844a15b0e39669e61805dd349458ce3e3
MD5 25d28636975ea090c63482abd22ef4f6
BLAKE2b-256 298fd585360a786d94307c7d977fe566dc9ff0ccd08d559ca3aaf099dab4cfb5

See more details on using hashes here.

File details

Details for the file pysha3-0.3-cp33-none-win32.whl.

File metadata

File hashes

Hashes for pysha3-0.3-cp33-none-win32.whl
Algorithm Hash digest
SHA256 d3fb47683b37e62fc07573eb4289d02a1cba4bec319e66822e3bbc1a4fa85d4e
MD5 957f624823eaa861e03bc8a57cc1a483
BLAKE2b-256 0cfbdad513a7388e2d6fc4c5dec3c4fce8b084421ce7dede3dee2f188418694e

See more details on using hashes here.

File details

Details for the file pysha3-0.3-cp32-none-win_amd64.whl.

File metadata

File hashes

Hashes for pysha3-0.3-cp32-none-win_amd64.whl
Algorithm Hash digest
SHA256 3af0dcb92519cd22fd0fbe8e5de7fe1f0d999a1acc6cc3885c86496818e47f3b
MD5 f1ba94bedb8f9633e713e15a44141703
BLAKE2b-256 c89db297426692a943bf16462ec93ce9ddee956b08b0c932d45cb0d9425f6387

See more details on using hashes here.

File details

Details for the file pysha3-0.3-cp32-none-win32.whl.

File metadata

File hashes

Hashes for pysha3-0.3-cp32-none-win32.whl
Algorithm Hash digest
SHA256 51030f3576f2a9f1a25943e76d1d2d9130ec41aaa1d099455e1aee6506e8cd91
MD5 939a2a29c19a5fbe8ebc228eccf1d164
BLAKE2b-256 7c2c9d440a94fa71a25df5d839924352e397c6bb2298ba0b32add9882ae218f5

See more details on using hashes here.

File details

Details for the file pysha3-0.3-cp27-none-win_amd64.whl.

File metadata

File hashes

Hashes for pysha3-0.3-cp27-none-win_amd64.whl
Algorithm Hash digest
SHA256 d4878634abbbfa5b8ca02507591cb18ee403a8f372e373b422ecca60ef26b239
MD5 743292eeed061ad9b1a77f39820f882c
BLAKE2b-256 b529d5b7a4cf2bed13c32c9c88391393b9dcd0adcb97c5ab71a1a77d0e3d52b1

See more details on using hashes here.

File details

Details for the file pysha3-0.3-cp27-none-win32.whl.

File metadata

File hashes

Hashes for pysha3-0.3-cp27-none-win32.whl
Algorithm Hash digest
SHA256 bbecf3d9678701b845e000867a2368e02168bae4d49fb004b389b8b16365ac7b
MD5 2635b11235356b00b3029b52df9b14aa
BLAKE2b-256 e1ae58d56e13c48179f316b6eb82394eb434353aaf23fd7fa836dad786769087

See more details on using hashes here.

File details

Details for the file pysha3-0.3-cp26-none-win_amd64.whl.

File metadata

File hashes

Hashes for pysha3-0.3-cp26-none-win_amd64.whl
Algorithm Hash digest
SHA256 31828f44cc75288dd20c3c6c111dd6a372331fc68d44a0584e8f352b9d92efbb
MD5 7f546ef211fee5143ff9f23554be2141
BLAKE2b-256 1455896242757c10184010e8873478425c9190500d40f62e2ac170eb4989c401

See more details on using hashes here.

File details

Details for the file pysha3-0.3-cp26-none-win32.whl.

File metadata

File hashes

Hashes for pysha3-0.3-cp26-none-win32.whl
Algorithm Hash digest
SHA256 1dc27bdac73101840fde35b7bf1173f66fe38a4b768a694d11922422447c261d
MD5 566eb0e3c7dee2140a0ce2662f1c4339
BLAKE2b-256 2e8e4307ab6aa3a85263d43946e92ad8df7ec707072a6d0f28e1350169e7ebe9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page