469,626 Members | 1,046 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,626 developers. It's quick & easy.

Pure Python Salsa20 Stream Cipher Implementation

Hi Folks,

for those of you who are familiar with the micropledge.com project,
here is a good opportunity to spend or earn something:
http://micropledge.com/projects/pysalsa20

I know that the details of this project are still a bit unclear, but
that is something we could discuss. By the way, the end result should
look like it's a part of the python standard library (naming
conventions, etc.) and of course it will be open source.

Thanks
Ich
Feb 8 '08 #1
12 2730
be**************@gmail.com writes:
for those of you who are familiar with the micropledge.com project,
here is a good opportunity to spend or earn something:
http://micropledge.com/projects/pysalsa20
I don't understand why a pure python version of salsa20 would be
interesting. Is there some application that uses salsa20, that's
worth being able to interoperate with in pure python?

If you just want a stream cipher in pure python (including its
standard library), the fastest way seems to be able to use the sha
module as a building block:

http://www.nightsong.com/phr/crypto/p3.py
Feb 8 '08 #2
be**************@gmail.com writes:
for those of you who are familiar with the micropledge.com project,
here is a good opportunity to spend or earn something:
http://micropledge.com/projects/pysalsa20
By the way, here is a concise implementation of salsa20 in C:

http://www.nightsong.com/phr/crypto/salsa20.c

maybe it could be converted to python more conveniently than
converting the reference implementation.
Feb 8 '08 #3
On 8 Feb., 17:18, Paul Rubin <http://phr...@NOSPAM.invalidwrote:
I don't understand why a pure python version of salsa20 would be
interesting. Is there some application that uses salsa20, that's
worth being able to interoperate with in pure python?
The reason for a pure python is that it would be independent from the
platform. A C implementation is faster, but you need to compile it for
every platform. A python implementation doesn't have that problem and
could be used to fall back upon.
Feb 9 '08 #4
En Sat, 09 Feb 2008 01:34:30 -0200, <be**************@gmail.comescribió:
On 8 Feb., 17:18, Paul Rubin <http://phr...@NOSPAM.invalidwrote:
>I don't understand why a pure python version of salsa20 would be
interesting. Is there some application that uses salsa20, that's
worth being able to interoperate with in pure python?

The reason for a pure python is that it would be independent from the
platform. A C implementation is faster, but you need to compile it for
every platform. A python implementation doesn't have that problem and
could be used to fall back upon.
On most platforms -with a notable exception- there is a C compiler
available as a standard tool, which is used to compile Python itself.
distutils can easily compile and install C extensions itself, so most of
the time "python setup.py install" is the only thing users have to
execute, exactly the same as if the package were pure Python. With
setuptools, things may be even easier.

I'm not saying that there is no merit in having a Python implementation,
just that -as Paul Rubin pointed out- the *need* for such thing is not too
high.

--
Gabriel Genellina

Feb 9 '08 #5
be**************@gmail.com writes:
The reason for a pure python is that it would be independent from the
platform. A C implementation is faster, but you need to compile it for
every platform. A python implementation doesn't have that problem and
could be used to fall back upon.
But why salsa20 in that case, unless it's approved as a standard? If
you're willing to put up with terrible performance in the fallback
implementation, you may as well use AES, which is a standard. If you
want reasonable performance in the fallback implementation, use
one of the hashlib functions as a cipher.
Feb 9 '08 #6
"Gabriel Genellina" <ga*******@yahoo.com.arwrites:
On most platforms -with a notable exception- there is a C compiler
available as a standard tool, which is used to compile Python itself.
The notable exception that you're thinking of is pervasive, but since
Python is usually distributed as a binary for those systems, there
might as well also be a binary crypto module, and in fact there are
quite a few.
Feb 9 '08 #7
Gabriel Genellina:
On most platforms -with a notable exception- there is a C compiler
available as a standard tool, which is used to compile Python itself.
For that platform the Python site may offer a version of binary Python
bundled with the MingGW (and Cython too, maybe), like ShedSkin does.

Bye,
bearophile
Feb 9 '08 #8
In article <ma*************************************@python.or g>,
Gabriel Genellina <ga*******@yahoo.com.arwrote:
>En Sat, 09 Feb 2008 01:34:30 -0200, <be**************@gmail.comescribió:
>On 8 Feb., 17:18, Paul Rubin <http://phr...@NOSPAM.invalidwrote:
>>>
I don't understand why a pure python version of salsa20 would be
interesting. Is there some application that uses salsa20, that's
worth being able to interoperate with in pure python?

The reason for a pure python is that it would be independent from the
platform. A C implementation is faster, but you need to compile it for
every platform. A python implementation doesn't have that problem and
could be used to fall back upon.

On most platforms -with a notable exception- there is a C compiler
available as a standard tool, which is used to compile Python itself.
distutils can easily compile and install C extensions itself, so most of
the time "python setup.py install" is the only thing users have to
execute, exactly the same as if the package were pure Python. With
setuptools, things may be even easier.
What about Jython, PyPy, and IronPython?
--
Aahz (aa**@pythoncraft.com) <* http://www.pythoncraft.com/

"All problems in computer science can be solved by another level of
indirection." --Butler Lampson
Feb 9 '08 #9
En Sat, 09 Feb 2008 20:29:58 -0200, Aahz <aa**@pythoncraft.comescribió:
In article <ma*************************************@python.or g>,
Gabriel Genellina <ga*******@yahoo.com.arwrote:
>En Sat, 09 Feb 2008 01:34:30 -0200, <be**************@gmail.com>
escribió:
>>On 8 Feb., 17:18, Paul Rubin <http://phr...@NOSPAM.invalidwrote:

