[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Pure Python Salsa20 Stream Cipher Implementation

betabrain.honshu

2/8/2008 6:42:00 AM

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

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
14 Answers

Paul Rubin

2/8/2008 9:18:00 AM

0

betabrain.honshu@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...

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

Paul Rubin

2/8/2008 9:20:00 AM

0

betabrain.honshu@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...

By the way, here is a concise implementation of salsa20 in C:

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

maybe it could be converted to python more conveniently than
converting the reference implementation.

betabrain.honshu

2/9/2008 3:35:00 AM

0

On 8 Feb., 17:18, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
> 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.

Gabriel Genellina

2/9/2008 4:08:00 AM

0

En Sat, 09 Feb 2008 01:34:30 -0200, <betabrain.honshu@gmail.com> escribió:
> On 8 Feb., 17:18, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:

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

Paul Rubin

2/9/2008 8:49:00 AM

0

betabrain.honshu@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.

Paul Rubin

2/9/2008 8:50:00 AM

0

"Gabriel Genellina" <gagsl-py2@yahoo.com.ar> writes:
> 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.

Bearophile

2/9/2008 10:22:00 AM

0

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

aahz

2/9/2008 10:30:00 PM

0

In article <mailman.546.1202530094.9267.python-list@python.org>,
Gabriel Genellina <gagsl-py2@yahoo.com.ar> wrote:
>En Sat, 09 Feb 2008 01:34:30 -0200, <betabrain.honshu@gmail.com> escribió:
>> On 8 Feb., 17:18, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
>>>
>>> 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 (aahz@pythoncraft.com) <*> http://www.python...

"All problems in computer science can be solved by another level of
indirection." --Butler Lampson

Gabriel Genellina

2/10/2008 4:51:00 AM

0

En Sat, 09 Feb 2008 20:29:58 -0200, Aahz <aahz@pythoncraft.com> escribió:

> In article <mailman.546.1202530094.9267.python-list@python.org>,
> Gabriel Genellina <gagsl-py2@yahoo.com.ar> wrote:
>> En Sat, 09 Feb 2008 01:34:30 -0200, <betabrain.honshu@gmail.com>
>> escribió:
>>> On 8 Feb., 17:18, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
>>>>
>>>> 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

ThunderBug

2/10/2008 8:43:00 AM

0

And FWIW.... there already exists a pySalsa20, a ctypes wrapper for
Bernstein's eSTREAM submission.
http://www.seanet.com/~bugb...