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 and XOR making for fast
encryption. (Decryption uses the same function.) Salsa20
is simple and quick.
Some Salsa20 parameter values...
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.
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
(no I/O and before Python GC kicks in)
Salsa20 is a Phase 3 finalist in the EU eSTREAM competition
and appears to be one of the fastest ciphers. It is well
documented so I will not attempt any injustice here. Please
see "References" below.
...and Salsa20 is "free for any use".
pySalsa20: a Python wrapper for Salsa20
---------------------------------------
pySalsa20.py is a simple ctypes Python 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. Compile the version of your choice
as a shared library (not as a Python extension), name and
install it as libsalsa20.so.
Sample usage:
from pySalsa20 import Salsa20
s20 = Salsa20(key, IV)
dataout = s20.encryptBytes(datain) # same for decrypt
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
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/salsa20p3.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
------------------------------------------------------------------------
------------------------------------------------------------------------
------------------------------------------------------------------------