I don't understand why a pure python version of salsa20 would be
interesting. Is there some application that uses salsa20, that's
worth being able to interoperate with in pure python?

The reason for a pure python is that it would be independent from the
platform. A C implementation is faster, but you need to compile it for
every platform. A python implementation doesn't have that problem and
could be used to fall back upon.

On most platforms -with a notable exception- there is a C compiler
available as a standard tool, which is used to compile Python itself.
distutils can easily compile and install C extensions itself, so most of
the time "python setup.py install" is the only thing users have to
execute, exactly the same as if the package were pure Python. With
setuptools, things may be even easier.

What about Jython, PyPy, and IronPython?
What about them?
Do you mean that there should be a Python implementation for each and
every imaginable module over there, so it can be used with all of those
Python variants? Restricted of course to their minimum common feature set?

--
Gabriel Genellina

Feb 10 '08 #10
And FWIW.... there already exists a pySalsa20, a ctypes wrapper for
Bernstein's eSTREAM submission.
http://www.seanet.com/~bugbee/crypto/
Feb 10 '08 #11
In article <ma*************************************@python.or g>,
Gabriel Genellina <ga*******@yahoo.com.arwrote:
>En Sat, 09 Feb 2008 20:29:58 -0200, Aahz <aa**@pythoncraft.comescribió:
>In article <ma*************************************@python.or g>,
Gabriel Genellina <ga*******@yahoo.com.arwrote:
>>En Sat, 09 Feb 2008 01:34:30 -0200, <be**************@gmail.com>
escribió:
On 8 Feb., 17:18, Paul Rubin <http://phr...@NOSPAM.invalidwrote:
>
I don't understand why a pure python version of salsa20 would be
interesting. Is there some application that uses salsa20, that's
worth being able to interoperate with in pure python?

The reason for a pure python is that it would be independent from the
platform. A C implementation is faster, but you need to compile it for
every platform. A python implementation doesn't have that problem and
could be used to fall back upon.

On most platforms -with a notable exception- there is a C compiler
available as a standard tool, which is used to compile Python itself.
distutils can easily compile and install C extensions itself, so most of
the time "python setup.py install" is the only thing users have to
execute, exactly the same as if the package were pure Python. With
setuptools, things may be even easier.

What about Jython, PyPy, and IronPython?

What about them?
Do you mean that there should be a Python implementation for each and
every imaginable module over there, so it can be used with all of those
Python variants? Restricted of course to their minimum common feature set?
<shrug Is there some reason you're using exaggerated language? My only
point is that simply saying "C compiler! C compiler!" ignores the fact
that Python itself is multi-platform (and makes you look foolish);
whether any given module should be written in pure Python needs to be
decided on a case-by-case basis.
--
Aahz (aa**@pythoncraft.com) <* http://www.pythoncraft.com/

"All problems in computer science can be solved by another level of
indirection." --Butler Lampson
Feb 11 '08 #12
En Mon, 11 Feb 2008 17:29:49 -0200, Aahz <aa**@pythoncraft.comescribió:
In article <ma*************************************@python.or g>,
Gabriel Genellina <ga*******@yahoo.com.arwrote:
>En Sat, 09 Feb 2008 20:29:58 -0200, Aahz <aa**@pythoncraft.com>
escribió:
>>In article <ma*************************************@python.or g>,
Gabriel Genellina <ga*******@yahoo.com.arwrote:
En Sat, 09 Feb 2008 01:34:30 -0200, <be**************@gmail.com>
escribió:
On 8 Feb., 17:18, Paul Rubin <http://phr...@NOSPAM.invalidwrote:
>>
>I don't understand why a pure python version of salsa20 would be
>interesting. Is there some application that uses salsa20, that's
>worth being able to interoperate with in pure python?
>
The reason for a pure python is that it would be independent from the
platform. A C implementation is faster, but you need to compile it
for
every platform. A python implementation doesn't have that problem and
could be used to fall back upon.

On most platforms -with a notable exception- there is a C compiler
available as a standard tool, which is used to compile Python itself.
distutils can easily compile and install C extensions itself, so most
of
the time "python setup.py install" is the only thing users have to
execute, exactly the same as if the package were pure Python. With
setuptools, things may be even easier.

What about Jython, PyPy, and IronPython?

What about them?
Do you mean that there should be a Python implementation for each and
every imaginable module over there, so it can be used with all of those
Python variants? Restricted of course to their minimum common feature
set?

<shrug Is there some reason you're using exaggerated language? My only
point is that simply saying "C compiler! C compiler!" ignores the fact
that Python itself is multi-platform (and makes you look foolish);
whether any given module should be written in pure Python needs to be
decided on a case-by-case basis.
And that's exactly what I said, I don't see the need for a pure Python
implementation of salsa20 based solely on "you need to compile [the C
source] on every platform" (cf. quoted text above). That's all, and I
don't want to argue with you or anyone about this.

--
Gabriel Genellina

Feb 11 '08 #13

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Gandalf | last post: by
1 post views Thread by David Mertz, Ph.D. | last post: by
3 posts views Thread by andrew.fabbro | last post: by
34 posts views Thread by Blake T. Garretson | last post: by
3 posts views Thread by Marco Meoni | last post: by
5 posts views Thread by Michael Sperlle | last post: by
reply views Thread by ml1n | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.