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).

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'

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.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

  • fixed MANIFEST.in to include Makefile and tests.py

  • added setup.py test command with hack for inplace builds

  • enhanced 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.2.2.zip (59.9 kB view details)

Uploaded Source

pysha3-0.2.2.tar.gz (46.5 kB view details)

Uploaded Source

Built Distributions

pysha3-0.2.2.win-amd64-py3.3.exe (276.2 kB view details)

Uploaded Source

pysha3-0.2.2.win-amd64-py3.2.exe (278.6 kB view details)

Uploaded Source

pysha3-0.2.2.win-amd64-py2.7.exe (278.1 kB view details)

Uploaded Source

pysha3-0.2.2.win-amd64-py2.6.exe (246.4 kB view details)

Uploaded Source

pysha3-0.2.2.win32-py3.3.exe (212.5 kB view details)

Uploaded Source

pysha3-0.2.2.win32-py3.2.exe (217.6 kB view details)

Uploaded Source

pysha3-0.2.2.win32-py2.7.exe (217.6 kB view details)

Uploaded Source

pysha3-0.2.2.win32-py2.6.exe (216.6 kB view details)

Uploaded Source

File details

Details for the file pysha3-0.2.2.zip.

File metadata

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

File hashes

Hashes for pysha3-0.2.2.zip
Algorithm Hash digest
SHA256 016eb8fcd931b903a88401d20b40859c3705f91c55f8f7cc61a1ed67b76e922e
MD5 af809c6600e0c41656a1dc603a13b726
BLAKE2b-256 a0d92bab192413fbeab2ce4c34d4d0ba261fca3a6c4e5befcbbb60c8494cd61f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pysha3-0.2.2.tar.gz
Algorithm Hash digest
SHA256 afedc110ad816ec0d08feff62f5d674b9b90a4028209cbc93a3e362e9fd5a05c
MD5 5899db42dd400e104f8d018467c4c35b
BLAKE2b-256 4bf1c9dbc9989d65dea3ba54526b1e222b9b7d974128e7518927f7bd69ffd0dd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysha3-0.2.2.win-amd64-py3.3.exe
Algorithm Hash digest
SHA256 d456dc45c2fc73b45d1fdd38840c39bef77d350e0d7bb6223be89eb4b1d7f697
MD5 7892e36806a2aa87b73b129fc7302b07
BLAKE2b-256 7f08c56a5d92f30c4e54b4ad7b83ea021ed1e1c687cf2c966066258fe667c9bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysha3-0.2.2.win-amd64-py3.2.exe
Algorithm Hash digest
SHA256 185e0d630165d2482c18ffd0f5048e7cfa69d114f956870cd4b04433d99ee071
MD5 46a92d6c29b003f7c8a031d795f53402
BLAKE2b-256 6c21b5129935af4f4912403142d787815a2e2835be774fef4dadbebb244ccfee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysha3-0.2.2.win-amd64-py2.7.exe
Algorithm Hash digest
SHA256 0dfa4885371b6fec523f82b9443e4bb5bc9da95857cd8f90097aceebb93ff2c8
MD5 8a2e21c6d336a833bb93ab743fbe0352
BLAKE2b-256 cf434118c6f73f671cd842f7f72e31e9465586a6876783f633d4e51046f2cb13

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysha3-0.2.2.win-amd64-py2.6.exe
Algorithm Hash digest
SHA256 02a658921389132c375ffcb819bc6568e8ae83fbe9dc5ca70e967e189f7b190c
MD5 d137af764948d2d59798c7e4db6d4df6
BLAKE2b-256 5267a7039c87b2f5d20d1a64f21a06e175bf63ad75640099a6418147000724b7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysha3-0.2.2.win32-py3.3.exe
Algorithm Hash digest
SHA256 d4cc857adcbfd047eb6eec6c8e6fc078ed0c2d90c91f92dd0dd7ab5e12bfd8bd
MD5 ad4f0a7241171eb34637928b98a2dd0d
BLAKE2b-256 077b501af2b62c48f9f141e70ab4bee3e9a29a097ac59168e5000afad7669362

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysha3-0.2.2.win32-py3.2.exe
Algorithm Hash digest
SHA256 5dcf7c4b7bcce37590a2642a02181c2c525c649c6a98a4efc3fc45c0e8a17fb5
MD5 ed95381b1c9d881c0b6643829da4dead
BLAKE2b-256 cc237fec5fbb3c7e5ebe3b46d7f683981fde5b3ade64f6c0aa6894348c4266df

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysha3-0.2.2.win32-py2.7.exe
Algorithm Hash digest
SHA256 c7d9e78f7adc96b401eab3ce764dcd69345117cad416aa41ba9f339cc582a99a
MD5 7dbdf66324b8f0f96456bbc3a69ebba3
BLAKE2b-256 3eb2d084567fac6d80e25284c9f11cf7fd23313c3816c9d5009e7a76165d2357

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysha3-0.2.2.win32-py2.6.exe
Algorithm Hash digest
SHA256 69124bbc4fbc403ad47858dc1dbf8ec88de9d2d9705770075af6e2a51a687a14
MD5 b08c784fb9c9917afc73b146f3212061
BLAKE2b-256 2f6afe1ec64f7190637253e0a257c632071565b40de5826360c2536e858348dd

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