Index of /~bugbee/crypto/salsa20
Name Last modified Size Description
Parent Directory 06-Mar-2008 22:41 -
Salsa20example1.java 02-Jul-2007 22:05 8k
hotSalsa-v1.py 03-Jul-2007 13:52 6k
pySalsa20-v3.zip 20-Apr-2007 23:02 16k
Salsa20: a Fast Streaming Cipher
--------------------------------
Salsa20 is a fast stream cipher written by Daniel Bernstein
that basically uses a hash function to create a stream that
is XORed on the data making for very fast encryption and
decryption.
design strength 128 bits
key length 128 or 256 bits, exactly
IV, aka nonce 64 bits, always
chunk size must be in multiples of 64 bytes
Salsa20 has two reduced versions, 8 and 12 rounds each. The
12-round reduced version, Salsa20/12, is a "winner" of the
EU eSTREAM competition.
...and Salsa20 is "free for any use".
pySalsa20: a Python wrapper for Salsa20
---------------------------------------
pySalsa20.py is a simple Python ctypes wrapper. Salsa20 is
as it's name implies, 20 rounds, but there are two reduced
versions, 8 and 12 rounds each. Because the APIs are
identical, pySalsa20 is capable of wrapping all three
versions (number of rounds hardcoded), including a special
version that allows you to set the number of rounds with a
set_rounds() function. Source modification is preferred,
but one easy way to get Salsa20/12 is to call set_rounds(12).
Be sure to compile the version of your choice as a shared
library (not as a Python extension), name and install it as
libsalsa20.so.
Usage:
from pySalsa20 import Salsa20
s20 = Salsa20(key, IV)
dataout = s20.encryptBytes(datain) # same for decrypt
One benchmark (10 MB):
1.5GHz PPC G4 102/97/89 MB/sec for 8/12/20 rounds
AMD Athlon 2500+ 77/67/53 MB/sec for 8/12/20 rounds
(memory only, no I/O, and before Python GC kicks in)
This is EXPERIMENTAL software and intended for educational
purposes only. To make experimentation less cumbersome,
pySalsa20 is also free for any use.
THIS PROGRAM IS PROVIDED WITHOUT WARRANTY OR GUARANTEE OF
ANY KIND. USE AT YOUR OWN RISK.
Enjoy,
Larry Bugbee
bugbee@seanet.com
April 2007
rev Dec 2008
References:
-----------
http://en.wikipedia.org/wiki/Salsa20
http://en.wikipedia.org/wiki/Daniel_Bernstein
http://cr.yp.to/djb.html
http://www.ecrypt.eu.org/stream/salsa20pf.html
http://www.ecrypt.eu.org/stream/p3ciphers/salsa20/salsa20_p3source.zip
Prerequisites:
-------------
- Python 2.5 (or 2.4 with ctypes added)
- gcc 4.x (gcc 3 should work)
Installation:
-------------
Compile provided .c source (set_rounds() mod included) or
download salsa20_p3source.zip (see refs) and compile (you
may want to apply the changes for set_rounds(), or not ;-)
PPC MacOSX:
export MACOSX_DEPLOYMENT_TARGET=10.4
gcc -fPIC -maltivec -O3 -dynamic -bundle \
-undefined dynamic_lookup \
-o libsalsa20.so ecrypt-altivec-ppc.c
Linux:
gcc -fPIC -O3 -shared -o libsalsa20.so ecrypt-linux.c
Windows:
see http://buggywhip.blogspot.com/2007/07/making-simple-dlls-simply.html
Install libsalsa20.so:
sudo cp libsalsa20.so /usr/local/lib # Mandriva wanted /usr/lib
Quick test:
python pySalsa20.py
Install pySalsa20.py:
sudo python setup.py install
------------------------------------------------------------------------
------------------------------------------------------------------------
------------------------------------------------------------------------